New lua versions
[ryzomcore.git] / ryzom / server / src / server_share / entity_state.h
blobd681e51ce3f18ef1433c996728f194ab87cf5efb
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef RY_ENTITY_STATE_H
20 #define RY_ENTITY_STATE_H
22 #include "nel/misc/vector_2d.h"
23 #include "nel/misc/vector.h"
25 #include "game_share/far_position.h"
26 #include "game_share/mirror_prop_value.h"
29 /**
30 * CEntityState
31 * \author Stephane Coutelas
32 * \author Nevrax France
33 * \date 2002
35 class CEntityState
37 public:
38 // Start by declaring methods for persistent load/ save operations
39 // The following macro is defined in persistent_data.h
40 // At time of writing it evaluated to:
41 // void store(CPersistentDataRecord &pdr) const;
42 // void apply(CPersistentDataRecord &pdr);
44 DECLARE_PERSISTENCE_METHODS
46 CMirrorPropValueAlice< sint32, CPropLocationPacked<2> > X;
47 CMirrorPropValueAlice< sint32, CPropLocationPacked<2> > Y;
48 CMirrorPropValueAlice< sint32, CPropLocationPacked<2> > Z;
50 CMirrorPropValueAlice< float, CPropLocationPacked<2> > Heading;
52 CEntityState()
54 clear();
57 void clear()
59 X=0;
60 Y=0;
61 Z=0;
62 Heading=0;
65 const CEntityState &operator = (const COfflineEntityState &s)
67 X = s.X;
68 Y = s.Y;
69 Z = s.Z;
70 Heading = s.Heading;
71 return *this;
74 /**
75 * operator=
77 void setCOfflineEntityState( COfflineEntityState &s ) const
79 s.X = X;
80 s.Y = Y;
81 s.Z = Z;
82 s.Heading = Heading;
86 /**
87 * Store temporaryly the state from an COfflineEntityState object (for later mirrorizing)
89 void storeToTemp( const COfflineEntityState& state )
91 X= state.X;
92 Y= state.Y;
93 Z= state.Z;
94 Heading= state.Heading;
97 /**
98 * Serial (read to temp storage, or write from mirror)
100 void serial(NLMISC::IStream &f)
102 X.serialRTWM( f );
103 Y.serialRTWM( f );
104 Z.serialRTWM( f );
105 Heading.serialRTWM( f );
109 * Fill vector in meter corresponding to state
111 void getVector( NLMISC::CVector& v ) const
113 v.x = X * 0.001f;
114 v.y = Y * 0.001f;
115 v.z = Z * 0.001f;
119 * Fill a CVectorfD in meter corresponding to state
121 void getVector2f( NLMISC::CVector2f& v ) const
123 v.x = X * 0.001f;
124 v.y = Y * 0.001f;
129 inline COfflineEntityState::COfflineEntityState(const CEntityState& state)
131 X = state.X;
132 Y = state.Y;
133 Z = state.Z;
134 Heading = state.Heading;
138 #endif // RY_ENTITY_STATE_H
139 /* entity_state.h */