SBSPSS/source/thing/thing.h

269 lines
7.0 KiB
C
Raw Normal View History

2001-02-26 21:27:20 +01:00
/*=========================================================================
thing.h
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __THING_THING_H__
#define __THING_THING_H__
/*----------------------------------------------------------------------
Includes
-------- */
#ifndef _GLOBAL_HEADER_
#include "system\global.h"
#endif
#ifndef __GAME_EVENT_H__
#include "game\event.h"
#endif
2001-05-10 18:16:57 +02:00
#include <dstructs.h>
2001-02-26 21:27:20 +01:00
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
2001-04-06 23:25:18 +02:00
// Collision rectangle definition
2001-05-10 18:16:57 +02:00
struct CRECT
2001-04-06 23:25:18 +02:00
{
int x1,y1,x2,y2;
2001-05-10 18:16:57 +02:00
};
2001-04-06 23:25:18 +02:00
2001-05-10 18:16:57 +02:00
/*----------------------------------------------------------------------*/
2001-02-26 21:27:20 +01:00
// Thing manager class
2001-05-10 18:16:57 +02:00
class CThing;
class CThingManager
2001-02-26 21:27:20 +01:00
{
public:
static void init();
static void shutdown();
2001-05-04 21:34:09 +02:00
static void killAllThingsForRespawn();
2001-02-26 21:27:20 +01:00
2001-05-11 01:51:14 +02:00
static void initAllThings();
2001-02-26 21:27:20 +01:00
static void thinkAllThings(int _frames);
static void renderAllThings();
2001-05-10 18:16:57 +02:00
static void processEventAllThings(GAME_EVENT _event,CThing *_sourceThing);
2001-02-26 21:27:20 +01:00
2001-04-06 23:25:18 +02:00
static CThing* checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue);
2001-05-10 18:16:57 +02:00
static void initCollision();
static sBBox &getRenderBBox() {return(m_RenderBBox);}
static sBBox &getThinkBBox() {return(m_ThinkBBox);}
2001-04-06 23:25:18 +02:00
2001-02-26 21:27:20 +01:00
protected:
2001-05-10 18:16:57 +02:00
static void initList(CThing **List);
static void addToThingList(CThing *_this);
static void removeFromThingList(CThing *_this);
static void addToCollisionList(CThing *_this);
friend class CThing;
2001-02-26 21:27:20 +01:00
private:
2001-05-10 18:16:57 +02:00
static CThing *s_thingLists[];
static int s_initialised;
2001-02-26 21:27:20 +01:00
2001-05-10 18:16:57 +02:00
static CThing *s_CollisionLists[];
static sBBox m_RenderBBox;
static sBBox m_ThinkBBox;
2001-02-26 21:27:20 +01:00
};
2001-05-10 18:16:57 +02:00
/*----------------------------------------------------------------------*/
2001-02-26 21:27:20 +01:00
// Base thing class
class CThing
{
public:
2001-05-10 18:16:57 +02:00
enum TYPE
2001-02-26 21:27:20 +01:00
{
TYPE_PICKUP,
2001-03-08 21:12:47 +01:00
TYPE_PLATFORM,
2001-02-26 21:27:20 +01:00
TYPE_PLAYER,
2001-02-27 17:59:50 +01:00
TYPE_PLAYERPROJECTILE,
TYPE_NPC,
2001-02-26 21:27:20 +01:00
TYPE_ENEMY,
2001-02-27 17:59:50 +01:00
TYPE_ENEMYPROJECTILE,
TYPE_TRIGGER,
2001-04-24 17:01:42 +02:00
TYPE_HAZARD,
2001-05-04 20:47:12 +02:00
TYPE_FX,
2001-02-26 21:27:20 +01:00
MAX_TYPE,
2001-05-10 18:16:57 +02:00
};
// TYPE;
CThing() {;}
virtual ~CThing() {;}
2001-02-26 21:27:20 +01:00
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType()=0;
2001-02-26 21:27:20 +01:00
2001-05-10 18:16:57 +02:00
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual u8 isSetToShutdown() {return( false );}
2001-02-26 21:27:20 +01:00
// Linkage
2001-05-10 18:16:57 +02:00
void addChild(CThing *Child);
void removeChild(CThing *Child);
void removeAllChild();
void deleteAllChild();
bool hasChild(CThing *Child);
int getNumChildren();
2001-02-26 21:27:20 +01:00
2001-05-10 18:16:57 +02:00
DVECTOR const &getPos() {return Pos;}
void setPos(DVECTOR newPos) {Pos=newPos;}
DVECTOR getPosDelta() {return PosDelta;}
CThing *getNext() {return Next;}
2001-02-26 21:27:20 +01:00
2001-05-10 18:16:57 +02:00
virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing);
2001-02-26 21:27:20 +01:00
protected:
2001-05-10 18:16:57 +02:00
// Parent Child Linkage
CThing *Parent,*Next;
2001-04-19 01:12:24 +02:00
// Count
2001-05-10 18:16:57 +02:00
int m_numChildren;
2001-02-26 21:27:20 +01:00
// Pos
2001-05-10 18:16:57 +02:00
DVECTOR Pos, PosLast, PosDelta;
2001-02-26 21:27:20 +01:00
public:
2001-05-10 18:16:57 +02:00
CThing *m_nextListThing;
CThing *m_nextCollisionThing;
2001-02-26 21:27:20 +01:00
// -- Collision --
public:
2001-05-14 18:33:39 +02:00
virtual CRECT const *getRenderBBox() {return &m_collisionArea;}
virtual CRECT const *getThinkBBox() {return &m_collisionArea;}
2001-05-15 00:12:09 +02:00
virtual bool alwaysThink() {return(false);}
2001-05-14 18:33:39 +02:00
2001-05-10 18:16:57 +02:00
void ShowBBox();
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
int getCollisionRadius() {return m_collisionRadius;}
2001-05-11 02:54:52 +02:00
virtual CRECT const &getCollisionArea() {return m_collisionArea;}
2001-05-10 18:16:57 +02:00
s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform?
DVECTOR const &getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed?
DVECTOR const &getCollisionSize() {return m_collisionSize;}
virtual int canCollide() {return true;}
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
int checkCollisionAgainstArea(CRECT *_rect);
void updateCollisionArea();
virtual void collidedWith(CThing *_thisThing) {;}
virtual void setHasPlatformCollided( bool newVal ) {;}
virtual bool getHasPlatformCollided() {return false;}
virtual s32 getNewYPos( CThing *_thisThing );
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
2001-05-10 23:09:23 +02:00
void setRenderFlag(bool f) {m_renderFlag=f;}
void setThinkFlag(bool f) {m_thinkFlag=f;}
2001-05-10 18:16:57 +02:00
bool canRender() {return (m_renderFlag);}
DVECTOR &getRenderPos() {return(m_RenderPos);}
bool canThink() {return (m_thinkFlag);}
2001-04-06 23:25:18 +02:00
2001-02-26 21:27:20 +01:00
protected:
2001-05-10 18:16:57 +02:00
virtual void setCollisionSize(int _w,int _h);
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform?
2001-02-26 21:27:20 +01:00
private:
2001-05-10 18:16:57 +02:00
DVECTOR m_collisionSize;
DVECTOR m_collisionCentreOffset;
int m_collisionRadius;
CRECT m_collisionArea;
DVECTOR m_collisionCentre;
s16 m_collisionAngle; // pkg - move to CNpcPlatform?
DVECTOR m_newCollidedPos; // pkg - to be removed?
bool m_renderFlag,m_thinkFlag;
DVECTOR m_RenderPos;
2001-02-26 21:27:20 +01:00
};
2001-05-10 18:16:57 +02:00
/*---------------------------------------------------------------------- */
2001-02-27 17:59:50 +01:00
/* These are the individual base classes for each of the seperate thing types */
class CPickupThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_PICKUP;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CPlayerThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_PLAYER;}
2001-05-15 00:12:09 +02:00
virtual bool alwaysThink() {return(true);}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CPlayerProjectileThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_PLAYERPROJECTILE;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CNpcThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_NPC;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CEnemyThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_ENEMY;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CEnemyProjectileThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_ENEMYPROJECTILE;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CPlatformThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_PLATFORM;}
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-02-27 17:59:50 +01:00
class CTriggerThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_TRIGGER;}
virtual void setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
virtual void setTargetBox(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
2001-05-04 03:35:52 +02:00
protected:
2001-05-10 18:16:57 +02:00
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
2001-02-27 17:59:50 +01:00
};
2001-05-10 18:16:57 +02:00
2001-04-24 17:01:42 +02:00
class CHazardThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_HAZARD;}
2001-04-24 17:01:42 +02:00
};
2001-05-10 18:16:57 +02:00
2001-05-04 20:47:12 +02:00
class CFXThing : public CThing
{
public:
2001-05-10 18:16:57 +02:00
virtual TYPE getThingType() {return TYPE_FX;}
2001-05-04 20:47:12 +02:00
};
2001-02-27 17:59:50 +01:00
2001-02-26 21:27:20 +01:00
#endif /* __THING_THING_H__ */
/*===========================================================================
end */