18 #include "precompiled.h"
57 return "<a:component type='system'/><empty/>";
166 if (!GetSimContext().HasUnitManager())
170 if (!cmpSourceVisual)
178 LOGERROR(L
"Unit with actor '%ls' launched a projectile but has no actor on 'projectile' attachpoint", cmpSourceVisual->
GetActorShortName().c_str());
183 projectile.
id = currentId;
184 projectile.
time = 0.f;
186 projectile.
gravity = gravity.ToFloat();
199 std::set<CStr> selections;
200 projectile.
unit = GetSimContext().GetUnitManager().CreateUnit(name, m_ActorSeed++, selections);
201 if (!projectile.
unit)
206 offset -= projectile.
pos;
207 float horizDistance = sqrtf(offset.
X*offset.
X + offset.
Z*offset.
Z);
208 projectile.
timeHit = horizDistance / speed.ToFloat();
209 projectile.
v = offset * (1.f / projectile.
timeHit);
213 m_Projectiles.push_back(projectile);
215 return projectile.
id;
220 projectile.
time += dt;
226 delta = projectile.
pos;
232 delta = projectile.
pos - delta;
242 if (projectile.
pos.
Y < h)
244 projectile.
pos.
Y = h;
261 float angle = acosf(up.
Dot(delta));
331 if (!losRevealAll && !los.IsVisible(posi, posj))
An entity initialisation parameter node.
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
void Translate(float x, float y, float z)
uint32_t LaunchProjectile(entity_id_t source, CFixedVector3D targetPoint, fixed speed, fixed gravity)
A simple fixed-point number class.
static void ClassInit(CComponentManager &componentManager)
#define REGISTER_COMPONENT_TYPE(cname)
virtual CVector3D GetProjectileLaunchPoint()=0
Return the exact position where a projectile should be launched from (based on the actor's ammo prop ...
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
virtual CLosQuerier GetLosQuerier(player_id_t player)=0
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other...
void AdvanceProjectile(Projectile &projectile, float dt)
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
void DeleteUnit(CUnit *unit)
virtual bool GetLosRevealAll(player_id_t player)=0
Returns whether the whole map has been made visible to the given player.
Serialization interface; see serialization overview.
virtual float GetExactGroundLevel(float x, float z)=0
Add renderable objects to the scene collector.
virtual uint32_t LaunchProjectileAtPoint(entity_id_t source, CFixedVector3D target, fixed speed, fixed gravity)
Launch a projectile from entity source to point target.
float Dot(const CVector3D &vector) const
static void swap(UniqueRange &p1, UniqueRange &p2)
virtual void SetTransform(const CMatrix3D &transform)
CVector3D Cross(const CVector3D &vector) const
bool IsBoxVisible(const CVector3D &position, const CBoundingBoxAligned &bounds) const
void Interpolate(float frameTime)
virtual void NumberU32_Unbounded(const char *name, uint32_t &out)
CModelAbstract & GetModel() const
virtual std::wstring GetProjectileActor()=0
Return the filename of the actor to be used for projectiles from this unit, or the empty string if no...
virtual void SubmitRecursive(CModelAbstract *model)
Submit a model that is part of the scene, including attached sub-models.
float deltaSimTime
Elapsed simulation time since previous interpolate, in seconds.
virtual void HandleMessage(const CMessage &msg, bool global)
This interface accepts renderable objects.
virtual int GetType() const =0
CMatrix3D ToMatrix() const
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
static const float PROJECTILE_DECAY_TIME
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
const CSimContext & GetSimContext() const
virtual void Serialize(ISerializer &serialize)
void NumberU32_Unbounded(const char *name, uint32_t value)
Serialize a number.
A simplified syntax for accessing entity components.
int GetCurrentDisplayedPlayer() const
Returns the player ID that the current display is being rendered for.
CEntityHandle GetSystemEntity() const
static std::string GetSchema()
virtual CFixedVector3D GetPosition()=0
Returns the current x,y,z position (no interpolation).
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
CUnitManager & GetUnitManager() const
SceneCollector & collector
std::vector< Projectile > m_Projectiles
Object providing efficient abstracted access to the LOS state.
CVector3D position(float t)
float LengthSquared() const
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)
void FromAxisAngle(const CVector3D &axis, float angle)
virtual void RemoveProjectile(uint32_t)
Removes a projectile, used when the projectile has hit a target.
Prepare for rendering a new frame (set up model positions etc).
virtual const CBoundingBoxAligned GetWorldBoundsRec()
Returns world space bounds of this object and all child objects.
virtual void Init(const CParamNode ¶mNode)
u32 entity_id_t
Entity ID type.
virtual std::wstring GetActorShortName()=0
Return the short name of the actor that's being displayed, or the empty string on error...
virtual void ValidatePosition()=0
Ensure that both the transformation and the bone matrices are correct for this model and all its prop...
Deserialization interface; see serialization overview.