2014-01-20 15:47:52 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Erik Persson] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef GAME_API_H
|
|
|
|
#define GAME_API_H
|
|
|
|
|
|
|
|
//Includes windows so we need to undef minmax
|
|
|
|
#define NOMINMAX
|
|
|
|
#include <vld.h>
|
|
|
|
|
|
|
|
#include "GameLogicDef.h"
|
|
|
|
#include "GameLogicStates.h"
|
|
|
|
#include <OysterMath.h>
|
2014-02-19 11:00:16 +01:00
|
|
|
#include "..\LevelLoader\ObjectDefines.h"
|
2014-02-18 11:33:36 +01:00
|
|
|
#include "DynamicArray.h"
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
{
|
|
|
|
class IObjectData;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collection of various event structures that may be used to get events grom the game.
|
|
|
|
*/
|
|
|
|
namespace GameEvent
|
|
|
|
{
|
2014-02-09 16:42:26 +01:00
|
|
|
typedef void(*ObjectMovedFunction)(IObjectData* object); // Callback method that recieves and object
|
|
|
|
typedef void(*ObjectDisabledFunction)(IObjectData* object, float seconds); // Callback method that recieves and object
|
2014-01-20 15:47:52 +01:00
|
|
|
//etc...
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object that collects the standard usage functions
|
|
|
|
*/
|
|
|
|
class IObjectData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/********************************************************
|
|
|
|
* Gets players position
|
2014-02-11 13:03:37 +01:00
|
|
|
* @return Returns the players position
|
2014-01-20 15:47:52 +01:00
|
|
|
********************************************************/
|
|
|
|
virtual Oyster::Math::Float3 GetPosition() = 0;
|
|
|
|
|
2014-02-11 13:03:37 +01:00
|
|
|
/********************************************************
|
|
|
|
* Gets players rotation as quaternion
|
|
|
|
* @return Returns a quaternion
|
|
|
|
********************************************************/
|
|
|
|
virtual Oyster::Math::Quaternion GetRotation() = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Gets players position
|
|
|
|
* @return Returns the player scale
|
|
|
|
********************************************************/
|
|
|
|
virtual Oyster::Math::Float3 GetScale() = 0;
|
|
|
|
|
2014-01-20 15:47:52 +01:00
|
|
|
/********************************************************
|
|
|
|
* Gets players current orientation
|
|
|
|
* @param playerID: ID of the player whos position you want
|
|
|
|
********************************************************/
|
|
|
|
virtual Oyster::Math::Float4x4 GetOrientation() = 0;
|
|
|
|
|
|
|
|
/** Get the uniuqe id for the object
|
|
|
|
* @return The id for the object.
|
|
|
|
*/
|
|
|
|
virtual int GetID() const = 0;
|
|
|
|
|
|
|
|
/** Get the type of the object
|
|
|
|
* @return The OBJECT_TYPE of the object is returned
|
|
|
|
*/
|
2014-02-12 14:48:58 +01:00
|
|
|
virtual ObjectSpecialType GetObjectType() const = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class IPlayerData :public IObjectData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/********************************************************
|
|
|
|
* Moves the chosen player based on input
|
|
|
|
* @param playerID: ID of the player you want to recieve the message
|
|
|
|
* @param movement: enum value on what kind of action is to be taken
|
|
|
|
********************************************************/
|
|
|
|
virtual void Move(const PLAYER_MOVEMENT &movement) = 0;
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
/** Relative rotation around given axis
|
|
|
|
* @param x: The relative x axis
|
|
|
|
* @param y: The relative y axis
|
|
|
|
**/
|
2014-02-12 13:11:35 +01:00
|
|
|
virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0;
|
2014-01-21 09:52:48 +01:00
|
|
|
|
2014-01-20 15:47:52 +01:00
|
|
|
/********************************************************
|
|
|
|
* Uses the chosen players weapon based on input
|
|
|
|
* @param Usage: enum value on what kind of action is to be taken
|
|
|
|
********************************************************/
|
2014-01-20 16:02:26 +01:00
|
|
|
virtual void UseWeapon(const WEAPON_FIRE &usage) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
/***/
|
|
|
|
virtual int GetTeamID() const = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Check player state
|
|
|
|
* @return The current player state
|
|
|
|
********************************************************/
|
|
|
|
virtual PLAYER_STATE GetState() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ILevelData :public IObjectData
|
|
|
|
{
|
|
|
|
public:
|
2014-02-05 11:46:04 +01:00
|
|
|
virtual int getNrOfDynamicObj()const = 0;
|
2014-01-30 09:40:58 +01:00
|
|
|
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
2014-02-18 11:44:02 +01:00
|
|
|
virtual void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& destMem) const = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class DANBIAS_GAMELOGIC_DLL GameAPI
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** A global function to get an instance of the API
|
|
|
|
* @return Returns the GameAPI instance
|
|
|
|
*/
|
|
|
|
static GameAPI& Instance( void );
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Initiates the Game instance.
|
|
|
|
* - This method must be called before the API can be used.
|
|
|
|
* @return If the return value is false, something went wrong.
|
|
|
|
*/
|
|
|
|
virtual bool Initiate( void ) = 0;
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Gets the position of all players currently in the game
|
|
|
|
********************************************************/
|
|
|
|
virtual void GetAllPlayerPositions( void ) const = 0;
|
|
|
|
|
|
|
|
/** Creates a player
|
|
|
|
* @return Returns a IPlayerData container to use for player manipulation.
|
|
|
|
*/
|
|
|
|
virtual IPlayerData* CreatePlayer( void ) = 0;
|
|
|
|
|
|
|
|
/** Creates a level
|
|
|
|
* @return Returns a ILevelData container to use for level manipulation
|
|
|
|
*/
|
|
|
|
virtual ILevelData* CreateLevel( void ) = 0;
|
|
|
|
|
|
|
|
/** Creates a team
|
|
|
|
* @return ?
|
|
|
|
*/
|
|
|
|
virtual void CreateTeam( void ) = 0;
|
|
|
|
|
|
|
|
/** Runs a update of the gamelogic and physics
|
|
|
|
* @return Returns true if a frame was proccessed
|
|
|
|
*/
|
|
|
|
virtual bool NewFrame( void ) = 0;
|
|
|
|
|
|
|
|
/** Set the frame time in fps
|
|
|
|
* @param FPS The fps to set
|
|
|
|
*/
|
2014-02-09 16:42:26 +01:00
|
|
|
virtual void SetFPS( int FPS = 120 ) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
/** Set the frames time in seconds
|
|
|
|
* @param seconds The frame length
|
|
|
|
*/
|
2014-02-09 16:42:26 +01:00
|
|
|
virtual void SetFrameTimeLength( float seconds = (1.0f/120.0f) ) = 0;
|
|
|
|
|
|
|
|
/** Set a specific object event subscription callback
|
|
|
|
* @param
|
|
|
|
*/
|
|
|
|
virtual void SetSubscription(GameEvent::ObjectMovedFunction functionPointer) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
/** Set a specific object event subscription callback
|
|
|
|
* @param
|
|
|
|
*/
|
2014-02-09 16:42:26 +01:00
|
|
|
virtual void SetSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|