2016-03-01 15:47:10 +00:00
|
|
|
#ifndef __PO_MAN_H
|
|
|
|
#define __PO_MAN_H
|
|
|
|
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "m_bbox.h"
|
2017-03-10 01:22:42 +00:00
|
|
|
#include "dthinker.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
struct FPolyObj;
|
|
|
|
|
2016-05-21 23:26:13 +00:00
|
|
|
class DPolyAction : public DThinker
|
|
|
|
{
|
|
|
|
DECLARE_CLASS(DPolyAction, DThinker)
|
|
|
|
HAS_OBJECT_POINTERS
|
|
|
|
public:
|
2019-01-24 00:05:07 +00:00
|
|
|
DPolyAction(FPolyObj *polyNum);
|
2016-09-19 17:14:30 +00:00
|
|
|
void Serialize(FSerializer &arc);
|
2017-01-12 21:49:18 +00:00
|
|
|
void OnDestroy() override;
|
2016-05-21 23:26:13 +00:00
|
|
|
void Stop();
|
|
|
|
double GetSpeed() const { return m_Speed; }
|
|
|
|
|
|
|
|
void StopInterpolation();
|
|
|
|
protected:
|
|
|
|
DPolyAction();
|
2019-01-24 00:05:07 +00:00
|
|
|
FPolyObj *m_PolyObj;
|
2016-05-21 23:26:13 +00:00
|
|
|
double m_Speed;
|
|
|
|
double m_Dist;
|
2017-03-08 12:34:26 +00:00
|
|
|
TObjPtr<DInterpolation*> m_Interpolation;
|
2016-05-21 23:26:13 +00:00
|
|
|
|
|
|
|
void SetInterpolation();
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
struct FPolyVertex
|
|
|
|
{
|
2016-03-30 22:41:21 +00:00
|
|
|
DVector2 pos;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
FPolyVertex &operator=(vertex_t *v)
|
|
|
|
{
|
2016-03-30 22:41:21 +00:00
|
|
|
pos = v->fPos();
|
2016-03-01 15:47:10 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FPolySeg
|
|
|
|
{
|
|
|
|
FPolyVertex v1;
|
|
|
|
FPolyVertex v2;
|
|
|
|
side_t *wall;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Linked lists of polyobjects
|
|
|
|
//
|
|
|
|
struct FPolyObj;
|
|
|
|
struct FPolyNode
|
|
|
|
{
|
|
|
|
FPolyObj *poly; // owning polyobject
|
|
|
|
FPolyNode *pnext; // next polyobj in list
|
|
|
|
FPolyNode *pprev; // previous polyobj
|
|
|
|
|
|
|
|
subsector_t *subsector; // containimg subsector
|
|
|
|
FPolyNode *snext; // next subsector
|
|
|
|
|
|
|
|
TArray<FPolySeg> segs; // segs for this node
|
|
|
|
int state;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ===== Polyobj data =====
|
|
|
|
struct FPolyObj
|
|
|
|
{
|
|
|
|
TArray<side_t *> Sidedefs;
|
|
|
|
TArray<line_t *> Linedefs;
|
|
|
|
TArray<vertex_t *> Vertices;
|
|
|
|
TArray<FPolyVertex> OriginalPts;
|
|
|
|
TArray<FPolyVertex> PrevPts;
|
|
|
|
FPolyVertex StartSpot;
|
|
|
|
FPolyVertex CenterSpot;
|
|
|
|
FBoundingBox Bounds; // Bounds in map coordinates
|
|
|
|
subsector_t *CenterSubsector;
|
|
|
|
int MirrorNum;
|
|
|
|
|
2016-03-30 22:41:21 +00:00
|
|
|
DAngle Angle;
|
2016-03-01 15:47:10 +00:00
|
|
|
int tag; // reference tag assigned in HereticEd
|
|
|
|
int bbox[4]; // bounds in blockmap coordinates
|
|
|
|
int validcount;
|
|
|
|
int crush; // should the polyobj attempt to crush mobjs?
|
|
|
|
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
|
2016-04-16 23:24:07 +00:00
|
|
|
bool bBlocked;
|
2017-03-08 14:20:00 +00:00
|
|
|
uint8_t bHasPortals; // 1 for any portal, 2 for a linked portal (2 must block rotations.)
|
2016-03-01 15:47:10 +00:00
|
|
|
int seqType;
|
2016-03-30 22:41:21 +00:00
|
|
|
double Size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
|
2016-03-01 15:47:10 +00:00
|
|
|
FPolyNode *subsectorlinks;
|
2017-03-08 12:34:26 +00:00
|
|
|
TObjPtr<DPolyAction*> specialdata; // pointer to a thinker, if the poly is moving
|
|
|
|
TObjPtr<DInterpolation*> interpolation;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
FPolyObj();
|
|
|
|
DInterpolation *SetInterpolation();
|
|
|
|
void StopInterpolation();
|
|
|
|
|
|
|
|
int GetMirror();
|
2016-03-30 22:41:21 +00:00
|
|
|
bool MovePolyobj (const DVector2 &pos, bool force = false);
|
|
|
|
bool RotatePolyobj (DAngle angle, bool fromsave = false);
|
|
|
|
void ClosestPoint(const DVector2 &fpos, DVector2 &out, side_t **side) const;
|
2016-03-01 15:47:10 +00:00
|
|
|
void LinkPolyobj ();
|
|
|
|
void RecalcActorFloorCeil(FBoundingBox bounds) const;
|
|
|
|
void CreateSubsectorLinks();
|
|
|
|
void ClearSubsectorLinks();
|
|
|
|
void CalcCenter();
|
2016-04-17 15:10:11 +00:00
|
|
|
void UpdateLinks();
|
2016-03-01 15:47:10 +00:00
|
|
|
static void ClearAllSubsectorLinks();
|
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
FLevelLocals *GetLevel() const;
|
|
|
|
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void ThrustMobj (AActor *actor, side_t *side);
|
|
|
|
void UpdateBBox ();
|
2016-03-30 22:41:21 +00:00
|
|
|
void DoMovePolyobj (const DVector2 &pos);
|
2016-03-01 15:47:10 +00:00
|
|
|
void UnLinkPolyobj ();
|
|
|
|
bool CheckMobjBlocking (side_t *sd);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct polyblock_t
|
|
|
|
{
|
|
|
|
FPolyObj *polyobj;
|
|
|
|
struct polyblock_t *prev;
|
|
|
|
struct polyblock_t *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
void PO_LinkToSubsectors(FLevelLocals *Level);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ===== PO_MAN =====
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PODOOR_NONE,
|
|
|
|
PODOOR_SLIDE,
|
|
|
|
PODOOR_SWING,
|
|
|
|
} podoortype_t;
|
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
bool EV_RotatePoly (FLevelLocals *Level, line_t *line, int polyNum, int speed, int byteAngle, int direction, bool overRide);
|
|
|
|
bool EV_MovePoly (FLevelLocals *Level, line_t *line, int polyNum, double speed, DAngle angle, double dist, bool overRide);
|
|
|
|
bool EV_MovePolyTo (FLevelLocals *Level, line_t *line, int polyNum, double speed, const DVector2 &pos, bool overRide);
|
|
|
|
bool EV_OpenPolyDoor (FLevelLocals *Level, line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type);
|
|
|
|
bool EV_StopPoly (FLevelLocals *Level, int polyNum);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
bool PO_Busy (FLevelLocals *Level, int polyobj);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
2019-01-24 00:05:07 +00:00
|
|
|
#endif
|