Ykkrosh
fba692c8b5
* Removed ToJSVal<jsval> because it's treated as ToJSVal<long> and causes minor confusion and/or compiler errors. Changed script interface functions to return either C++ types or a jsval_t wrapper. * Replaced some C casts with static_cast to avoid significant confusion and to cause compiler errors instead. * Removed some redundant argument-checking code. Simplified some string-generating code. * Fixed some "dereferencing type-punned pointer will break strict-aliasing rules" warnings (from `g++ -O3`). This was SVN commit r5115.
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#ifndef INCLUDED_PRODUCTIONQUEUE
|
|
#define INCLUDED_PRODUCTIONQUEUE
|
|
|
|
#include "EntityHandles.h"
|
|
#include "scripting/ScriptableObject.h"
|
|
#include <vector>
|
|
|
|
class CEntity;
|
|
|
|
class CProductionItem : public CJSObject<CProductionItem>
|
|
{
|
|
public:
|
|
int m_type;
|
|
CStrW m_name;
|
|
float m_totalTime; // how long this production takes
|
|
float m_elapsedTime; // how long we've been working on this production
|
|
|
|
CProductionItem( int type, const CStrW& name, float totalTime );
|
|
~CProductionItem();
|
|
|
|
void Update( size_t timestep );
|
|
|
|
bool IsComplete();
|
|
float GetProgress();
|
|
|
|
jsval JSI_GetProgress( JSContext* cx );
|
|
|
|
static void ScriptingInit();
|
|
};
|
|
|
|
class CProductionQueue : public CJSObject<CProductionQueue>
|
|
{
|
|
CEntity* m_owner;
|
|
std::vector<CProductionItem*> m_items;
|
|
public:
|
|
CProductionQueue( CEntity* owner );
|
|
~CProductionQueue();
|
|
|
|
void AddItem( int type, const CStrW& name, float totalTime );
|
|
void Update( size_t timestep );
|
|
void CancelAll();
|
|
|
|
jsval JSI_GetLength( JSContext* cx );
|
|
jsval_t JSI_Get( JSContext* cx, uintN argc, jsval* argv );
|
|
bool JSI_Cancel( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
static void ScriptingInit();
|
|
};
|
|
|
|
#endif
|