Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpDecay.cpp
/* Copyright (C) 2015 Wildfire Games. | /* Copyright (C) 2020 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 All 9 Lines | |||||
#include "simulation2/system/Component.h" | #include "simulation2/system/Component.h" | ||||
#include "ICmpDecay.h" | #include "ICmpDecay.h" | ||||
#include "simulation2/MessageTypes.h" | #include "simulation2/MessageTypes.h" | ||||
#include "ICmpPosition.h" | #include "ICmpPosition.h" | ||||
#include "ICmpTerrain.h" | #include "ICmpTerrain.h" | ||||
#include "ICmpUnitRenderer.h" | |||||
#include "ICmpVisual.h" | #include "ICmpVisual.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
/** | /** | ||||
* Fairly basic decay implementation, for units and buildings etc. | * Fairly basic decay implementation, for units and buildings etc. | ||||
* The decaying entity remains stationary for some time period, then falls downwards | * The decaying entity remains stationary for some time period, then falls downwards | ||||
* with some initial speed and some acceleration, until it has fully sunk. | * with some initial speed and some acceleration, until it has fully sunk. | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | virtual void Init(const CParamNode& paramNode) | ||||
// Detect unsafe misconfiguration | // Detect unsafe misconfiguration | ||||
if (m_Active && !ENTITY_IS_LOCAL(GetEntityId())) | if (m_Active && !ENTITY_IS_LOCAL(GetEntityId())) | ||||
{ | { | ||||
debug_warn(L"CCmpDecay must not be used on non-local (network-synchronised) entities"); | debug_warn(L"CCmpDecay must not be used on non-local (network-synchronised) entities"); | ||||
m_Active = false; | m_Active = false; | ||||
} | } | ||||
if (m_Active) | if (!m_Active) | ||||
return; | |||||
GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_Interpolate, this, true); | GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_Interpolate, this, true); | ||||
CmpPtr<ICmpUnitRenderer> cmpUnitRenderer(GetSystemEntity()); | |||||
if (cmpUnitRenderer) | |||||
cmpUnitRenderer->AddCorpse(GetEntityId()); | |||||
} | } | ||||
virtual void Deinit() | virtual void Deinit() | ||||
{ | { | ||||
if (!m_Active) | |||||
return; | |||||
CmpPtr<ICmpUnitRenderer> cmpUnitRenderer(GetSystemEntity()); | |||||
if (cmpUnitRenderer) | |||||
cmpUnitRenderer->RemoveCorpse(GetEntityId()); | |||||
} | } | ||||
virtual void Serialize(ISerializer& UNUSED(serialize)) | virtual void Serialize(ISerializer& UNUSED(serialize)) | ||||
{ | { | ||||
// This component isn't network-synchronised, so don't serialize anything | // This component isn't network-synchronised, so don't serialize anything | ||||
} | } | ||||
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& UNUSED(deserialize)) | virtual void Deserialize(const CParamNode& paramNode, IDeserializer& UNUSED(deserialize)) | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator