Cafu Engine
FuncDoor.hpp
1 /*
2 =================================================================================
3 This file is part of Cafu, the open-source game engine and graphics engine
4 for multiplayer, cross-platform, real-time 3D action.
5 Copyright (C) 2002-2013 Carsten Fuchs Software.
6 
7 Cafu is free software: you can redistribute it and/or modify it under the terms
8 of the GNU General Public License as published by the Free Software Foundation,
9 either version 3 of the License, or (at your option) any later version.
10 
11 Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17 
18 For support and more information about Cafu, visit us at <http://www.cafu.de>.
19 =================================================================================
20 */
21 
22 #ifndef CAFU_FUNC_DOOR_HPP_INCLUDED
23 #define CAFU_FUNC_DOOR_HPP_INCLUDED
24 
25 #include "BaseEntity.hpp"
26 
27 
28 struct luaL_Reg;
29 namespace cf { namespace SceneGraph { class GenericNodeT; } }
30 
31 
32 namespace GAME_NAME
33 {
34  class EntFuncDoorT : public BaseEntityT
35  {
36  public:
37 
38  EntFuncDoorT(const EntityCreateParamsT& Params);
39  ~EntFuncDoorT();
40 
41  void Think(float FrameTime, unsigned long ServerFrameNr);
42  void OnTrigger(BaseEntityT* Activator);
43 
44  void Draw(bool FirstPersonView, float LodDist) const;
45 
46 
47  const cf::TypeSys::TypeInfoT* GetType() const;
48  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
49  static const cf::TypeSys::TypeInfoT TypeInfo;
50 
51 
52  private:
53 
54  void DoDeserialize(cf::Network::InStreamT& Stream); // Override the BaseEntityT base class method.
55 
56  void UpdateMovePos(float MoveFraction_);
57 
58  enum DoorStateT { Closed, Opening, Open, Closing };
59 
60  const cf::ClipSys::CollisionModelT* InfraredCollMdl; ///< The collision model for the doors "infrared" trigger volume, covering both sides of the door (and the door itself).
61  cf::ClipSys::ClipModelT InfraredClipMdl; ///< The related clip model for the automatic "infrared" operation of the door.
62 
63  DoorStateT DoorState;
64  Vector3dT OpenPos; ///< The position of the door when open.
65  Vector3dT ClosedPos; ///< The position of the door when closed.
66  float MoveTime; ///< The time it takes the door to open or close.
67  float MoveFraction; ///< 0.0 at the closed door position, 1.0 at the open door position.
68  float OpenTime; ///< The time the door stays open before it automatically closes again.
69  float OpenTimeLeft; ///< The time that is left until we're closing again.
70 
71  EntFuncDoorT* TeamHead; ///< The head of a linked list of doors that are all in the same team.
72  EntFuncDoorT* TeamNext; ///< The next door in the linked list.
73 
74  const cf::SceneGraph::GenericNodeT* RootNode; ///< The root node of the scene graph of the model (brushwork) of this entity.
75 
76 
77  // Script methods (to be called from the map/entity Lua scripts).
78  static int SetOrigin(lua_State* LuaState); // Override for the base class method (we also have to update our ClipModel origin).
79 
80  static const luaL_Reg MethodsList[];
81  };
82 }
83 
84 #endif
A clip model represents an object in the world against which clipping queries can be performed...
Definition: ClipModel.hpp:46
This class is used for reading data from a StateT instance (deserialization).
Definition: State.hpp:222
Definition: EntityCreateParams.hpp:38
Definition: BaseEntity.hpp:85
This is the base class for collision models, making sure that they all share the same interface...
Definition: CollisionModel_base.hpp:45
Definition: FuncDoor.hpp:34
Definition: TypeSys.hpp:67
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:94
Definition: Node.hpp:50