Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpVisualActor.cpp
/* Copyright (C) 2022 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | public: | ||||
{ | { | ||||
if (m_Unit) | if (m_Unit) | ||||
{ | { | ||||
GetSimContext().GetUnitManager().DeleteUnit(m_Unit); | GetSimContext().GetUnitManager().DeleteUnit(m_Unit); | ||||
m_Unit = NULL; | m_Unit = NULL; | ||||
} | } | ||||
} | } | ||||
void Update(const CParamNode& paramNode) override | |||||
{ | |||||
m_ConstructionPreview = paramNode.GetChild("ConstructionPreview").IsOk(); | |||||
m_IsFoundationActor = paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk(); | |||||
m_BaseActorName = paramNode.GetChild(m_IsFoundationActor ? "FoundationActor" : "Actor").ToWString(); | |||||
// Don't parse, we recompute down below | |||||
m_VisibleInAtlasOnly = paramNode.GetChild("VisibleInAtlasOnly").ToBool(); | |||||
m_IsActorOnly = paramNode.GetChild("ActorOnly").IsOk(); | |||||
m_SilhouetteDisplay = paramNode.GetChild("SilhouetteDisplay").ToBool(); | |||||
m_SilhouetteOccluder = paramNode.GetChild("SilhouetteOccluder").ToBool(); | |||||
m_DisableShadows = paramNode.GetChild("DisableShadows").ToBool(); | |||||
InitSelectionShapeDescriptor(paramNode); | |||||
RecomputeActorName(); | |||||
} | |||||
template<typename S> | template<typename S> | ||||
void SerializeCommon(S& serialize) | void SerializeCommon(S& serialize) | ||||
{ | { | ||||
serialize.NumberFixed_Unbounded("r", m_R); | serialize.NumberFixed_Unbounded("r", m_R); | ||||
serialize.NumberFixed_Unbounded("g", m_G); | serialize.NumberFixed_Unbounded("g", m_G); | ||||
serialize.NumberFixed_Unbounded("b", m_B); | serialize.NumberFixed_Unbounded("b", m_B); | ||||
serialize.StringASCII("anim name", m_AnimName, 0, 256); | serialize.StringASCII("anim name", m_AnimName, 0, 256); | ||||
▲ Show 20 Lines • Show All 411 Lines • ▼ Show 20 Lines | void CCmpVisualActor::InitModel() | ||||
// the model is now responsible for cleaning up the descriptor | // the model is now responsible for cleaning up the descriptor | ||||
if (m_ShapeDescriptor != nullptr) | if (m_ShapeDescriptor != nullptr) | ||||
m_Unit->GetModel().SetCustomSelectionShape(m_ShapeDescriptor); | m_Unit->GetModel().SetCustomSelectionShape(m_ShapeDescriptor); | ||||
} | } | ||||
void CCmpVisualActor::InitSelectionShapeDescriptor(const CParamNode& paramNode) | void CCmpVisualActor::InitSelectionShapeDescriptor(const CParamNode& paramNode) | ||||
{ | { | ||||
// by default, we don't need a custom selection shape and we can just keep the default behaviour | // by default, we don't need a custom selection shape and we can just keep the default behaviour | ||||
// We don't need to delete the descriptor here, because the CModelAbstract holds it. | |||||
m_ShapeDescriptor = nullptr; | m_ShapeDescriptor = nullptr; | ||||
const CParamNode& shapeNode = paramNode.GetChild("SelectionShape"); | const CParamNode& shapeNode = paramNode.GetChild("SelectionShape"); | ||||
if (shapeNode.IsOk()) | if (shapeNode.IsOk()) | ||||
{ | { | ||||
if (shapeNode.GetChild("Bounds").IsOk()) | if (shapeNode.GetChild("Bounds").IsOk()) | ||||
{ | { | ||||
// default; no need to take action | // default; no need to take action | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator