1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: dsectoreffect.h 4469 2014-01-03 23:38:29Z dr_sean $
5 //
6 // Copyright (C) 1998-2006 by Randy Heit (ZDoom).
7 // Copyright (C) 2006-2014 by The Odamex Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // DESCRIPTION:
20 //	Separated Sector effects (?)
21 //
22 //-----------------------------------------------------------------------------
23 
24 
25 #ifndef __DSECTOREFFECT_H__
26 #define __DSECTOREFFECT_H__
27 
28 #include "dobject.h"
29 #include "dthinker.h"
30 #include "r_defs.h"
31 
32 typedef enum
33 {
34 	SEC_FLOOR,
35 	SEC_PLAT,
36 	SEC_CEILING,
37 	SEC_DOOR,
38 	SEC_ELEVATOR,
39 	SEC_PILLAR,
40 
41 	SEC_INVALID
42 } movertype_t;
43 
44 class DSectorEffect : public DThinker
45 {
46 	DECLARE_SERIAL (DSectorEffect, DThinker)
47 public:
48 	DSectorEffect (sector_t *sector);
49 	~DSectorEffect ();
50 	virtual void Destroy();
51 protected:
52 	DSectorEffect ();
53 	sector_t	*m_Sector;
54 };
55 
56 class DMover : public DSectorEffect
57 {
58 	DECLARE_SERIAL (DMover, DSectorEffect);
59 public:
60 	DMover (sector_t *sector);
61 protected:
62 	enum EResult { ok, crushed, pastdest };
63 private:
64 	EResult MovePlane (fixed_t speed, fixed_t dest, bool crush, int floorOrCeiling, int direction);
65 protected:
66 	DMover ();
MoveFloor(fixed_t speed,fixed_t dest,bool crush,int direction)67 	inline EResult MoveFloor (fixed_t speed, fixed_t dest, bool crush, int direction)
68 	{
69 		return MovePlane (speed, dest, crush, 0, direction);
70 	}
MoveFloor(fixed_t speed,fixed_t dest,int direction)71 	inline EResult MoveFloor (fixed_t speed, fixed_t dest, int direction)
72 	{
73 		return MovePlane (speed, dest, false, 0, direction);
74 	}
MoveCeiling(fixed_t speed,fixed_t dest,bool crush,int direction)75 	inline EResult MoveCeiling (fixed_t speed, fixed_t dest, bool crush, int direction)
76 	{
77 		return MovePlane (speed, dest, crush, 1, direction);
78 	}
MoveCeiling(fixed_t speed,fixed_t dest,int direction)79 	inline EResult MoveCeiling (fixed_t speed, fixed_t dest, int direction)
80 	{
81 		return MovePlane (speed, dest, false, 1, direction);
82 	}
83 };
84 
85 class DMovingFloor : public DMover
86 {
87 	DECLARE_SERIAL (DMovingFloor, DMover);
88 public:
89 	DMovingFloor (sector_t *sector);
90 protected:
91 	DMovingFloor ();
92 };
93 
94 class DMovingCeiling : public DMover
95 {
96 	DECLARE_SERIAL (DMovingCeiling, DMover);
97 public:
98 	DMovingCeiling (sector_t *sector);
99 protected:
100 	DMovingCeiling ();
101 };
102 
103 #endif //__DSECTOREFFECT_H__
104 
105