Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPosition.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
Freagarach: `++` | |||||
* 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, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "simulation2/system/Component.h" | #include "simulation2/system/Component.h" | ||||
#include "ICmpPosition.h" | #include "ICmpPosition.h" | ||||
#include "simulation2/MessageTypes.h" | #include "simulation2/MessageTypes.h" | ||||
#include "simulation2/serialization/SerializeTemplates.h" | |||||
Done Inline Actionsleftover ? Stan: leftover ? | |||||
Done Inline ActionsI believe this is included in SerializedTypes so no need to explicitly include it wraitii: I believe this is included in SerializedTypes so no need to explicitly include it | |||||
#include "ICmpTerrain.h" | #include "ICmpTerrain.h" | ||||
#include "ICmpTerritoryManager.h" | #include "ICmpTerritoryManager.h" | ||||
#include "ICmpVisual.h" | #include "ICmpVisual.h" | ||||
#include "ICmpWaterManager.h" | #include "ICmpWaterManager.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "lib/rand.h" | #include "lib/rand.h" | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public: | ||||
// when the entity is a turret, only m_RotY is used, and this is the rotation | // when the entity is a turret, only m_RotY is used, and this is the rotation | ||||
// relative to the parent entity | // relative to the parent entity | ||||
entity_angle_t m_RotX, m_RotY, m_RotZ; | entity_angle_t m_RotX, m_RotY, m_RotZ; | ||||
player_id_t m_Territory; | player_id_t m_Territory; | ||||
entity_id_t m_TurretParent; | entity_id_t m_TurretParent; | ||||
CFixedVector3D m_TurretPosition; | CFixedVector3D m_TurretPosition; | ||||
std::set<entity_id_t> m_Turrets; | std::set<entity_id_t> m_Turrets; | ||||
Done Inline ActionsInitialised here. Freagarach: Initialised here. | |||||
// Not serialized: | // Not serialized: | ||||
float m_InterpolatedRotX, m_InterpolatedRotY, m_InterpolatedRotZ; | float m_InterpolatedRotX, m_InterpolatedRotY, m_InterpolatedRotZ; | ||||
float m_LastInterpolatedRotX, m_LastInterpolatedRotZ; | float m_LastInterpolatedRotX, m_LastInterpolatedRotZ; | ||||
bool m_ActorFloating; | bool m_ActorFloating; | ||||
bool m_EnabledMessageInterpolate; | bool m_EnabledMessageInterpolate; | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | virtual void Serialize(ISerializer& serialize) | ||||
} | } | ||||
serialize.NumberU32_Unbounded("turret parent", m_TurretParent); | serialize.NumberU32_Unbounded("turret parent", m_TurretParent); | ||||
if (m_TurretParent != INVALID_ENTITY) | if (m_TurretParent != INVALID_ENTITY) | ||||
{ | { | ||||
serialize.NumberFixed_Unbounded("x", m_TurretPosition.X); | serialize.NumberFixed_Unbounded("x", m_TurretPosition.X); | ||||
serialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); | serialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); | ||||
serialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); | serialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); | ||||
} | } | ||||
SerializeSet<SerializeU32_Unbounded>()(serialize, "turrets", m_Turrets); | |||||
} | } | ||||
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) | virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) | ||||
{ | { | ||||
Init(paramNode); | Init(paramNode); | ||||
deserialize.Bool("in world", m_InWorld); | deserialize.Bool("in world", m_InWorld); | ||||
if (m_InWorld) | if (m_InWorld) | ||||
Show All 20 Lines | virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) | ||||
deserialize.NumberU32_Unbounded("turret parent", m_TurretParent); | deserialize.NumberU32_Unbounded("turret parent", m_TurretParent); | ||||
if (m_TurretParent != INVALID_ENTITY) | if (m_TurretParent != INVALID_ENTITY) | ||||
{ | { | ||||
deserialize.NumberFixed_Unbounded("x", m_TurretPosition.X); | deserialize.NumberFixed_Unbounded("x", m_TurretPosition.X); | ||||
deserialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); | deserialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); | ||||
deserialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); | deserialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); | ||||
} | } | ||||
SerializeSet<SerializeU32_Unbounded>()(deserialize, "turrets", m_Turrets); | |||||
if (m_InWorld) | if (m_InWorld) | ||||
UpdateXZRotation(); | UpdateXZRotation(); | ||||
UpdateMessageSubscriptions(); | UpdateMessageSubscriptions(); | ||||
} | } | ||||
void Deserialized() | void Deserialized() | ||||
▲ Show 20 Lines • Show All 709 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
++