view LightClone/Source/Bot.h @ 25:eae13b04b06f

Working on Gui drag and drop
author koryspansel <koryspansel@bendbroadband.com>
date Fri, 16 Sep 2011 13:11:35 -0700
parents e494c4295dba
children 58a16d529d95
line wrap: on
line source

/*
 * Bot
 */

#ifndef __BOT_H__
#define __BOT_H__

#include "Core.h"
#include "RenderContext.h"
#include "ResourceManager.h"
#include "VirtualMachine.h"
#include "Environment.h"
#include "Code.h"
#include "Clock.h"

/*
 * BotState
 */
enum
{
	BotState_Idle,
	BotState_Evaluate,
	BotState_Animate,
	BotState_Pause,
};

/*
 * BotSequence
 */
enum
{
	BotSequence_Forward,
	BotSequence_RotateCW,
	BotSequence_RotateCCW,
	BotSequence_Jump,
	BotSequence_Light,
};

/*
 * Bot
 */
class Bot
{
	/*
	 * BotSequencer
	 */
	struct BotSequencer
	{
		/*
		 * nSequence
		 */
		uint32 nSequence;

		/*
		 * fTimer
		 */
		float fTimer;

		/*
		 * fSpeed
		 */
		float fSpeed;

		/*
		 * kPosition
		 */
		Position kPosition;

		/*
		 * kDirection
		 */
		uint32 kDirection;

		/*
		 * nColor
		 */
		uint32 nColor;
	};

private:

	/*
	 * pEffect
	 */
	ID3DXEffect* pEffect;

	/*
	 * pVertexBuffer
	 */
	IDirect3DVertexBuffer9* pVertexBuffer;

	/*
	 * pTexture
	 */
	IDirect3DTexture9* pTexture;

	/*
	 * pEnvironment
	 */
	Environment* pEnvironment;

	/*
	 * kMachine
	 */
	VirtualMachine kMachine;

	/*
	 * kClock
	 *	The clock used to keep track of VM execution
	 */
	Clock kClock;

	/*
	 * nState
	 */
	uint32 nState;

	/*
	 * kSequencer
	 */
	BotSequencer kSequencer;

public:

	/*
	 * kPosition
	 */
	Position kPosition;

	/*
	 * kDirection
	 */
	uint32 kDirection;

	/*
	 * nColor
	 */
	uint32 nColor;

	/*
	 * kSize
	 */
	D3DXVECTOR3 kSize;

public:

	/*
	 * Bot
	 */
	Bot();

	/*
	 * Reset
	 */
	ErrorCode Initialize(ResourceManager* pResourceManager);

	/*
	 * Terminate
	 */
	void Terminate();

	/*
	 * Setup
	 */
	void Setup(Environment* pInstance);

	/*
	 * Reset
	 */
	void Reset();

	/* 
	 * GetWorldPosition
	 */
	const D3DXVECTOR3 GetWorldPosition() const;

	/*
	 * GetWorldOrientation
	 */
	const D3DXVECTOR3 GetWorldOrientation() const;

	/*
	 * AddFunction
	 */
	void AddFunction(uint32 nFunction, uint32 nSize);

	/*
	 * Upload
	 */
	ErrorCode Upload(Code* pCode, uint32 nCount);

	/*
	 * Update
	 */
	bool Update(float fElapsed);

	/*
	 * Render
	 */
	void Render(RenderContext& kContext, Camera& kCamera);

private:
	
	/*
	 * Compile
	 */
	ErrorCode Compile(Code* pCode, uint8* pData, uint32 nSize);

	/*
	 * SetupVertexBuffer
	 */
	ErrorCode SetupVertexBuffer();
};

#endif //__BOT_H__