1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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 CL_DOOR_MANAGER_H
20 #define CL_DOOR_MANAGER_H
29 class CDoorManager
: public NL3D::ITransformName
31 static uint32 s_nextId
;
36 std::string Name
; // Name of the door (type_id ie: ma_asc_3portes_02)
37 std::vector
<NLPACS::UMovePrimitive
*> Prims
;// All collisions prims for that door
38 NL3D::UInstanceGroup
*InstanceGroup
; // Instance Group where the door is.
39 std::vector
<uint32
> Instances
; // Shapes making the door
40 std::vector
<NLMISC::CMatrix
> InstMat
; // Matrix of the shapes making the door
41 bool Opened
; // Is the door is opened or closed ?
42 std::vector
<CEntityCL
*> Entities
; // Entities in the trigger zone
43 std::vector
<uint8
> EntitiesMoved
; // Entities in the trigger zone that moved
44 float OCState
; // 0 closed 1 opened
46 enum TAnimType
{ Normal
,
47 Matis3Part
, // For Instance Parts: 0==left 1==right 2==down
48 Matis3PartBourgeon
, // For Instance Parts: 0==left 1==right 2==down
63 void entityCollide(CEntityCL
*pE
);
67 // Animate the door's instances from current state to open state
68 // Return true if the anim is finished
71 // Animate the door's instances from current state to open state
72 // Return true if the anim is finished
75 // Called by open/close
81 /// Singleton method : Get the unique interface loader instance
82 static CDoorManager
* getInstance()
84 if (_Instance
== NULL
)
85 _Instance
= new CDoorManager();
90 static void releaseInstance();
92 void loadedCallback (NL3D::UInstanceGroup
*ig
);
94 // Check in the group if there are some doors
95 void addedCallback (NL3D::UInstanceGroup
*ig
);
97 // Remove all doors attached to this group
98 void removedCallback (NL3D::UInstanceGroup
*ig
);
100 // Copy triggers to be used in update
101 void getPACSTriggers();
103 // Check triggers in pacs to open/close the doors
108 virtual std::string
transformName (uint index
, const std::string
&instanceName
, const std::string
&shapeName
);
112 static CDoorManager
*_Instance
;
114 std::vector
<SDoor
*> _Doors
;
116 // shortcut to access the manager
117 inline CDoorManager
&getDoorManager() { return *CDoorManager::getInstance(); }
123 class CIGDoorAddedCallback
: public IIGObserver
126 // An IG has been added
127 virtual void instanceGroupLoaded(NL3D::UInstanceGroup
*ig
)
129 getDoorManager().loadedCallback (ig
);
131 // An IG has been added
132 virtual void instanceGroupAdded(NL3D::UInstanceGroup
*ig
)
134 getDoorManager().addedCallback (ig
);
136 // An IG will be removed
137 virtual void instanceGroupRemoved(NL3D::UInstanceGroup
*ig
)
139 getDoorManager().removedCallback (ig
);
143 extern CIGDoorAddedCallback IGDoorCallback
;
145 #endif // CL_DOOR_MANAGER_H