1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #include <nel/misc/vector.h>
32 #include <nel/misc/time_nl.h>
34 #include <nel/3d/animation_time.h>
35 #include <nel/3d/u_instance.h>
36 #include <nel/3d/u_skeleton.h>
39 #include "animation.h"
42 // External definitions
57 class UVisualCollisionEntity
;
67 // An entity that will move through the landscape.
68 // The possible entities are the Self (the player's avatar), the Other and the Snowball
73 // Create a default entity
75 Id(0xffffffff), Name("<Unknown>"), Angle(0.0f
), AuxiliaryAngle(0.0f
), InterpolatedAuxiliaryAngle(0.0f
),
76 AutoMove(false), Instance(NULL
), Skeleton(NULL
),
77 Particule(NULL
), Source(NULL
), IsWalking(false), WasWalking(false), IsAiming(false), WasAiming(false),
78 /*CurrentAnim(NoAnim), */NextEmptySlot(0), PlayList(NULL
), BotState(0)
82 // The id of the entity
85 // The name of the entity
88 // Contain the target position for this entity
89 NLMISC::CVector ServerPosition
;
91 // Contain the current position of the entity
92 NLMISC::CVector Position
;
94 // The immediate speed of the entity
95 NLMISC::CVector ImmediateSpeed
;
97 // The maximum speed of the entity
99 // The angle of the entity
101 // Various angle controls for the interpolation
102 AuxiliaryAngle
, InterpolatedAuxiliaryAngle
;
104 // The trajectory (only for snowballs, defined in physics.h)
105 CTrajectory Trajectory
;
108 // The state enum of the entity
109 enum TState
{ Appear
, Normal
, Disappear
};
111 // The state of this entity
113 // The date of the beginning of this state
114 NLMISC::TLocalTime StateStartTime
;
116 // The type enum of the entity
117 enum TType
{ Self
, Other
, Snowball
};
119 // The type of this entity
122 // Is it an auto-moving entity
125 // The PACS move primitive
126 NLPACS::UMovePrimitive
*MovePrimitive
;
127 // The collision entity (for ground snapping)
128 NL3D::UVisualCollisionEntity
*VisualCollisionEntity
;
129 // The mesh instance associated to this entity
130 NL3D::UInstance Instance
;
131 // The skeleton binded to the instance
132 NL3D::USkeleton Skeleton
;
133 // The particle system (for appear and disappear effects)
134 NL3D::UInstance Particule
;
136 // The sound source associated to the entity
137 NLSOUND::USource
*Source
;
139 void setState (TState state
);
146 // Playlist linked to this entity
147 // EAnim CurrentAnim;
149 NL3D::UPlayList
*PlayList
;
150 std::queue
<EAnim
> AnimQueue
;
151 NL3D::CAnimationTime StartAnimationTime
;
154 NLMISC::TLocalTime BotStateStart
;
161 // The collision bits used by pacs (dynamic collisions)
164 SelfCollisionBit
= 1,
165 OtherCollisionBit
= 2,
166 SnowballCollisionBit
= 4,
167 StaticCollisionBit
= 8
171 // External variables
174 // The entity representing the player avatar
175 extern CEntity
*Self
;
177 // The speed of the player
178 extern float PlayerSpeed
;
179 // The speed of the snowball
180 extern float SnowballSpeed
;
182 // The entities storage
183 extern std::map
<uint32
, CEntity
> Entities
;
184 typedef std::map
<uint32
, CEntity
>::iterator EIT
;
186 extern uint32 NextEID
;
189 // External functions
192 EIT
findEntity (uint32 eid
, bool needAssert
= true);
194 void addEntity (uint32 eid
, std::string name
, CEntity::TType type
, const NLMISC::CVector
&startPosition
, const NLMISC::CVector
&serverPosition
);
195 void removeEntity (uint32 eid
);
197 // when we turn online, we need to clear all offline entities
198 void removeAllEntitiesExceptUs ();
199 void deleteAllEntities();
202 void updateEntities();
203 void releaseEntities();
205 // Reset the pacs position of an entity (in case pacs went wrong)
206 void resetEntityPosition(uint32 eid
);
207 // Process the event when an entity shoots a snowball
208 void shotSnowball(uint32 sid
, uint32 eid
, const NLMISC::CVector
&start
, const NLMISC::CVector
&target
, float speed
, float deflagRadius
);
210 void renderEntitiesNames ();
212 } /* namespace SBCLIENT */
216 /* End of entities.h */