18 #include "precompiled.h"
74 "<element name='DelayTime' a:help='Time to wait before starting to sink, in seconds'>"
75 "<ref name='nonNegativeDecimal'/>"
77 "<element name='SinkRate' a:help='Initial rate of sinking, in metres per second'>"
78 "<ref name='nonNegativeDecimal'/>"
80 "<element name='SinkAccel' a:help='Acceleration rate of sinking, in metres per second per second'>"
81 "<ref name='nonNegativeDecimal'/>"
84 "<element name='Inactive' a:help='If this element is present, the entity will not do any decaying'>"
89 "<element name='SinkingAnim' a:help='If this element is present, the entity will decay in a ship-like manner'>"
109 debug_warn(L
"CCmpDecay must not be used on non-local (network-synchronised) entities");
140 if (!cmpPosition || !cmpPosition->
IsInWorld())
196 float tilt_time = t > 5.f ? 5.f : t;
197 float tiltSink = tilt_time * tilt_time / 5.f;
202 depth =
m_SinkRate * (exp(t - 1.f) - 0.54881163609f) + (
m_SinkAccel * exp(t - 4.f) - 0.01831563888f);
An entity initialisation parameter node.
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
A simple fixed-point number class.
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)=0
entity_pos_t m_InitialZRotation
#define REGISTER_COMPONENT_TYPE(cname)
virtual void Init(const CParamNode ¶mNode)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
#define ENTITY_IS_LOCAL(id)
bool IsOk() const
Returns true if this is a valid CParamNode, false if it represents a non-existent node...
Serialization interface; see serialization overview.
virtual CFixedVector3D GetRotation()=0
Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch...
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)
virtual bool IsInWorld()=0
Returns true if the entity currently exists at a defined position in the world.
float deltaSimTime
Elapsed simulation time since previous interpolate, in seconds.
static void ClassInit(CComponentManager &componentManager)
CEntityHandle GetEntityHandle() const
fixed ToFixed() const
Parses the content of this node as a fixed-point number.
entity_id_t GetEntityId() const
virtual int GetType() const =0
const CParamNode & GetChild(const char *name) const
Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none...
float ToFloat() const
Convert to float. May be lossy - float can't represent all values.
virtual void HandleMessage(const CMessage &msg, bool global)
entity_pos_t m_InitialXRotation
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
const CSimContext & GetSimContext() const
A simplified syntax for accessing entity components.
CEntityHandle GetSystemEntity() const
virtual CFixedVector3D GetPosition()=0
Returns the current x,y,z position (no interpolation).
virtual CBoundingBoxAligned GetBounds()=0
Get the world-space bounding box of the object's visual representation.
static std::string GetSchema()
static CFixed FromFloat(float n)
#define debug_warn(expr)
display the error dialog with the given text.
void DestroyComponentsSoon(entity_id_t ent)
Destroys all the components belonging to the specified entity when FlushDestroyedComponents is called...
int ToInt_RoundToNearest() const
Prepare for rendering a new frame (set up model positions etc).
Fairly basic decay implementation, for units and buildings etc.
virtual void SetHeightOffset(entity_pos_t dy)=0
Set the vertical offset above the terrain/water surface.
CComponentManager & GetComponentManager() const
Deserialization interface; see serialization overview.
virtual void SetXZRotation(entity_angle_t x, entity_angle_t z)=0
Rotate immediately to the given angles around the X (pitch) and Z (roll) axes.
virtual void Serialize(ISerializer &serialize)