Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPosition.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 160 Lines • ▼ Show 20 Lines | void Init(const CParamNode& paramNode) override | ||||
m_EnabledMessageInterpolate = false; | m_EnabledMessageInterpolate = false; | ||||
} | } | ||||
void Deinit() override | void Deinit() override | ||||
{ | { | ||||
} | } | ||||
void Update(const CParamNode& paramNode) override | |||||
{ | |||||
const std::string& anchor = paramNode.GetChild("Anchor").ToString(); | |||||
if (anchor == "pitch") | |||||
m_AnchorType = PITCH; | |||||
else if (anchor == "pitch-roll") | |||||
m_AnchorType = PITCH_ROLL; | |||||
else if (anchor == "roll") | |||||
m_AnchorType = ROLL; | |||||
else | |||||
m_AnchorType = UPRIGHT; | |||||
if (m_RelativeToGround) | |||||
m_Y = paramNode.GetChild("Altitude").ToFixed(); | |||||
m_Floating = paramNode.GetChild("Floating").ToBool(); | |||||
m_FloatDepth = paramNode.GetChild("FloatDepth").ToFixed(); | |||||
m_RotYSpeed = paramNode.GetChild("TurnRate").ToFixed(); | |||||
AdvertiseInterpolatedPositionChanges(); | |||||
} | |||||
void Serialize(ISerializer& serialize) override | void Serialize(ISerializer& serialize) override | ||||
{ | { | ||||
serialize.Bool("in world", m_InWorld); | serialize.Bool("in world", m_InWorld); | ||||
if (m_InWorld) | if (m_InWorld) | ||||
{ | { | ||||
serialize.NumberFixed_Unbounded("x", m_X); | serialize.NumberFixed_Unbounded("x", m_X); | ||||
serialize.NumberFixed_Unbounded("y", m_Y); | serialize.NumberFixed_Unbounded("y", m_Y); | ||||
serialize.NumberFixed_Unbounded("z", m_Z); | serialize.NumberFixed_Unbounded("z", m_Z); | ||||
serialize.NumberFixed_Unbounded("last x", m_LastX); | serialize.NumberFixed_Unbounded("last x", m_LastX); | ||||
serialize.NumberFixed_Unbounded("last y diff", m_LastYDifference); | serialize.NumberFixed_Unbounded("last y diff", m_LastYDifference); | ||||
serialize.NumberFixed_Unbounded("last z", m_LastZ); | serialize.NumberFixed_Unbounded("last z", m_LastZ); | ||||
} | } | ||||
serialize.NumberI32_Unbounded("territory", m_Territory); | serialize.NumberI32_Unbounded("territory", m_Territory); | ||||
serialize.NumberFixed_Unbounded("rot x", m_RotX); | serialize.NumberFixed_Unbounded("rot x", m_RotX); | ||||
serialize.NumberFixed_Unbounded("rot y", m_RotY); | serialize.NumberFixed_Unbounded("rot y", m_RotY); | ||||
serialize.NumberFixed_Unbounded("rot z", m_RotZ); | serialize.NumberFixed_Unbounded("rot z", m_RotZ); | ||||
serialize.NumberFixed_Unbounded("rot y speed", m_RotYSpeed); | |||||
serialize.NumberFixed_Unbounded("altitude", m_Y); | serialize.NumberFixed_Unbounded("altitude", m_Y); | ||||
serialize.Bool("relative", m_RelativeToGround); | serialize.Bool("relative", m_RelativeToGround); | ||||
serialize.Bool("floating", m_Floating); | serialize.Bool("floating", m_Floating); | ||||
serialize.NumberFixed_Unbounded("float depth", m_FloatDepth); | serialize.NumberFixed_Unbounded("float depth", m_FloatDepth); | ||||
serialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress); | serialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress); | ||||
if (serialize.IsDebug()) | if (serialize.IsDebug()) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (m_InWorld) | ||||
deserialize.NumberFixed_Unbounded("last x", m_LastX); | deserialize.NumberFixed_Unbounded("last x", m_LastX); | ||||
deserialize.NumberFixed_Unbounded("last y diff", m_LastYDifference); | deserialize.NumberFixed_Unbounded("last y diff", m_LastYDifference); | ||||
deserialize.NumberFixed_Unbounded("last z", m_LastZ); | deserialize.NumberFixed_Unbounded("last z", m_LastZ); | ||||
} | } | ||||
deserialize.NumberI32_Unbounded("territory", m_Territory); | deserialize.NumberI32_Unbounded("territory", m_Territory); | ||||
deserialize.NumberFixed_Unbounded("rot x", m_RotX); | deserialize.NumberFixed_Unbounded("rot x", m_RotX); | ||||
deserialize.NumberFixed_Unbounded("rot y", m_RotY); | deserialize.NumberFixed_Unbounded("rot y", m_RotY); | ||||
deserialize.NumberFixed_Unbounded("rot z", m_RotZ); | deserialize.NumberFixed_Unbounded("rot z", m_RotZ); | ||||
deserialize.NumberFixed_Unbounded("rot y speed", m_RotYSpeed); | |||||
deserialize.NumberFixed_Unbounded("altitude", m_Y); | deserialize.NumberFixed_Unbounded("altitude", m_Y); | ||||
deserialize.Bool("relative", m_RelativeToGround); | deserialize.Bool("relative", m_RelativeToGround); | ||||
deserialize.Bool("floating", m_Floating); | deserialize.Bool("floating", m_Floating); | ||||
deserialize.NumberFixed_Unbounded("float depth", m_FloatDepth); | deserialize.NumberFixed_Unbounded("float depth", m_FloatDepth); | ||||
deserialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress); | deserialize.NumberFixed_Unbounded("constructionprogress", m_ConstructionProgress); | ||||
// TODO: should there be range checks on all these values? | // TODO: should there be range checks on all these values? | ||||
m_InterpolatedRotY = m_RotY.ToFloat(); | m_InterpolatedRotY = m_RotY.ToFloat(); | ||||
▲ Show 20 Lines • Show All 737 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator