1 // SONIC ROBO BLAST 2
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 2004      by Stephen McGranahan
4 // Copyright (C) 2015-2020 by Sonic Team Junior.
5 //
6 // This program is free software distributed under the
7 // terms of the GNU General Public License, version 2.
8 // See the 'LICENSE' file for more details.
9 //-----------------------------------------------------------------------------
10 /// \file  p_slopes.c
11 /// \brief ZDoom + Eternity Engine Slopes, ported and enhanced by Kalaron
12 
13 #ifndef P_SLOPES_H__
14 #define P_SLOPES_H__
15 
16 #include "m_fixed.h" // Vectors
17 
18 extern pslope_t *slopelist;
19 extern UINT16 slopecount;
20 
21 typedef enum
22 {
23 	TMSP_FRONTFLOOR,
24 	TMSP_FRONTCEILING,
25 	TMSP_BACKFLOOR,
26 	TMSP_BACKCEILING,
27 } textmapslopeplane_t;
28 
29 typedef enum
30 {
31 	TMSC_FRONTTOBACKFLOOR   = 1,
32 	TMSC_BACKTOFRONTFLOOR   = 1<<1,
33 	TMSC_FRONTTOBACKCEILING = 1<<2,
34 	TMSC_BACKTOFRONTCEILING = 1<<3,
35 } textmapslopecopy_t;
36 
37 typedef enum
38 {
39 	TMS_NONE,
40 	TMS_FRONT,
41 	TMS_BACK,
42 } textmapside_t;
43 
44 typedef enum
45 {
46 	TMSL_NOPHYSICS = 1,
47 	TMSL_DYNAMIC = 2,
48 } textmapslopeflags_t;
49 
50 void P_LinkSlopeThinkers (void);
51 
52 void P_CalculateSlopeNormal(pslope_t *slope);
53 void P_SpawnSlopes(const boolean fromsave);
54 
55 //
56 // P_CopySectorSlope
57 //
58 // Searches through tagged sectors and copies
59 //
60 void P_CopySectorSlope(line_t *line);
61 
62 pslope_t *P_SlopeById(UINT16 id);
63 
64 // Returns the height of the sloped plane at (x, y) as a fixed_t
65 fixed_t P_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y);
66 
67 // Like P_GetSlopeZAt but falls back to z if slope is NULL
68 fixed_t P_GetZAt(const pslope_t *slope, fixed_t x, fixed_t y, fixed_t z);
69 
70 // Returns the height of the sector at (x, y)
71 fixed_t P_GetSectorFloorZAt  (const sector_t *sector, fixed_t x, fixed_t y);
72 fixed_t P_GetSectorCeilingZAt(const sector_t *sector, fixed_t x, fixed_t y);
73 
74 // Returns the height of the FOF at (x, y)
75 fixed_t P_GetFFloorTopZAt   (const ffloor_t *ffloor, fixed_t x, fixed_t y);
76 fixed_t P_GetFFloorBottomZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y);
77 
78 // Returns the height of the light list at (x, y)
79 fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y);
80 
81 // Lots of physics-based bullshit
82 void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
83 void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
84 void P_SlopeLaunch(mobj_t *mo);
85 fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope);
86 void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
87 void P_ButteredSlope(mobj_t *mo);
88 
89 
90 /// Dynamic plane type enum for the thinker. Will have a different functionality depending on this.
91 typedef enum {
92 	DP_FRONTFLOOR,
93 	DP_FRONTCEIL,
94 	DP_BACKFLOOR,
95 	DP_BACKCEIL,
96 	DP_VERTEX
97 } dynplanetype_t;
98 
99 /// Permit slopes to be dynamically altered through a thinker.
100 typedef struct
101 {
102 	thinker_t thinker;
103 
104 	pslope_t* slope;
105 	dynplanetype_t type;
106 
107 	// Used by line slopes.
108 	line_t* sourceline;
109 	fixed_t extent;
110 
111 	// Used by mapthing vertex slopes.
112 	INT16 tags[3];
113 	vector3_t vex[3];
114 } dynplanethink_t;
115 
116 void T_DynamicSlopeLine (dynplanethink_t* th);
117 void T_DynamicSlopeVert (dynplanethink_t* th);
118 #endif // #ifndef P_SLOPES_H__
119