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
|
2014-02-25 14:35:27 +01:00
|
|
|
typedef void(*ObjectDisabledFunction)(IObjectData* object); // Callback method that recieves and object
|
|
|
|
typedef void(*ObjectEnabledFunction)(IObjectData* object); // Callback method that recieves and object
|
2014-02-21 15:42:09 +01:00
|
|
|
typedef void(*ObjectHpFunction)(IObjectData* object, float hp); // Callback method that sends obj HP
|
|
|
|
typedef void(*ObjectRespawnedFunction)(IObjectData* object, Oyster::Math::Float3 spawnPos ); // Callback method that sends spawnPos
|
2014-02-25 12:12:24 +01:00
|
|
|
typedef void(*ObjectDeadFunction)(IObjectData* victim, IObjectData* killer, float seconds); // Callback method that sends killer and death timer
|
2014-02-25 14:35:27 +01:00
|
|
|
typedef void(*PickupEventFunction)(IObjectData* player, int pickupEffectID ); // Callback method that sends killer and death timer
|
|
|
|
typedef void(*AnimationEventFunction)(IObjectData* player, int actionID ); // Callback method that sends killer and death timer
|
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-21 11:10:47 +01:00
|
|
|
virtual void SetLookDir(const Oyster::Math3D::Float3& lookDir) = 0;
|
2014-02-19 13:47:49 +01:00
|
|
|
|
|
|
|
/** Relative rotation around given axis
|
|
|
|
* @param leftRadians: The relative amount of radians to turn
|
|
|
|
**/
|
|
|
|
virtual void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) = 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;
|
2014-02-20 16:52:36 +01:00
|
|
|
|
|
|
|
virtual void Inactivate() = 0;
|
|
|
|
virtual void Release() = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class ILevelData :public IObjectData
|
|
|
|
{
|
|
|
|
public:
|
2014-02-25 11:46:05 +01:00
|
|
|
virtual void Update(float deltaTime) = 0;
|
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-25 11:46:05 +01:00
|
|
|
virtual void AddPlayerToGame(IPlayerData *player) = 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
|
|
|
|
*/
|
2014-02-18 21:24:21 +01:00
|
|
|
virtual ILevelData* CreateLevel( const wchar_t mapName[255] ) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*/
|
2014-02-25 14:35:27 +01:00
|
|
|
virtual void SetMoveSubscription(GameEvent::ObjectMovedFunction functionPointer) = 0;
|
|
|
|
virtual void SetDisableSubscription(GameEvent::ObjectDisabledFunction functionPointer) = 0;
|
|
|
|
virtual void SetEnableSubscription(GameEvent::ObjectEnabledFunction functionPointer) = 0;
|
2014-02-21 15:42:09 +01:00
|
|
|
virtual void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) = 0;
|
|
|
|
virtual void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) = 0;
|
|
|
|
virtual void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) = 0;
|
2014-02-25 14:35:27 +01:00
|
|
|
virtual void SetActionSubscription(GameEvent::AnimationEventFunction functionPointer) = 0;
|
|
|
|
virtual void SetPickupSubscription(GameEvent::PickupEventFunction functionPointer) = 0;
|
2014-01-20 15:47:52 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|