Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / door_manager.h
blobe6878e35e007a1ab73c3f51bf03baac3995fa4b4
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 CL_DOOR_MANAGER_H
20 #define CL_DOOR_MANAGER_H
22 #include "ig_enum.h"
24 // ///////////// //
25 // Doors Manager //
26 // ///////////// //
27 class CEntityCL;
29 class CDoorManager : public NL3D::ITransformName
31 static uint32 s_nextId;
33 struct SDoor
35 uint32 ID;
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
49 Zorai2Part
51 TAnimType AnimType;
54 SDoor()
56 ID = ++s_nextId;
57 InstanceGroup = NULL;
58 Opened = false;
59 OCState = 0;
60 AnimType = Normal;
63 void entityCollide(CEntityCL *pE);
65 void checkToClose();
67 // Animate the door's instances from current state to open state
68 // Return true if the anim is finished
69 bool open();
71 // Animate the door's instances from current state to open state
72 // Return true if the anim is finished
73 bool close();
75 // Called by open/close
76 void anim();
79 public:
81 /// Singleton method : Get the unique interface loader instance
82 static CDoorManager* getInstance()
84 if (_Instance == NULL)
85 _Instance = new CDoorManager();
86 return _Instance;
89 // release memory
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
104 void update ();
106 private:
108 virtual std::string transformName (uint index, const std::string &instanceName, const std::string &shapeName);
110 private:
112 static CDoorManager *_Instance;
114 std::vector<SDoor*> _Doors;
116 // shortcut to access the manager
117 inline CDoorManager &getDoorManager() { return *CDoorManager::getInstance(); }
119 // ///////// //
120 // Callbacks //
121 // ///////// //
123 class CIGDoorAddedCallback : public IIGObserver
125 private:
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