Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpUnitMotion.h
Show First 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | if (paramNode.GetChild("RunMultiplier").IsOk()) | ||||||||||
m_RunMultiplier = m_TemplateRunMultiplier = paramNode.GetChild("RunMultiplier").ToFixed(); | m_RunMultiplier = m_TemplateRunMultiplier = paramNode.GetChild("RunMultiplier").ToFixed(); | ||||||||||
m_InstantTurnAngle = paramNode.GetChild("InstantTurnAngle").ToFixed(); | m_InstantTurnAngle = paramNode.GetChild("InstantTurnAngle").ToFixed(); | ||||||||||
m_Acceleration = m_TemplateAcceleration = paramNode.GetChild("Acceleration").ToFixed(); | m_Acceleration = m_TemplateAcceleration = paramNode.GetChild("Acceleration").ToFixed(); | ||||||||||
m_TemplateWeight = paramNode.GetChild("Weight").ToFixed(); | m_TemplateWeight = paramNode.GetChild("Weight").ToFixed(); | ||||||||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity()); | |||||||||||
if (cmpPathfinder) | |||||||||||
{ | |||||||||||
m_PassClassName = paramNode.GetChild("PassabilityClass").ToString(); | m_PassClassName = paramNode.GetChild("PassabilityClass").ToString(); | ||||||||||
m_PassClass = cmpPathfinder->GetPassabilityClass(m_PassClassName); | SetPassabilityData(m_PassClassName); | ||||||||||
m_Clearance = cmpPathfinder->GetClearance(m_PassClass); | |||||||||||
CmpPtr<ICmpObstruction> cmpObstruction(GetEntityHandle()); | CmpPtr<ICmpObstruction> cmpObstruction(GetEntityHandle()); | ||||||||||
if (cmpObstruction) | if (cmpObstruction) | ||||||||||
{ | |||||||||||
cmpObstruction->SetUnitClearance(m_Clearance); | |||||||||||
m_BlockMovement = cmpObstruction->GetBlockMovementFlag(true); | m_BlockMovement = cmpObstruction->GetBlockMovementFlag(true); | ||||||||||
} | |||||||||||
} | |||||||||||
SetParticipateInPushing(!paramNode.GetChild("DisablePushing").IsOk() || !paramNode.GetChild("DisablePushing").ToBool()); | SetParticipateInPushing(!paramNode.GetChild("DisablePushing").IsOk() || !paramNode.GetChild("DisablePushing").ToBool()); | ||||||||||
m_DebugOverlayEnabled = false; | m_DebugOverlayEnabled = false; | ||||||||||
} | } | ||||||||||
void Deinit() override | void Deinit() override | ||||||||||
{ | { | ||||||||||
} | } | ||||||||||
template<typename S> | template<typename S> | ||||||||||
void SerializeCommon(S& serialize) | void SerializeCommon(S& serialize) | ||||||||||
{ | { | ||||||||||
// m_Clearance and m_PassClass are constructed from this. | |||||||||||
serialize.StringASCII("pass class", m_PassClassName, 0, 64); | serialize.StringASCII("pass class", m_PassClassName, 0, 64); | ||||||||||
serialize.NumberU32_Unbounded("ticket", m_ExpectedPathTicket.m_Ticket); | serialize.NumberU32_Unbounded("ticket", m_ExpectedPathTicket.m_Ticket); | ||||||||||
Serializer(serialize, "ticket type", m_ExpectedPathTicket.m_Type, Ticket::Type::LONG_PATH); | Serializer(serialize, "ticket type", m_ExpectedPathTicket.m_Type, Ticket::Type::LONG_PATH); | ||||||||||
serialize.NumberU8_Unbounded("failed movements", m_FailedMovements); | serialize.NumberU8_Unbounded("failed movements", m_FailedMovements); | ||||||||||
serialize.NumberU8_Unbounded("followknownimperfectpath", m_FollowKnownImperfectPathCountdown); | serialize.NumberU8_Unbounded("followknownimperfectpath", m_FollowKnownImperfectPathCountdown); | ||||||||||
Show All 27 Lines | void Serialize(ISerializer& serialize) override | ||||||||||
SerializeCommon(serialize); | SerializeCommon(serialize); | ||||||||||
} | } | ||||||||||
void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) override | void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) override | ||||||||||
{ | { | ||||||||||
Init(paramNode); | Init(paramNode); | ||||||||||
SerializeCommon(deserialize); | SerializeCommon(deserialize); | ||||||||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity()); | SetPassabilityData(m_PassClassName); | ||||||||||
Freagarach: Update clearance here as well? | |||||||||||
Done Inline ActionsUn-needed because clearance is serialised. wraitii: Un-needed because clearance is serialised. | |||||||||||
Not Done Inline ActionsNot in this file? Freagarach: Not in this file? | |||||||||||
Done Inline ActionsI might be wrong, but I believe the clearance is set by the obstruction manager on deserialization. You've made me doubt, so I'll check. wraitii: I might be wrong, but I believe the clearance is set by the obstruction manager on… | |||||||||||
Done Inline ActionsErr as a matter of fact the passability class name is also not serialised, and now I'm confused again why this doesn't OOS in rejoin test... Maybe I just failed to trigger it. wraitii: Err as a matter of fact the passability class name is also not serialised, and now I'm confused… | |||||||||||
if (cmpPathfinder) | |||||||||||
m_PassClass = cmpPathfinder->GetPassabilityClass(m_PassClassName); | |||||||||||
CmpPtr<ICmpObstruction> cmpObstruction(GetEntityHandle()); | CmpPtr<ICmpObstruction> cmpObstruction(GetEntityHandle()); | ||||||||||
if (cmpObstruction) | if (cmpObstruction) | ||||||||||
m_BlockMovement = cmpObstruction->GetBlockMovementFlag(false); | m_BlockMovement = cmpObstruction->GetBlockMovementFlag(false); | ||||||||||
} | } | ||||||||||
void HandleMessage(const CMessage& msg, bool UNUSED(global)) override | void HandleMessage(const CMessage& msg, bool UNUSED(global)) override | ||||||||||
{ | { | ||||||||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | public: | ||||||||||
} | } | ||||||||||
std::string GetPassabilityClassName() const override | std::string GetPassabilityClassName() const override | ||||||||||
{ | { | ||||||||||
return m_PassClassName; | return m_PassClassName; | ||||||||||
} | } | ||||||||||
void SetPassabilityClassName(const std::string& passClassName) override | void SetPassabilityClassName(const std::string& passClassName) override | ||||||||||
{ | { | ||||||||||
m_PassClassName = passClassName; | if (!m_FormationController) | ||||||||||
FreagarachUnsubmitted Not Done Inline Actions
Freagarach: | |||||||||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity()); | { | ||||||||||
if (cmpPathfinder) | LOGWARNING("Only formation controllers can change their passability class"); | ||||||||||
m_PassClass = cmpPathfinder->GetPassabilityClass(passClassName); | return; | ||||||||||
} | |||||||||||
SetPassabilityData(passClassName); | |||||||||||
} | } | ||||||||||
Not Done Inline ActionsWould it be possible to deduplicate some of this with the stuff in init? Freagarach: Would it be possible to deduplicate some of this with the stuff in init? | |||||||||||
fixed GetCurrentSpeed() const override | fixed GetCurrentSpeed() const override | ||||||||||
{ | { | ||||||||||
return m_CurrentSpeed; | return m_CurrentSpeed; | ||||||||||
} | } | ||||||||||
void SetFacePointAfterMove(bool facePointAfterMove) override | void SetFacePointAfterMove(bool facePointAfterMove) override | ||||||||||
{ | { | ||||||||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | private: | ||||||||||
} | } | ||||||||||
void SetParticipateInPushing(bool pushing) | void SetParticipateInPushing(bool pushing) | ||||||||||
{ | { | ||||||||||
CmpPtr<ICmpUnitMotionManager> cmpUnitMotionManager(GetSystemEntity()); | CmpPtr<ICmpUnitMotionManager> cmpUnitMotionManager(GetSystemEntity()); | ||||||||||
m_Pushing = pushing && cmpUnitMotionManager->IsPushingActivated(); | m_Pushing = pushing && cmpUnitMotionManager->IsPushingActivated(); | ||||||||||
} | } | ||||||||||
void SetPassabilityData(const std::string& passClassName) | |||||||||||
{ | |||||||||||
m_PassClassName = passClassName; | |||||||||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity()); | |||||||||||
if (cmpPathfinder) | |||||||||||
{ | |||||||||||
m_PassClass = cmpPathfinder->GetPassabilityClass(passClassName); | |||||||||||
m_Clearance = cmpPathfinder->GetClearance(m_PassClass); | |||||||||||
CmpPtr<ICmpObstruction> cmpObstruction(GetEntityHandle()); | |||||||||||
if (cmpObstruction) | |||||||||||
cmpObstruction->SetUnitClearance(m_Clearance); | |||||||||||
} | |||||||||||
} | |||||||||||
/** | /** | ||||||||||
* Warns other components that our current movement will likely fail (e.g. we won't be able to reach our target) | * Warns other components that our current movement will likely fail (e.g. we won't be able to reach our target) | ||||||||||
* This should only be called before the actual movement in a given turn, or units might both move and try to do things | * This should only be called before the actual movement in a given turn, or units might both move and try to do things | ||||||||||
* on the same turn, leading to gliding units. | * on the same turn, leading to gliding units. | ||||||||||
*/ | */ | ||||||||||
void MoveFailed() | void MoveFailed() | ||||||||||
{ | { | ||||||||||
// Don't notify if we are a formation member in a moving formation - we can occasionally be stuck for a long time | // Don't notify if we are a formation member in a moving formation - we can occasionally be stuck for a long time | ||||||||||
▲ Show 20 Lines • Show All 1,263 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Update clearance here as well?