2007-04-22 03:09:50 +02:00
|
|
|
// Holds effects of a technology (research item), as well as its status
|
|
|
|
// (unavailable, researched, in progress, etc).
|
|
|
|
//
|
|
|
|
// There is a separate CTechnology object for each tech for each player,
|
|
|
|
// because the status can be different for different players.
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_TECHNOLOGY
|
|
|
|
#define INCLUDED_TECHNOLOGY
|
2006-06-23 03:06:21 +02:00
|
|
|
|
|
|
|
#include <vector>
|
2007-04-22 03:09:50 +02:00
|
|
|
#include "scripting/ScriptableComplex.h"
|
2006-06-23 03:06:21 +02:00
|
|
|
#include "simulation/ScriptObject.h"
|
|
|
|
#include "ps/Game.h"
|
|
|
|
|
|
|
|
class XMBElement;
|
|
|
|
class CXeromyces;
|
2006-07-19 01:59:48 +02:00
|
|
|
class CEntity;
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2007-04-22 03:09:50 +02:00
|
|
|
class CTechnology : public CJSComplex<CTechnology>
|
2006-06-23 03:06:21 +02:00
|
|
|
{
|
|
|
|
friend class CTechnologyCollection;
|
|
|
|
|
2006-12-16 02:01:15 +01:00
|
|
|
struct Modifier
|
2006-06-23 03:06:21 +02:00
|
|
|
{
|
|
|
|
CStr attribute;
|
|
|
|
float value;
|
2006-07-22 00:57:38 +02:00
|
|
|
bool isPercent;
|
|
|
|
Modifier(): value(0), isPercent(false) {}
|
2006-06-23 03:06:21 +02:00
|
|
|
};
|
|
|
|
static STL_HASH_SET<CStr, CStr_hash_compare> m_scriptsLoaded;
|
|
|
|
|
|
|
|
public:
|
2006-07-21 00:43:06 +02:00
|
|
|
CTechnology(const CStrW& name, CPlayer* player);
|
2007-05-02 14:07:08 +02:00
|
|
|
~CTechnology() {}
|
|
|
|
|
|
|
|
// noncopyable (avoid VC7.1 warning); don't derive from
|
|
|
|
// boost::noncopyable, so that multiple inheritance is avoided
|
|
|
|
private:
|
|
|
|
CTechnology(const CTechnology&);
|
|
|
|
const CTechnology& operator=(const CTechnology&);
|
|
|
|
public:
|
|
|
|
|
2006-06-23 03:06:21 +02:00
|
|
|
//JS functions
|
|
|
|
static void ScriptingInit();
|
|
|
|
jsval ApplyEffects( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
jsval IsValid( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
jsval IsResearched( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
jsval IsExcluded( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
inline jsval GetPlayerID( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void Apply( CEntity* entity );
|
2006-07-19 01:59:48 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool IsTechValid();
|
|
|
|
inline bool IsResearched() { return m_researched; }
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void SetExclusion( bool exclude ) { m_excluded=exclude; }
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool LoadXml( const CStr& filename );
|
|
|
|
bool LoadElId( XMBElement ID, CXeromyces& XeroFile );
|
|
|
|
bool LoadElReq( XMBElement Req, CXeromyces& XeroFile );
|
|
|
|
bool LoadElEffect( XMBElement Effect, CXeromyces& XeroFile, const CStr& filename );
|
2006-06-23 03:06:21 +02:00
|
|
|
|
|
|
|
private:
|
2006-07-21 00:43:06 +02:00
|
|
|
CStrW m_Name; // name of the tech file
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2006-07-21 00:43:06 +02:00
|
|
|
CStrW m_Generic;
|
|
|
|
CStrW m_Specific;
|
|
|
|
|
|
|
|
CStrW m_Icon;
|
2006-06-23 03:06:21 +02:00
|
|
|
int m_IconCell;
|
2006-07-21 00:43:06 +02:00
|
|
|
CStrW m_Classes;
|
|
|
|
CStrW m_History;
|
2006-06-23 03:06:21 +02:00
|
|
|
|
|
|
|
float m_ReqTime;
|
|
|
|
std::vector<CStr> m_ReqEntities;
|
|
|
|
std::vector<CStr> m_ReqTechs;
|
2007-04-22 03:09:50 +02:00
|
|
|
|
2006-06-23 03:06:21 +02:00
|
|
|
std::vector<CStr> m_Pairs;
|
|
|
|
std::vector<CStr> m_Targets;
|
|
|
|
std::vector<Modifier> m_Modifiers;
|
|
|
|
std::vector<Modifier> m_Sets;
|
|
|
|
|
2007-04-22 03:09:50 +02:00
|
|
|
CPlayer* m_player; //Which player this tech object belongs to
|
2006-07-21 00:43:06 +02:00
|
|
|
|
2006-06-23 03:06:21 +02:00
|
|
|
CScriptObject m_effectFunction;
|
|
|
|
|
2006-07-18 06:17:46 +02:00
|
|
|
bool m_excluded;
|
2006-06-23 03:06:21 +02:00
|
|
|
bool m_researched;
|
2006-07-19 07:26:52 +02:00
|
|
|
bool m_inProgress;
|
2006-06-23 03:06:21 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool HasReqEntities();
|
|
|
|
bool HasReqTechs();
|
2007-04-22 03:09:50 +02:00
|
|
|
|
|
|
|
// Hack: shouldn't be part of CJSComplex
|
2007-05-02 14:07:08 +02:00
|
|
|
void RebuildClassSet() {};
|
2006-06-23 03:06:21 +02:00
|
|
|
};
|
|
|
|
|
2006-09-30 17:46:40 +02:00
|
|
|
#endif
|