mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 08:57:09 +00:00
Mass refactoring part 1/2: establishing multiple subprojects, moving source files to their new location, adding resources/templates to version control
This commit is contained in:
128
src/Core/Resource/Script/CMasterTemplate.cpp
Normal file
128
src/Core/Resource/Script/CMasterTemplate.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include "CMasterTemplate.h"
|
||||
#include "../factory/CWorldLoader.h"
|
||||
#include <Core/Log.h>
|
||||
|
||||
CMasterTemplate::CMasterTemplate()
|
||||
{
|
||||
mVersion = 0;
|
||||
mFullyLoaded = false;
|
||||
mHasPropList = false;
|
||||
}
|
||||
|
||||
CMasterTemplate::~CMasterTemplate()
|
||||
{
|
||||
for (auto it = mTemplates.begin(); it != mTemplates.end(); it++)
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
EGame CMasterTemplate::GetGame()
|
||||
{
|
||||
return mGame;
|
||||
}
|
||||
|
||||
CScriptTemplate* CMasterTemplate::TemplateByID(u32 ObjectID)
|
||||
{
|
||||
auto it = mTemplates.find(ObjectID);
|
||||
|
||||
if (it != mTemplates.end())
|
||||
return it->second;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CScriptTemplate* CMasterTemplate::TemplateByID(const CFourCC& ObjectID)
|
||||
{
|
||||
return TemplateByID(ObjectID.ToLong());
|
||||
}
|
||||
|
||||
CScriptTemplate* CMasterTemplate::TemplateByIndex(u32 Index)
|
||||
{
|
||||
auto it = mTemplates.begin();
|
||||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByID(u32 StateID)
|
||||
{
|
||||
auto it = mStates.find(StateID);
|
||||
|
||||
if (it != mStates.end())
|
||||
return it->second;
|
||||
else
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByID(const CFourCC& State)
|
||||
{
|
||||
return StateByID(State.ToLong());
|
||||
}
|
||||
|
||||
TString CMasterTemplate::StateByIndex(u32 Index)
|
||||
{
|
||||
auto it = mStates.begin();
|
||||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByID(u32 MessageID)
|
||||
{
|
||||
auto it = mMessages.find(MessageID);
|
||||
|
||||
if (it != mMessages.end())
|
||||
return it->second;
|
||||
else
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByID(const CFourCC& MessageID)
|
||||
{
|
||||
return MessageByID(MessageID.ToLong());
|
||||
}
|
||||
|
||||
TString CMasterTemplate::MessageByIndex(u32 Index)
|
||||
{
|
||||
auto it = mMessages.begin();
|
||||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
CPropertyTemplate* CMasterTemplate::GetProperty(u32 PropertyID)
|
||||
{
|
||||
auto it = mPropertyList.find(PropertyID);
|
||||
|
||||
if (it != mPropertyList.end())
|
||||
return it->second;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMasterTemplate::HasPropertyList()
|
||||
{
|
||||
return mHasPropList;
|
||||
}
|
||||
|
||||
bool CMasterTemplate::IsLoadedSuccessfully()
|
||||
{
|
||||
return mFullyLoaded;
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CMasterTemplate* CMasterTemplate::GetMasterForGame(EGame Game)
|
||||
{
|
||||
auto it = smMasterMap.find(Game);
|
||||
|
||||
if (it != smMasterMap.end())
|
||||
return it->second;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::list<CMasterTemplate*> CMasterTemplate::GetMasterList()
|
||||
{
|
||||
std::list<CMasterTemplate*> list;
|
||||
|
||||
for (auto it = smMasterMap.begin(); it != smMasterMap.end(); it++)
|
||||
list.push_back(it->second);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
std::map<EGame, CMasterTemplate*> CMasterTemplate::smMasterMap;
|
||||
u32 CMasterTemplate::smGameListVersion;
|
||||
68
src/Core/Resource/Script/CMasterTemplate.h
Normal file
68
src/Core/Resource/Script/CMasterTemplate.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef CMASTERTEMPLATE_H
|
||||
#define CMASTERTEMPLATE_H
|
||||
|
||||
#include "CScriptTemplate.h"
|
||||
#include "../EFormatVersion.h"
|
||||
#include <Common/types.h>
|
||||
#include <map>
|
||||
#include <tinyxml2.h>
|
||||
|
||||
class CMasterTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
EGame mGame;
|
||||
TString mGameName;
|
||||
TString mSourceFile;
|
||||
u32 mVersion;
|
||||
bool mFullyLoaded;
|
||||
|
||||
std::map<u32, CScriptTemplate*> mTemplates;
|
||||
std::map<u32, TString> mStates;
|
||||
std::map<u32, TString> mMessages;
|
||||
|
||||
bool mHasPropList;
|
||||
std::map<u32, CPropertyTemplate*> mPropertyList;
|
||||
|
||||
static std::map<EGame, CMasterTemplate*> smMasterMap;
|
||||
static u32 smGameListVersion;
|
||||
|
||||
public:
|
||||
CMasterTemplate();
|
||||
~CMasterTemplate();
|
||||
EGame GetGame();
|
||||
u32 NumScriptTemplates();
|
||||
u32 NumStates();
|
||||
u32 NumMessages();
|
||||
CScriptTemplate* TemplateByID(u32 ObjectID);
|
||||
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
|
||||
CScriptTemplate* TemplateByIndex(u32 Index);
|
||||
TString StateByID(u32 StateID);
|
||||
TString StateByID(const CFourCC& StateID);
|
||||
TString StateByIndex(u32 Index);
|
||||
TString MessageByID(u32 MessageID);
|
||||
TString MessageByID(const CFourCC& MessageID);
|
||||
TString MessageByIndex(u32 Index);
|
||||
CPropertyTemplate* GetProperty(u32 PropertyID);
|
||||
bool HasPropertyList();
|
||||
bool IsLoadedSuccessfully();
|
||||
|
||||
static CMasterTemplate* GetMasterForGame(EGame Game);
|
||||
static std::list<CMasterTemplate*> GetMasterList();
|
||||
};
|
||||
|
||||
// ************ INLINE ************
|
||||
inline u32 CMasterTemplate::NumScriptTemplates() {
|
||||
return mTemplates.size();
|
||||
}
|
||||
|
||||
inline u32 CMasterTemplate::NumStates() {
|
||||
return mStates.size();
|
||||
}
|
||||
|
||||
inline u32 CMasterTemplate::NumMessages() {
|
||||
return mMessages.size();
|
||||
}
|
||||
|
||||
#endif // CMASTERTEMPLATE_H
|
||||
123
src/Core/Resource/Script/CProperty.cpp
Normal file
123
src/Core/Resource/Script/CProperty.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "CProperty.h"
|
||||
|
||||
// ************ CPropertyStruct ************
|
||||
CPropertyStruct::~CPropertyStruct()
|
||||
{
|
||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
CPropertyBase* CPropertyStruct::PropertyByIndex(u32 index)
|
||||
{
|
||||
return mProperties[index];
|
||||
}
|
||||
|
||||
CPropertyBase* CPropertyStruct::PropertyByID(u32 ID)
|
||||
{
|
||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||
{
|
||||
if ((*it)->ID() == ID)
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPropertyBase* CPropertyStruct::PropertyByIDString(const TIDString& str)
|
||||
{
|
||||
// Resolve namespace
|
||||
u32 nsStart = str.IndexOf(":");
|
||||
|
||||
// String has namespace; the requested property is within a struct
|
||||
if (nsStart != -1)
|
||||
{
|
||||
TString strStructID = str.Truncate(nsStart);
|
||||
if (!strStructID.IsHexString()) return nullptr;
|
||||
|
||||
u32 structID = strStructID.ToInt32();
|
||||
TString propName = str.ChopFront(nsStart + 1);
|
||||
|
||||
CPropertyStruct *pStruct = StructByID(structID);
|
||||
if (!pStruct) return nullptr;
|
||||
else return pStruct->PropertyByIDString(propName);
|
||||
}
|
||||
|
||||
// No namespace; fetch the property from this struct
|
||||
else
|
||||
{
|
||||
if (str.IsHexString())
|
||||
return PropertyByID(str.ToInt32());
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
CPropertyStruct* CPropertyStruct::StructByIndex(u32 index)
|
||||
{
|
||||
CPropertyBase *pProp = PropertyByIndex(index);
|
||||
|
||||
if (pProp->Type() == eStructProperty)
|
||||
return static_cast<CPropertyStruct*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPropertyStruct* CPropertyStruct::StructByID(u32 ID)
|
||||
{
|
||||
CPropertyBase *pProp = PropertyByID(ID);
|
||||
|
||||
if (pProp->Type() == eStructProperty)
|
||||
return static_cast<CPropertyStruct*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPropertyStruct* CPropertyStruct::StructByIDString(const TIDString& str)
|
||||
{
|
||||
CPropertyBase *pProp = PropertyByIDString(str);
|
||||
|
||||
if (pProp->Type() == eStructProperty)
|
||||
return static_cast<CPropertyStruct*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CPropertyStruct* CPropertyStruct::CopyFromTemplate(CStructTemplate *pTemp)
|
||||
{
|
||||
CPropertyStruct *pStruct = new CPropertyStruct();
|
||||
pStruct->mpTemplate = pTemp;
|
||||
pStruct->Reserve(pTemp->Count());
|
||||
|
||||
for (u32 iProp = 0; iProp < pTemp->Count(); iProp++)
|
||||
{
|
||||
CPropertyTemplate *pPropTemp = pTemp->PropertyByIndex(iProp);
|
||||
CPropertyBase *pProp = nullptr;
|
||||
|
||||
switch (pPropTemp->Type())
|
||||
{
|
||||
case eBoolProperty: pProp = new CBoolProperty(false); break;
|
||||
case eByteProperty: pProp = new CByteProperty(0); break;
|
||||
case eShortProperty: pProp = new CShortProperty(0); break;
|
||||
case eLongProperty: pProp = new CLongProperty(0); break;
|
||||
case eEnumProperty: pProp = new CEnumProperty(0); break;
|
||||
case eBitfieldProperty: pProp = new CBitfieldProperty(0); break;
|
||||
case eFloatProperty: pProp = new CFloatProperty(0.f); break;
|
||||
case eStringProperty: pProp = new CStringProperty(""); break;
|
||||
case eVector3Property: pProp = new CVector3Property(CVector3f::skZero); break;
|
||||
case eColorProperty: pProp = new CColorProperty(CColor::skBlack); break;
|
||||
case eFileProperty: pProp = new CFileProperty(); break;
|
||||
case eArrayProperty: pProp = new CArrayProperty(); break;
|
||||
case eAnimParamsProperty: pProp = new CAnimParamsProperty(); break;
|
||||
case eUnknownProperty: pProp = new CUnknownProperty(); break;
|
||||
case eStructProperty: pProp = CPropertyStruct::CopyFromTemplate(static_cast<CStructTemplate*>(pPropTemp)); break;
|
||||
}
|
||||
|
||||
if (pProp)
|
||||
{
|
||||
pProp->SetTemplate(pPropTemp);
|
||||
pStruct->mProperties.push_back(pProp);
|
||||
}
|
||||
}
|
||||
|
||||
return pStruct;
|
||||
}
|
||||
103
src/Core/Resource/Script/CProperty.h
Normal file
103
src/Core/Resource/Script/CProperty.h
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef CPROPERTY
|
||||
#define CPROPERTY
|
||||
|
||||
/*
|
||||
* This header file declares some classes used to track script object properties
|
||||
* CPropertyBase, __CProperty (and typedefs), CPropertyStruct
|
||||
* It's a bit hard to read, should be reorganized at some point
|
||||
*/
|
||||
#include "../CResource.h"
|
||||
#include "../CAnimationParameters.h"
|
||||
#include "CPropertyTemplate.h"
|
||||
#include "EPropertyType.h"
|
||||
#include <Common/CColor.h>
|
||||
#include <Common/CVector3f.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Core/TResPtr.h>
|
||||
#include <list>
|
||||
|
||||
class CScriptTemplate;
|
||||
|
||||
typedef TString TIDString;
|
||||
|
||||
/*
|
||||
* CPropertyBase is the base class, containing just some virtual function definitions
|
||||
* Virtual destructor is mainly there to make cleanup easy; don't need to cast to delete
|
||||
*/
|
||||
class CPropertyBase
|
||||
{
|
||||
friend class CScriptLoader;
|
||||
protected:
|
||||
CPropertyTemplate *mpTemplate;
|
||||
public:
|
||||
virtual ~CPropertyBase() {}
|
||||
inline virtual EPropertyType Type() = 0;
|
||||
inline CPropertyTemplate *Template() { return mpTemplate; }
|
||||
inline void SetTemplate(CPropertyTemplate *_tmp) { mpTemplate = _tmp; }
|
||||
inline TString Name() { return mpTemplate->Name(); }
|
||||
inline u32 ID() { return mpTemplate->PropertyID(); }
|
||||
};
|
||||
|
||||
/*
|
||||
* __CProperty is a template subclass for actual properties.
|
||||
* Don't use this class directly. Typedefs are provided for every possible property type.
|
||||
*/
|
||||
template <typename t, EPropertyType type>
|
||||
class __CProperty : public CPropertyBase
|
||||
{
|
||||
friend class CScriptLoader;
|
||||
t mValue;
|
||||
public:
|
||||
__CProperty() {}
|
||||
__CProperty(t v) { Set(v); }
|
||||
~__CProperty() {}
|
||||
inline EPropertyType Type() { return type; }
|
||||
inline t Get() { return mValue; }
|
||||
inline void Set(t v) { mValue = v; }
|
||||
};
|
||||
typedef __CProperty<bool, eBoolProperty> CBoolProperty;
|
||||
typedef __CProperty<char, eByteProperty> CByteProperty;
|
||||
typedef __CProperty<short, eShortProperty> CShortProperty;
|
||||
typedef __CProperty<long, eLongProperty> CLongProperty;
|
||||
typedef __CProperty<long, eEnumProperty> CEnumProperty;
|
||||
typedef __CProperty<long, eBitfieldProperty> CBitfieldProperty;
|
||||
typedef __CProperty<float, eFloatProperty> CFloatProperty;
|
||||
typedef __CProperty<TString, eStringProperty> CStringProperty;
|
||||
typedef __CProperty<CVector3f, eVector3Property> CVector3Property;
|
||||
typedef __CProperty<CColor, eColorProperty> CColorProperty;
|
||||
typedef __CProperty<TResPtr<CResource>, eFileProperty> CFileProperty;
|
||||
typedef __CProperty<CAnimationParameters, eAnimParamsProperty> CAnimParamsProperty;
|
||||
typedef __CProperty<std::vector<u8>, eArrayProperty> CArrayProperty;
|
||||
typedef __CProperty<std::vector<u8>, eUnknownProperty> CUnknownProperty;
|
||||
|
||||
/*
|
||||
* CPropertyStruct is for defining structs of properties.
|
||||
*/
|
||||
class CPropertyStruct : public CPropertyBase
|
||||
{
|
||||
friend class CScriptLoader;
|
||||
std::vector<CPropertyBase*> mProperties;
|
||||
public:
|
||||
// Destructor simply iterates through the list and deletes them. Nothing complicated.
|
||||
~CPropertyStruct();
|
||||
|
||||
// Inline
|
||||
EPropertyType Type() { return eStructProperty; }
|
||||
inline u32 Count() { return mProperties.size(); }
|
||||
inline void Reserve(u32 amount) { mProperties.reserve(amount); }
|
||||
inline CPropertyBase* operator[](u32 index) { return mProperties[index]; }
|
||||
|
||||
// Functions
|
||||
CPropertyBase* PropertyByIndex(u32 index);
|
||||
CPropertyBase* PropertyByID(u32 ID);
|
||||
CPropertyBase* PropertyByIDString(const TIDString& str);
|
||||
CPropertyStruct* StructByIndex(u32 index);
|
||||
CPropertyStruct* StructByID(u32 ID);
|
||||
CPropertyStruct* StructByIDString(const TIDString& str);
|
||||
|
||||
// Static
|
||||
static CPropertyStruct* CopyFromTemplate(CStructTemplate *pTemp);
|
||||
};
|
||||
|
||||
#endif // CPROPERTY
|
||||
|
||||
175
src/Core/Resource/Script/CPropertyTemplate.cpp
Normal file
175
src/Core/Resource/Script/CPropertyTemplate.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
#include "CPropertyTemplate.h"
|
||||
#include <iostream>
|
||||
|
||||
EPropertyType PropStringToPropEnum(const TString& prop)
|
||||
{
|
||||
if (prop == "bool") return eBoolProperty;
|
||||
if (prop == "byte") return eByteProperty;
|
||||
if (prop == "short") return eShortProperty;
|
||||
if (prop == "long") return eLongProperty;
|
||||
if (prop == "enum") return eEnumProperty;
|
||||
if (prop == "bitfield") return eBitfieldProperty;
|
||||
if (prop == "float") return eFloatProperty;
|
||||
if (prop == "string") return eStringProperty;
|
||||
if (prop == "color") return eColorProperty;
|
||||
if (prop == "vector3f") return eVector3Property;
|
||||
if (prop == "file") return eFileProperty;
|
||||
if (prop == "struct") return eStructProperty;
|
||||
if (prop == "array") return eArrayProperty;
|
||||
if (prop == "animparams") return eAnimParamsProperty;
|
||||
if (prop == "unknown") return eUnknownProperty;
|
||||
return eInvalidProperty;
|
||||
}
|
||||
|
||||
TString PropEnumToPropString(EPropertyType prop)
|
||||
{
|
||||
switch (prop)
|
||||
{
|
||||
case eBoolProperty: return "bool";
|
||||
case eByteProperty: return "byte";
|
||||
case eShortProperty: return "short";
|
||||
case eLongProperty: return "long";
|
||||
case eEnumProperty: return "enum";
|
||||
case eBitfieldProperty: return "bitfield";
|
||||
case eFloatProperty: return "float";
|
||||
case eStringProperty: return "string";
|
||||
case eColorProperty: return "color";
|
||||
case eVector3Property: return "vector3f";
|
||||
case eFileProperty: return "file";
|
||||
case eStructProperty: return "struct";
|
||||
case eArrayProperty: return "array";
|
||||
case eAnimParamsProperty: return "animparams";
|
||||
case eUnknownProperty: return "unknown";
|
||||
|
||||
case eInvalidProperty:
|
||||
default:
|
||||
return "invalid";
|
||||
}
|
||||
}
|
||||
|
||||
/*******************
|
||||
* CStructTemplate *
|
||||
*******************/
|
||||
CStructTemplate::CStructTemplate() : CPropertyTemplate(-1)
|
||||
{
|
||||
mIsSingleProperty = false;
|
||||
mPropType = eStructProperty;
|
||||
}
|
||||
|
||||
CStructTemplate::~CStructTemplate()
|
||||
{
|
||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
// ************ GETTERS ************
|
||||
EPropertyType CStructTemplate::Type() const
|
||||
{
|
||||
return eStructProperty;
|
||||
}
|
||||
|
||||
bool CStructTemplate::IsSingleProperty() const
|
||||
{
|
||||
return mIsSingleProperty;
|
||||
}
|
||||
|
||||
u32 CStructTemplate::Count() const
|
||||
{
|
||||
return mProperties.size();
|
||||
}
|
||||
|
||||
CPropertyTemplate* CStructTemplate::PropertyByIndex(u32 index)
|
||||
{
|
||||
if (mProperties.size() > index)
|
||||
return mProperties[index];
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPropertyTemplate* CStructTemplate::PropertyByID(u32 ID)
|
||||
{
|
||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||
{
|
||||
if ((*it)->PropertyID() == ID)
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPropertyTemplate* CStructTemplate::PropertyByIDString(const TIDString& str)
|
||||
{
|
||||
// Resolve namespace
|
||||
u32 nsStart = str.IndexOf(":");
|
||||
u32 propStart = nsStart + 1;
|
||||
|
||||
// String has namespace; the requested property is within a struct
|
||||
if (nsStart != -1)
|
||||
{
|
||||
TString strStructID = str.SubString(0, nsStart);
|
||||
if (!strStructID.IsHexString()) return nullptr;
|
||||
|
||||
u32 structID = strStructID.ToInt32();
|
||||
TString propName = str.SubString(propStart, str.Length() - propStart);
|
||||
|
||||
CStructTemplate *pStruct = StructByID(structID);
|
||||
if (!pStruct) return nullptr;
|
||||
else return pStruct->PropertyByIDString(propName);
|
||||
}
|
||||
|
||||
// No namespace; fetch the property from this struct
|
||||
else
|
||||
{
|
||||
// ID string lookup
|
||||
if (str.IsHexString())
|
||||
return PropertyByID(str.ToInt32());
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
CStructTemplate* CStructTemplate::StructByIndex(u32 index)
|
||||
{
|
||||
CPropertyTemplate *pProp = PropertyByIndex(index);
|
||||
|
||||
if (pProp->Type() == eStructProperty)
|
||||
return static_cast<CStructTemplate*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStructTemplate* CStructTemplate::StructByID(u32 ID)
|
||||
{
|
||||
CPropertyTemplate *pProp = PropertyByID(ID);
|
||||
|
||||
if (pProp && pProp->Type() == eStructProperty)
|
||||
return static_cast<CStructTemplate*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStructTemplate* CStructTemplate::StructByIDString(const TString& str)
|
||||
{
|
||||
CPropertyTemplate *pProp = PropertyByIDString(str);
|
||||
|
||||
if (pProp && pProp->Type() == eStructProperty)
|
||||
return static_cast<CStructTemplate*>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ************ DEBUG ************
|
||||
void CStructTemplate::DebugPrintProperties(TString base)
|
||||
{
|
||||
base = base + Name() + "::";
|
||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||
{
|
||||
CPropertyTemplate *tmp = *it;
|
||||
if (tmp->Type() == eStructProperty)
|
||||
{
|
||||
CStructTemplate *tmp2 = static_cast<CStructTemplate*>(tmp);
|
||||
tmp2->DebugPrintProperties(base);
|
||||
}
|
||||
else
|
||||
std::cout << base << tmp->Name() << "\n";
|
||||
}
|
||||
}
|
||||
219
src/Core/Resource/Script/CPropertyTemplate.h
Normal file
219
src/Core/Resource/Script/CPropertyTemplate.h
Normal file
@@ -0,0 +1,219 @@
|
||||
#ifndef CPROPERTYTEMPLATE
|
||||
#define CPROPERTYTEMPLATE
|
||||
|
||||
#include "EPropertyType.h"
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
#include <vector>
|
||||
|
||||
typedef TString TIDString;
|
||||
|
||||
class CPropertyTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
protected:
|
||||
EPropertyType mPropType;
|
||||
TString mPropName;
|
||||
u32 mPropID;
|
||||
public:
|
||||
CPropertyTemplate(u32 ID)
|
||||
: mPropID(ID)
|
||||
{
|
||||
}
|
||||
|
||||
CPropertyTemplate(EPropertyType type, TString name, u32 ID)
|
||||
: mPropType(type),
|
||||
mPropName(name),
|
||||
mPropID(ID)
|
||||
{
|
||||
}
|
||||
|
||||
virtual EPropertyType Type() const
|
||||
{
|
||||
return mPropType;
|
||||
}
|
||||
|
||||
inline TString Name() const
|
||||
{
|
||||
return mPropName;
|
||||
}
|
||||
|
||||
inline u32 PropertyID() const
|
||||
{
|
||||
return mPropID;
|
||||
}
|
||||
|
||||
inline void SetName(const TString& Name)
|
||||
{
|
||||
mPropName = Name;
|
||||
}
|
||||
};
|
||||
|
||||
class CFileTemplate : public CPropertyTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
TStringList mAcceptedExtensions;
|
||||
public:
|
||||
CFileTemplate(u32 ID) : CPropertyTemplate(ID) { mPropType = eFileProperty; }
|
||||
|
||||
CFileTemplate(const TString& name, u32 ID, const TStringList& extensions)
|
||||
: CPropertyTemplate(ID)
|
||||
{
|
||||
mPropType = eFileProperty;
|
||||
mPropName = name;
|
||||
mAcceptedExtensions = extensions;
|
||||
}
|
||||
|
||||
EPropertyType Type() const
|
||||
{
|
||||
return eFileProperty;
|
||||
}
|
||||
|
||||
const TStringList& Extensions() const
|
||||
{
|
||||
return mAcceptedExtensions;
|
||||
}
|
||||
};
|
||||
|
||||
class CEnumTemplate : public CPropertyTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
struct SEnumerator
|
||||
{
|
||||
TString Name;
|
||||
u32 ID;
|
||||
|
||||
SEnumerator(const TString& _name, u32 _ID)
|
||||
: Name(_name), ID(_ID) {}
|
||||
};
|
||||
std::vector<SEnumerator> mEnumerators;
|
||||
TString mSourceFile;
|
||||
|
||||
public:
|
||||
CEnumTemplate(u32 ID)
|
||||
: CPropertyTemplate(ID)
|
||||
{
|
||||
mPropType = eEnumProperty;
|
||||
}
|
||||
|
||||
CEnumTemplate(const TString& name, u32 ID)
|
||||
: CPropertyTemplate(eEnumProperty, name, ID)
|
||||
{}
|
||||
|
||||
EPropertyType Type() const
|
||||
{
|
||||
return eEnumProperty;
|
||||
}
|
||||
|
||||
u32 NumEnumerators()
|
||||
{
|
||||
return mEnumerators.size();
|
||||
}
|
||||
|
||||
u32 EnumeratorIndex(u32 enumID)
|
||||
{
|
||||
for (u32 iEnum = 0; iEnum < mEnumerators.size(); iEnum++)
|
||||
{
|
||||
if (mEnumerators[iEnum].ID == enumID)
|
||||
return iEnum;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 EnumeratorID(u32 enumIndex)
|
||||
{
|
||||
if (mEnumerators.size() > enumIndex)
|
||||
return mEnumerators[enumIndex].ID;
|
||||
|
||||
else return -1;
|
||||
}
|
||||
|
||||
TString EnumeratorName(u32 enumIndex)
|
||||
{
|
||||
if (mEnumerators.size() > enumIndex)
|
||||
return mEnumerators[enumIndex].Name;
|
||||
|
||||
else return "INVALID ENUM INDEX";
|
||||
}
|
||||
};
|
||||
|
||||
class CBitfieldTemplate : public CPropertyTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
struct SBitFlag
|
||||
{
|
||||
TString Name;
|
||||
u32 Mask;
|
||||
|
||||
SBitFlag(const TString& _name, u32 _mask)
|
||||
: Name(_name), Mask(_mask) {}
|
||||
};
|
||||
std::vector<SBitFlag> mBitFlags;
|
||||
TString mSourceFile;
|
||||
|
||||
public:
|
||||
CBitfieldTemplate(u32 ID)
|
||||
: CPropertyTemplate(ID)
|
||||
{
|
||||
mPropType = eBitfieldProperty;
|
||||
}
|
||||
|
||||
CBitfieldTemplate(const TString& name, u32 ID)
|
||||
: CPropertyTemplate(eBitfieldProperty, name, ID)
|
||||
{}
|
||||
|
||||
EPropertyType Type() const
|
||||
{
|
||||
return eBitfieldProperty;
|
||||
}
|
||||
|
||||
u32 NumFlags()
|
||||
{
|
||||
return mBitFlags.size();
|
||||
}
|
||||
|
||||
TString FlagName(u32 index)
|
||||
{
|
||||
return mBitFlags[index].Name;
|
||||
}
|
||||
|
||||
u32 FlagMask(u32 index)
|
||||
{
|
||||
return mBitFlags[index].Mask;
|
||||
}
|
||||
};
|
||||
|
||||
class CStructTemplate : public CPropertyTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
bool mIsSingleProperty;
|
||||
std::vector<CPropertyTemplate*> mProperties;
|
||||
TString mSourceFile;
|
||||
public:
|
||||
CStructTemplate();
|
||||
~CStructTemplate();
|
||||
|
||||
EPropertyType Type() const;
|
||||
bool IsSingleProperty() const;
|
||||
u32 Count() const;
|
||||
CPropertyTemplate* PropertyByIndex(u32 index);
|
||||
CPropertyTemplate* PropertyByID(u32 ID);
|
||||
CPropertyTemplate* PropertyByIDString(const TIDString& str);
|
||||
CStructTemplate* StructByIndex(u32 index);
|
||||
CStructTemplate* StructByID(u32 ID);
|
||||
CStructTemplate* StructByIDString(const TIDString& str);
|
||||
void DebugPrintProperties(TString base);
|
||||
};
|
||||
|
||||
#endif // CPROPERTYTEMPLATE
|
||||
|
||||
95
src/Core/Resource/Script/CScriptLayer.cpp
Normal file
95
src/Core/Resource/Script/CScriptLayer.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "CScriptLayer.h"
|
||||
|
||||
CScriptLayer::CScriptLayer()
|
||||
{
|
||||
mLayerName = "New Layer";
|
||||
mActive = true;
|
||||
mVisible = true;
|
||||
}
|
||||
|
||||
CScriptLayer::~CScriptLayer()
|
||||
{
|
||||
for (auto it = mObjects.begin(); it != mObjects.end(); it++)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
// ************* DATA MANIPULATION *************
|
||||
void CScriptLayer::AddObject(CScriptObject* object)
|
||||
{
|
||||
mObjects.push_back(object);
|
||||
}
|
||||
|
||||
void CScriptLayer::DeleteObjectByIndex(u32 index)
|
||||
{
|
||||
delete mObjects[index];
|
||||
mObjects.erase(mObjects.begin() + index, mObjects.begin() + index);
|
||||
}
|
||||
|
||||
void CScriptLayer::DeleteObjectByID(u32 ID)
|
||||
{
|
||||
for (auto it = mObjects.begin(); it != mObjects.end(); it++)
|
||||
{
|
||||
if ((*it)->InstanceID() == ID)
|
||||
{
|
||||
delete *it;
|
||||
mObjects.erase(it, it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptLayer::Reserve(u32 amount)
|
||||
{
|
||||
mObjects.reserve(amount);
|
||||
}
|
||||
|
||||
// ************* GETTERS *************
|
||||
TString CScriptLayer::Name()
|
||||
{
|
||||
return mLayerName;
|
||||
}
|
||||
|
||||
bool CScriptLayer::IsActive()
|
||||
{
|
||||
return mActive;
|
||||
}
|
||||
|
||||
bool CScriptLayer::IsVisible()
|
||||
{
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
u32 CScriptLayer::GetNumObjects()
|
||||
{
|
||||
return mObjects.size();
|
||||
}
|
||||
|
||||
CScriptObject* CScriptLayer::ObjectByIndex(u32 index)
|
||||
{
|
||||
return mObjects[index];
|
||||
}
|
||||
|
||||
CScriptObject* CScriptLayer::ObjectByID(u32 ID)
|
||||
{
|
||||
for (auto it = mObjects.begin(); it != mObjects.end(); it++)
|
||||
if ((*it)->InstanceID() == ID)
|
||||
return *it;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ************* SETTERS *************
|
||||
void CScriptLayer::SetName(const TString& name)
|
||||
{
|
||||
mLayerName = name;
|
||||
}
|
||||
|
||||
void CScriptLayer::SetActive(bool active)
|
||||
{
|
||||
mActive = active;
|
||||
}
|
||||
|
||||
void CScriptLayer::SetVisible(bool visible)
|
||||
{
|
||||
mVisible = visible;
|
||||
}
|
||||
48
src/Core/Resource/Script/CScriptLayer.h
Normal file
48
src/Core/Resource/Script/CScriptLayer.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef SSCRIPTLAYER_H
|
||||
#define SSCRIPTLAYER_H
|
||||
|
||||
#include "CScriptObject.h"
|
||||
#include <Common/types.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CScriptLayer
|
||||
{
|
||||
TString mLayerName;
|
||||
bool mActive;
|
||||
bool mVisible;
|
||||
std::vector<CScriptObject*> mObjects;
|
||||
public:
|
||||
CScriptLayer();
|
||||
~CScriptLayer();
|
||||
|
||||
// Data Manipulation
|
||||
void AddObject(CScriptObject* object);
|
||||
void DeleteObjectByIndex(u32 index);
|
||||
void DeleteObjectByID(u32 ID);
|
||||
void Reserve(u32 amount);
|
||||
|
||||
// Getters and Setters
|
||||
TString Name();
|
||||
bool IsActive();
|
||||
bool IsVisible();
|
||||
u32 GetNumObjects();
|
||||
CScriptObject* ObjectByIndex(u32 index);
|
||||
CScriptObject* ObjectByID(u32 ID);
|
||||
|
||||
void SetName(const TString& name);
|
||||
void SetActive(bool active);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
// Operators
|
||||
CScriptObject* operator[](u32 index);
|
||||
};
|
||||
|
||||
// ************* INLINE FUNCTIONS *************
|
||||
inline CScriptObject* CScriptLayer::operator[](u32 index)
|
||||
{
|
||||
return mObjects[index];
|
||||
}
|
||||
|
||||
|
||||
#endif // SSCRIPTLAYER_H
|
||||
226
src/Core/Resource/Script/CScriptObject.cpp
Normal file
226
src/Core/Resource/Script/CScriptObject.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
#include "CScriptObject.h"
|
||||
#include "../CAnimSet.h"
|
||||
#include "CMasterTemplate.h"
|
||||
|
||||
CScriptObject::CScriptObject(CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate)
|
||||
{
|
||||
mpTemplate = pTemplate;
|
||||
mpArea = pArea;
|
||||
mpLayer = pLayer;
|
||||
mpProperties = nullptr;
|
||||
mpTemplate->AddObject(this);
|
||||
mpDisplayModel = nullptr;
|
||||
mpBillboard = nullptr;
|
||||
mpCollision = nullptr;
|
||||
mHasInGameModel = false;
|
||||
}
|
||||
|
||||
CScriptObject::~CScriptObject()
|
||||
{
|
||||
if (mpProperties) delete mpProperties;
|
||||
mpTemplate->RemoveObject(this);
|
||||
}
|
||||
|
||||
// ************ DATA MANIPULATION ************
|
||||
void CScriptObject::CopyFromTemplate(CScriptTemplate *pTemp, u32 propCount)
|
||||
{
|
||||
CStructTemplate *pBaseStruct = pTemp->BaseStructByCount(propCount);
|
||||
delete mpProperties;
|
||||
mpProperties = CPropertyStruct::CopyFromTemplate(pBaseStruct);
|
||||
}
|
||||
|
||||
void CScriptObject::EvaluateProperties()
|
||||
{
|
||||
mpInstanceName = mpTemplate->FindInstanceName(mpProperties);
|
||||
mpPosition = mpTemplate->FindPosition(mpProperties);
|
||||
mpRotation = mpTemplate->FindRotation(mpProperties);
|
||||
mpScale = mpTemplate->FindScale(mpProperties);
|
||||
mpActive = mpTemplate->FindActive(mpProperties);
|
||||
mpLightParameters = mpTemplate->FindLightParameters(mpProperties);
|
||||
mHasInGameModel = mpTemplate->HasInGameModel(mpProperties);
|
||||
mVolumeShape = mpTemplate->VolumeShape(this);
|
||||
EvaluateDisplayModel();
|
||||
EvaluateBillboard();
|
||||
EvaluateCollisionModel();
|
||||
}
|
||||
|
||||
void CScriptObject::EvaluateDisplayModel()
|
||||
{
|
||||
mpDisplayModel = mpTemplate->FindDisplayModel(mpProperties);
|
||||
}
|
||||
|
||||
void CScriptObject::EvaluateBillboard()
|
||||
{
|
||||
mpBillboard = mpTemplate->FindBillboardTexture(mpProperties);
|
||||
}
|
||||
|
||||
void CScriptObject::EvaluateCollisionModel()
|
||||
{
|
||||
mpCollision = mpTemplate->FindCollision(mpProperties);
|
||||
}
|
||||
|
||||
// ************ GETTERS ************
|
||||
CPropertyBase* CScriptObject::PropertyByIndex(u32 index) const
|
||||
{
|
||||
return mpProperties->PropertyByIndex(index);
|
||||
}
|
||||
|
||||
CPropertyBase* CScriptObject::PropertyByIDString(const TString& str) const
|
||||
{
|
||||
return mpProperties->PropertyByIDString(str);
|
||||
}
|
||||
|
||||
CScriptTemplate* CScriptObject::Template() const
|
||||
{
|
||||
return mpTemplate;
|
||||
}
|
||||
|
||||
CMasterTemplate* CScriptObject::MasterTemplate() const
|
||||
{
|
||||
return mpTemplate->MasterTemplate();
|
||||
}
|
||||
|
||||
CGameArea* CScriptObject::Area() const
|
||||
{
|
||||
return mpArea;
|
||||
}
|
||||
|
||||
CScriptLayer* CScriptObject::Layer() const
|
||||
{
|
||||
return mpLayer;
|
||||
}
|
||||
|
||||
CPropertyStruct* CScriptObject::Properties() const
|
||||
{
|
||||
return mpProperties;
|
||||
}
|
||||
|
||||
u32 CScriptObject::NumProperties() const
|
||||
{
|
||||
return mpProperties->Count();
|
||||
}
|
||||
|
||||
u32 CScriptObject::ObjectTypeID() const
|
||||
{
|
||||
return mpTemplate->ObjectID();
|
||||
}
|
||||
|
||||
u32 CScriptObject::InstanceID() const
|
||||
{
|
||||
return mInstanceID;
|
||||
}
|
||||
|
||||
u32 CScriptObject::NumInLinks() const
|
||||
{
|
||||
return mInConnections.size();
|
||||
}
|
||||
|
||||
u32 CScriptObject::NumOutLinks() const
|
||||
{
|
||||
return mOutConnections.size();
|
||||
}
|
||||
|
||||
const SLink& CScriptObject::InLink(u32 index) const
|
||||
{
|
||||
return mInConnections[index];
|
||||
}
|
||||
|
||||
const SLink& CScriptObject::OutLink(u32 index) const
|
||||
{
|
||||
return mOutConnections[index];
|
||||
}
|
||||
|
||||
TString CScriptObject::InstanceName() const
|
||||
{
|
||||
if (mpInstanceName)
|
||||
return mpInstanceName->Get();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Position() const
|
||||
{
|
||||
if (mpPosition)
|
||||
return mpPosition->Get();
|
||||
else
|
||||
return CVector3f::skZero;
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Rotation() const
|
||||
{
|
||||
if (mpRotation)
|
||||
return mpRotation->Get();
|
||||
else
|
||||
return CVector3f::skZero;
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Scale() const
|
||||
{
|
||||
if (mpScale)
|
||||
return mpScale->Get();
|
||||
else
|
||||
return CVector3f::skOne;
|
||||
}
|
||||
|
||||
bool CScriptObject::IsActive() const
|
||||
{
|
||||
if (mpActive)
|
||||
return mpActive->Get();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScriptObject::HasInGameModel() const
|
||||
{
|
||||
return mHasInGameModel;
|
||||
}
|
||||
|
||||
void CScriptObject::SetPosition(const CVector3f& newPos)
|
||||
{
|
||||
if (mpPosition) mpPosition->Set(newPos);
|
||||
}
|
||||
|
||||
void CScriptObject::SetRotation(const CVector3f& newRot)
|
||||
{
|
||||
if (mpRotation) mpRotation->Set(newRot);
|
||||
}
|
||||
|
||||
void CScriptObject::SetScale(const CVector3f& newScale)
|
||||
{
|
||||
if (mpScale) mpScale->Set(newScale);
|
||||
}
|
||||
|
||||
void CScriptObject::SetName(const TString& newName)
|
||||
{
|
||||
if (mpInstanceName) mpInstanceName->Set(newName);
|
||||
}
|
||||
|
||||
void CScriptObject::SetActive(bool isActive)
|
||||
{
|
||||
if (mpActive) mpActive->Set(isActive);
|
||||
}
|
||||
|
||||
CPropertyStruct* CScriptObject::LightParameters() const
|
||||
{
|
||||
return mpLightParameters;
|
||||
}
|
||||
|
||||
CModel* CScriptObject::GetDisplayModel() const
|
||||
{
|
||||
return mpDisplayModel;
|
||||
}
|
||||
|
||||
CTexture* CScriptObject::GetBillboard() const
|
||||
{
|
||||
return mpBillboard;
|
||||
}
|
||||
|
||||
CCollisionMeshGroup* CScriptObject::GetCollision() const
|
||||
{
|
||||
return mpCollision;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptObject::VolumeShape() const
|
||||
{
|
||||
return mVolumeShape;
|
||||
}
|
||||
84
src/Core/Resource/Script/CScriptObject.h
Normal file
84
src/Core/Resource/Script/CScriptObject.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef CSCRIPTOBJECT_H
|
||||
#define CSCRIPTOBJECT_H
|
||||
|
||||
#include "SConnection.h"
|
||||
#include "CProperty.h"
|
||||
#include "CPropertyTemplate.h"
|
||||
#include "CScriptTemplate.h"
|
||||
#include "../model/CModel.h"
|
||||
#include "../CCollisionMeshGroup.h"
|
||||
#include "../CGameArea.h"
|
||||
|
||||
class CScriptLayer;
|
||||
|
||||
class CScriptObject
|
||||
{
|
||||
friend class CScriptLoader;
|
||||
friend class CAreaLoader;
|
||||
|
||||
CScriptTemplate *mpTemplate;
|
||||
TResPtr<CGameArea> mpArea;
|
||||
CScriptLayer *mpLayer;
|
||||
|
||||
u32 mInstanceID;
|
||||
std::vector<SLink> mOutConnections;
|
||||
std::vector<SLink> mInConnections;
|
||||
CPropertyStruct *mpProperties;
|
||||
|
||||
CStringProperty *mpInstanceName;
|
||||
CVector3Property *mpPosition;
|
||||
CVector3Property *mpRotation;
|
||||
CVector3Property *mpScale;
|
||||
CBoolProperty *mpActive;
|
||||
CPropertyStruct *mpLightParameters;
|
||||
TResPtr<CModel> mpDisplayModel;
|
||||
TResPtr<CTexture> mpBillboard;
|
||||
TResPtr<CCollisionMeshGroup> mpCollision;
|
||||
bool mHasInGameModel;
|
||||
|
||||
EVolumeShape mVolumeShape;
|
||||
|
||||
public:
|
||||
CScriptObject(CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate);
|
||||
~CScriptObject();
|
||||
|
||||
void CopyFromTemplate(CScriptTemplate *pTemp, u32 propCount);
|
||||
void EvaluateProperties();
|
||||
void EvaluateDisplayModel();
|
||||
void EvaluateBillboard();
|
||||
void EvaluateCollisionModel();
|
||||
|
||||
CScriptTemplate* Template() const;
|
||||
CMasterTemplate* MasterTemplate() const;
|
||||
CGameArea* Area() const;
|
||||
CScriptLayer* Layer() const;
|
||||
CPropertyStruct* Properties() const;
|
||||
u32 NumProperties() const;
|
||||
CPropertyBase* PropertyByIndex(u32 index) const;
|
||||
CPropertyBase* PropertyByIDString(const TIDString& str) const;
|
||||
u32 ObjectTypeID() const;
|
||||
u32 InstanceID() const;
|
||||
u32 NumInLinks() const;
|
||||
u32 NumOutLinks() const;
|
||||
const SLink& InLink(u32 index) const;
|
||||
const SLink& OutLink(u32 index) const;
|
||||
|
||||
CVector3f Position() const;
|
||||
CVector3f Rotation() const;
|
||||
CVector3f Scale() const;
|
||||
TString InstanceName() const;
|
||||
bool IsActive() const;
|
||||
bool HasInGameModel() const;
|
||||
void SetPosition(const CVector3f& newPos);
|
||||
void SetRotation(const CVector3f& newRot);
|
||||
void SetScale(const CVector3f& newScale);
|
||||
void SetName(const TString& newName);
|
||||
void SetActive(bool isActive);
|
||||
CPropertyStruct* LightParameters() const;
|
||||
CModel* GetDisplayModel() const;
|
||||
CTexture* GetBillboard() const;
|
||||
CCollisionMeshGroup* GetCollision() const;
|
||||
EVolumeShape VolumeShape() const;
|
||||
};
|
||||
|
||||
#endif // CSCRIPTOBJECT_H
|
||||
402
src/Core/Resource/Script/CScriptTemplate.cpp
Normal file
402
src/Core/Resource/Script/CScriptTemplate.cpp
Normal file
@@ -0,0 +1,402 @@
|
||||
#include "CScriptTemplate.h"
|
||||
#include "CScriptObject.h"
|
||||
#include "CMasterTemplate.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <Core/Log.h>
|
||||
#include <Core/CResCache.h>
|
||||
#include <Resource/CAnimSet.h>
|
||||
|
||||
CScriptTemplate::CScriptTemplate(CMasterTemplate *pMaster)
|
||||
{
|
||||
mpMaster = pMaster;
|
||||
mVisible = true;
|
||||
mPreviewScale = 1.f;
|
||||
mVolumeShape = eNoShape;
|
||||
}
|
||||
|
||||
CScriptTemplate::~CScriptTemplate()
|
||||
{
|
||||
for (u32 iSet = 0; iSet < mPropertySets.size(); iSet++)
|
||||
delete mPropertySets[iSet].pBaseStruct;
|
||||
}
|
||||
|
||||
CMasterTemplate* CScriptTemplate::MasterTemplate()
|
||||
{
|
||||
return mpMaster;
|
||||
}
|
||||
|
||||
EGame CScriptTemplate::Game()
|
||||
{
|
||||
return mpMaster->GetGame();
|
||||
}
|
||||
|
||||
TString CScriptTemplate::TemplateName(s32 propCount) const
|
||||
{
|
||||
// Return original name if there is only one property set
|
||||
// or if caller doesn't want to distinguish between sets
|
||||
if ((NumPropertySets() == 1) || (propCount == -1))
|
||||
return mTemplateName;
|
||||
|
||||
// Otherwise we return the template name with the set name appended
|
||||
for (auto it = mPropertySets.begin(); it != mPropertySets.end(); it++)
|
||||
if (it->pBaseStruct->Count() == propCount)
|
||||
return mTemplateName + " (" + it->SetName + ")";
|
||||
|
||||
return mTemplateName + " (Invalid)";
|
||||
}
|
||||
|
||||
TString CScriptTemplate::PropertySetNameByCount(s32 propCount) const
|
||||
{
|
||||
for (auto it = mPropertySets.begin(); it != mPropertySets.end(); it++)
|
||||
if (it->pBaseStruct->Count() == propCount)
|
||||
return it->SetName;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
TString CScriptTemplate::PropertySetNameByIndex(u32 index) const
|
||||
{
|
||||
if (index < NumPropertySets())
|
||||
return mPropertySets[index].SetName;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
u32 CScriptTemplate::NumPropertySets() const
|
||||
{
|
||||
return mPropertySets.size();
|
||||
}
|
||||
|
||||
CScriptTemplate::ERotationType CScriptTemplate::RotationType() const
|
||||
{
|
||||
return mRotationType;
|
||||
}
|
||||
|
||||
CScriptTemplate::EScaleType CScriptTemplate::ScaleType() const
|
||||
{
|
||||
return mScaleType;
|
||||
}
|
||||
|
||||
float CScriptTemplate::PreviewScale() const
|
||||
{
|
||||
return mPreviewScale;
|
||||
}
|
||||
|
||||
u32 CScriptTemplate::ObjectID() const
|
||||
{
|
||||
return mObjectID;
|
||||
}
|
||||
|
||||
void CScriptTemplate::SetVisible(bool visible)
|
||||
{
|
||||
mVisible = visible;
|
||||
}
|
||||
|
||||
bool CScriptTemplate::IsVisible() const
|
||||
{
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
void CScriptTemplate::DebugPrintProperties(int propCount)
|
||||
{
|
||||
CStructTemplate *pTemp = BaseStructByCount(propCount);
|
||||
if (pTemp) pTemp->DebugPrintProperties("");
|
||||
}
|
||||
|
||||
// ************ PROPERTY FETCHING ************
|
||||
template<typename t, EPropertyType propType>
|
||||
t TFetchProperty(CPropertyStruct *pProperties, const TIDString& ID)
|
||||
{
|
||||
if (ID.IsEmpty()) return nullptr;
|
||||
CPropertyBase *pProp = pProperties->PropertyByIDString(ID);
|
||||
|
||||
if (pProp && (pProp->Type() == propType))
|
||||
return static_cast<t>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStructTemplate* CScriptTemplate::BaseStructByCount(s32 propCount)
|
||||
{
|
||||
if (mPropertySets.size() == 1) return mPropertySets[0].pBaseStruct;
|
||||
|
||||
for (u32 iSet = 0; iSet < mPropertySets.size(); iSet++)
|
||||
if (mPropertySets[iSet].pBaseStruct->Count() == propCount)
|
||||
return mPropertySets[iSet].pBaseStruct;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStructTemplate* CScriptTemplate::BaseStructByIndex(u32 index)
|
||||
{
|
||||
if (index < NumPropertySets())
|
||||
return mPropertySets[index].pBaseStruct;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
{
|
||||
if (pObj->Template() != this)
|
||||
{
|
||||
Log::Error(pObj->Template()->TemplateName() + " instance somehow called VolumeShape() on " + TemplateName() + " template");
|
||||
return eInvalidShape;
|
||||
}
|
||||
|
||||
if (mVolumeShape == eConditionalShape)
|
||||
{
|
||||
CPropertyBase *pProp = pObj->Properties()->PropertyByIDString(mVolumeConditionIDString);
|
||||
|
||||
// Get value of the condition test property (only boolean, integral, and enum types supported)
|
||||
int v;
|
||||
switch (pProp->Type())
|
||||
{
|
||||
case eBoolProperty:
|
||||
v = (static_cast<CBoolProperty*>(pProp)->Get() ? 1 : 0);
|
||||
break;
|
||||
|
||||
case eByteProperty:
|
||||
v = (int) static_cast<CByteProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eShortProperty:
|
||||
v = (int) static_cast<CShortProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eLongProperty:
|
||||
v = (int) static_cast<CLongProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eEnumProperty: {
|
||||
CEnumProperty *pEnumCast = static_cast<CEnumProperty*>(pProp);
|
||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pEnumCast->Template());
|
||||
int index = static_cast<CEnumProperty*>(pProp)->Get();
|
||||
v = pEnumTemp->EnumeratorID(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Test and check whether any of the conditions are true
|
||||
for (auto it = mVolumeConditions.begin(); it != mVolumeConditions.end(); it++)
|
||||
{
|
||||
if (it->Value == v)
|
||||
return it->Shape;
|
||||
}
|
||||
|
||||
Log::Error(TemplateName() + " instance " + TString::HexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + TString::HexString((u32) v, true, true));
|
||||
return eInvalidShape;
|
||||
}
|
||||
|
||||
else return mVolumeShape;
|
||||
}
|
||||
|
||||
CStringProperty* CScriptTemplate::FindInstanceName(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CStringProperty*, eStringProperty>(pProperties, mNameIDString);
|
||||
}
|
||||
|
||||
CVector3Property* CScriptTemplate::FindPosition(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CVector3Property*, eVector3Property>(pProperties, mPositionIDString);
|
||||
}
|
||||
|
||||
CVector3Property* CScriptTemplate::FindRotation(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CVector3Property*, eVector3Property>(pProperties, mRotationIDString);
|
||||
}
|
||||
|
||||
CVector3Property* CScriptTemplate::FindScale(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CVector3Property*, eVector3Property>(pProperties, mScaleIDString);
|
||||
}
|
||||
|
||||
CBoolProperty* CScriptTemplate::FindActive(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CBoolProperty*, eBoolProperty>(pProperties, mActiveIDString);
|
||||
}
|
||||
|
||||
CPropertyStruct* CScriptTemplate::FindLightParameters(CPropertyStruct *pProperties)
|
||||
{
|
||||
return TFetchProperty<CPropertyStruct*, eStructProperty>(pProperties, mLightParametersIDString);
|
||||
}
|
||||
|
||||
// todo: merge these four functions, they have near-identical code
|
||||
CModel* CScriptTemplate::FindDisplayModel(CPropertyStruct *pProperties)
|
||||
{
|
||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||
{
|
||||
if ((it->AssetType != SEditorAsset::eModel) && (it->AssetType != SEditorAsset::eAnimParams)) continue;
|
||||
CResource *pRes = nullptr;
|
||||
|
||||
// File
|
||||
if (it->AssetSource == SEditorAsset::eFile)
|
||||
{
|
||||
TString path = "../resources/" + it->AssetLocation;
|
||||
pRes = gResCache.GetResource(path);
|
||||
}
|
||||
|
||||
// Property
|
||||
else
|
||||
{
|
||||
CPropertyBase *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
||||
|
||||
if (pProp->Type() == eFileProperty)
|
||||
{
|
||||
CFileProperty *pFile = static_cast<CFileProperty*>(pProp);
|
||||
pRes = pFile->Get();
|
||||
}
|
||||
|
||||
else if (pProp->Type() == eAnimParamsProperty)
|
||||
{
|
||||
CAnimParamsProperty *pParams = static_cast<CAnimParamsProperty*>(pProp);
|
||||
pRes = pParams->Get().GetCurrentModel(it->ForceNodeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify resource exists + is correct type
|
||||
if (pRes && (pRes->Type() == eModel))
|
||||
return static_cast<CModel*>(pRes);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CTexture* CScriptTemplate::FindBillboardTexture(CPropertyStruct *pProperties)
|
||||
{
|
||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||
{
|
||||
if (it->AssetType != SEditorAsset::eBillboard) continue;
|
||||
CResource *pRes = nullptr;
|
||||
|
||||
// File
|
||||
if (it->AssetSource == SEditorAsset::eFile)
|
||||
{
|
||||
TString path = "../resources/" + it->AssetLocation;
|
||||
pRes = gResCache.GetResource(path);
|
||||
}
|
||||
|
||||
// Property
|
||||
else
|
||||
{
|
||||
CPropertyBase *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
||||
|
||||
if (pProp->Type() == eFileProperty)
|
||||
{
|
||||
CFileProperty *pFile = static_cast<CFileProperty*>(pProp);
|
||||
pRes = pFile->Get();
|
||||
}
|
||||
}
|
||||
|
||||
// Verify resource exists + is correct type
|
||||
if (pRes && (pRes->Type() == eTexture))
|
||||
return static_cast<CTexture*>(pRes);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties)
|
||||
{
|
||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||
{
|
||||
if (it->AssetType != SEditorAsset::eCollision) continue;
|
||||
CResource *pRes = nullptr;
|
||||
|
||||
// File
|
||||
if (it->AssetSource == SEditorAsset::eFile)
|
||||
{
|
||||
TString path = "../resources/" + it->AssetLocation;
|
||||
pRes = gResCache.GetResource(path);
|
||||
}
|
||||
|
||||
// Property
|
||||
else
|
||||
{
|
||||
CPropertyBase *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
||||
|
||||
if (pProp->Type() == eFileProperty)
|
||||
{
|
||||
CFileProperty *pFile = static_cast<CFileProperty*>(pProp);
|
||||
pRes = pFile->Get();
|
||||
}
|
||||
}
|
||||
|
||||
// Verify resource exists + is correct type
|
||||
if (pRes && (pRes->Type() == eCollisionMeshGroup))
|
||||
return static_cast<CCollisionMeshGroup*>(pRes);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CScriptTemplate::HasInGameModel(CPropertyStruct *pProperties)
|
||||
{
|
||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||
{
|
||||
if ((it->AssetType != SEditorAsset::eModel) && (it->AssetType != SEditorAsset::eAnimParams)) continue;
|
||||
if (it->AssetSource == SEditorAsset::eFile) continue;
|
||||
CResource *pRes = nullptr;
|
||||
|
||||
CPropertyBase *pProp = pProperties->PropertyByIDString(it->AssetLocation);
|
||||
|
||||
if (pProp->Type() == eFileProperty)
|
||||
{
|
||||
CFileProperty *pFile = static_cast<CFileProperty*>(pProp);
|
||||
pRes = pFile->Get();
|
||||
}
|
||||
|
||||
else if (pProp->Type() == eAnimParamsProperty)
|
||||
{
|
||||
CAnimParamsProperty *pParams = static_cast<CAnimParamsProperty*>(pProp);
|
||||
pRes = pParams->Get().GetCurrentModel(it->ForceNodeIndex);
|
||||
}
|
||||
|
||||
// Verify resource exists + is correct type
|
||||
if (pRes && (pRes->Type() == eModel))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScriptTemplate::HasPosition()
|
||||
{
|
||||
return (!mPositionIDString.IsEmpty());
|
||||
}
|
||||
|
||||
// ************ OBJECT TRACKING ************
|
||||
u32 CScriptTemplate::NumObjects() const
|
||||
{
|
||||
return mObjectList.size();
|
||||
}
|
||||
|
||||
const std::list<CScriptObject*>& CScriptTemplate::ObjectList() const
|
||||
{
|
||||
return mObjectList;
|
||||
}
|
||||
|
||||
void CScriptTemplate::AddObject(CScriptObject *pObject)
|
||||
{
|
||||
mObjectList.push_back(pObject);
|
||||
}
|
||||
|
||||
void CScriptTemplate::RemoveObject(CScriptObject *pObject)
|
||||
{
|
||||
for (auto it = mObjectList.begin(); it != mObjectList.end(); it++)
|
||||
{
|
||||
if (*it == pObject)
|
||||
{
|
||||
mObjectList.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptTemplate::SortObjects()
|
||||
{
|
||||
// todo: make this function take layer names into account
|
||||
mObjectList.sort([](CScriptObject *pA, CScriptObject *pB) -> bool {
|
||||
return (pA->InstanceID() < pB->InstanceID());
|
||||
});
|
||||
}
|
||||
135
src/Core/Resource/Script/CScriptTemplate.h
Normal file
135
src/Core/Resource/Script/CScriptTemplate.h
Normal file
@@ -0,0 +1,135 @@
|
||||
#ifndef CSCRIPTTEMPLATE_H
|
||||
#define CSCRIPTTEMPLATE_H
|
||||
|
||||
#include "CPropertyTemplate.h"
|
||||
#include "CProperty.h"
|
||||
#include "EPropertyType.h"
|
||||
#include "EVolumeShape.h"
|
||||
#include <Common/CFourCC.h>
|
||||
#include <Common/types.h>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <tinyxml2.h>
|
||||
#include <Resource/model/CModel.h>
|
||||
#include <Resource/CCollisionMeshGroup.h>
|
||||
|
||||
class CMasterTemplate;
|
||||
class CScriptObject;
|
||||
|
||||
typedef TString TIDString;
|
||||
|
||||
/*
|
||||
* CScriptTemplate is a class that encases the data contained in one of the XML templates.
|
||||
* It essentially sets the layout of any given script object.
|
||||
*
|
||||
* It contains any data that applies globally to every instance of the object, such as
|
||||
* property names, editor attribute properties, etc.
|
||||
*/
|
||||
class CScriptTemplate
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
public:
|
||||
enum ERotationType {
|
||||
eRotationEnabled, eRotationDisabled
|
||||
};
|
||||
|
||||
enum EScaleType {
|
||||
eScaleEnabled, eScaleDisabled, eScaleVolume
|
||||
};
|
||||
|
||||
private:
|
||||
struct SPropertySet {
|
||||
TString SetName;
|
||||
CStructTemplate *pBaseStruct;
|
||||
};
|
||||
|
||||
struct SEditorAsset
|
||||
{
|
||||
enum {
|
||||
eModel, eAnimParams, eBillboard, eCollision
|
||||
} AssetType;
|
||||
|
||||
enum {
|
||||
eProperty, eFile
|
||||
} AssetSource;
|
||||
|
||||
TIDString AssetLocation;
|
||||
s32 ForceNodeIndex; // Force animsets to use specific node instead of one from property
|
||||
};
|
||||
|
||||
CMasterTemplate *mpMaster;
|
||||
std::vector<SPropertySet> mPropertySets;
|
||||
std::list<CScriptObject*> mObjectList;
|
||||
TString mTemplateName;
|
||||
TString mSourceFile;
|
||||
u32 mObjectID;
|
||||
bool mVisible;
|
||||
|
||||
// Editor Properties
|
||||
TIDString mNameIDString;
|
||||
TIDString mPositionIDString;
|
||||
TIDString mRotationIDString;
|
||||
TIDString mScaleIDString;
|
||||
TIDString mActiveIDString;
|
||||
TIDString mLightParametersIDString;
|
||||
std::vector<SEditorAsset> mAssets;
|
||||
|
||||
float mPreviewScale;
|
||||
ERotationType mRotationType;
|
||||
EScaleType mScaleType;
|
||||
|
||||
// Preview Volume
|
||||
EVolumeShape mVolumeShape;
|
||||
TIDString mVolumeConditionIDString;
|
||||
|
||||
struct SVolumeCondition {
|
||||
int Value;
|
||||
EVolumeShape Shape;
|
||||
};
|
||||
std::vector<SVolumeCondition> mVolumeConditions;
|
||||
|
||||
public:
|
||||
CScriptTemplate(CMasterTemplate *pMaster);
|
||||
~CScriptTemplate();
|
||||
|
||||
CMasterTemplate* MasterTemplate();
|
||||
EGame Game();
|
||||
TString TemplateName(s32 propCount = -1) const;
|
||||
TString PropertySetNameByCount(s32 propCount) const;
|
||||
TString PropertySetNameByIndex(u32 index) const;
|
||||
u32 NumPropertySets() const;
|
||||
ERotationType RotationType() const;
|
||||
EScaleType ScaleType() const;
|
||||
float PreviewScale() const;
|
||||
u32 ObjectID() const;
|
||||
void SetVisible(bool visible);
|
||||
bool IsVisible() const;
|
||||
void DebugPrintProperties(int propCount = -1);
|
||||
|
||||
// Property Fetching
|
||||
CStructTemplate* BaseStructByCount(s32 propCount);
|
||||
CStructTemplate* BaseStructByIndex(u32 index);
|
||||
EVolumeShape VolumeShape(CScriptObject *pObj);
|
||||
CStringProperty* FindInstanceName(CPropertyStruct *pProperties);
|
||||
CVector3Property* FindPosition(CPropertyStruct *pProperties);
|
||||
CVector3Property* FindRotation(CPropertyStruct *pProperties);
|
||||
CVector3Property* FindScale(CPropertyStruct *pProperties);
|
||||
CBoolProperty* FindActive(CPropertyStruct *pProperties);
|
||||
CPropertyStruct* FindLightParameters(CPropertyStruct *pProperties);
|
||||
CModel* FindDisplayModel(CPropertyStruct *pProperties);
|
||||
CTexture* FindBillboardTexture(CPropertyStruct *pProperties);
|
||||
CCollisionMeshGroup* FindCollision(CPropertyStruct *pProperties);
|
||||
bool HasInGameModel(CPropertyStruct *pProperties);
|
||||
bool HasPosition();
|
||||
|
||||
// Object Tracking
|
||||
u32 NumObjects() const;
|
||||
const std::list<CScriptObject*>& ObjectList() const;
|
||||
void AddObject(CScriptObject *pObject);
|
||||
void RemoveObject(CScriptObject *pObject);
|
||||
void SortObjects();
|
||||
};
|
||||
|
||||
#endif // CSCRIPTTEMPLATE_H
|
||||
130
src/Core/Resource/Script/EObjectType.h
Normal file
130
src/Core/Resource/Script/EObjectType.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifndef EOBJECTTYPE_H
|
||||
#define EOBJECTTYPE_H
|
||||
|
||||
// dunno if this is actually needed, but here it is.
|
||||
enum EObjectType
|
||||
{
|
||||
Actor = 0x0,
|
||||
Waypoint = 0x2,
|
||||
DoorArea = 0x3,
|
||||
Trigger = 0x4,
|
||||
Timer = 0x5,
|
||||
Counter = 0x6,
|
||||
Effect = 0x7,
|
||||
Platform = 0x8,
|
||||
Sound = 0x9,
|
||||
Generator = 0xA,
|
||||
Dock = 0xB,
|
||||
Camera = 0xC,
|
||||
CameraWaypoint = 0xD,
|
||||
NewIntroBoss = 0xE,
|
||||
SpawnPoint = 0xF,
|
||||
CameraHint = 0x10,
|
||||
Pickup = 0x11,
|
||||
MemoryRelay = 0x13,
|
||||
RandomRelay = 0x14,
|
||||
Relay = 0x15,
|
||||
Beetle = 0x16,
|
||||
HUDMemo = 0x17,
|
||||
CameraFilterKeyframe = 0x18,
|
||||
CameraBlurKeyframe = 0x19,
|
||||
DamageableTrigger = 0x1A,
|
||||
Debris = 0x1B,
|
||||
CameraShaker = 0x1C,
|
||||
ActorKeyFrame = 0x1D,
|
||||
Water = 0x20,
|
||||
Warwasp = 0x21,
|
||||
SpacePirate = 0x24,
|
||||
FlyingPirate = 0x25,
|
||||
ElitePirate = 0x26,
|
||||
MetroidBeta = 0x27,
|
||||
ChozoGhost = 0x28,
|
||||
CoverPoint = 0x2A,
|
||||
SpiderBallWaypoint = 0x2C,
|
||||
BloodFlower = 0x2D,
|
||||
FlickerBat = 0x2E,
|
||||
PathCamera = 0x2F,
|
||||
GrapplePoint = 0x30,
|
||||
PuddleSpore = 0x31,
|
||||
SpiderBallAttractionSurface = 0x33,
|
||||
PuddleToadGamma = 0x34,
|
||||
Fog = 0x35,
|
||||
FireFlea = 0x36,
|
||||
MetareeAlpha = 0x37,
|
||||
ActorRotate = 0x39,
|
||||
SpecialFunction = 0x3A,
|
||||
SpankWeed = 0x3B,
|
||||
Zoomer = 0x3D,
|
||||
PlayerHint = 0x3E,
|
||||
Ripper = 0x3F,
|
||||
PickupGenerator = 0x40,
|
||||
PointOfInterest = 0x42,
|
||||
Drone = 0x43,
|
||||
MetroidAlpha = 0x44,
|
||||
DebrisExtended = 0x45,
|
||||
Steam = 0x46,
|
||||
Ripple = 0x47,
|
||||
BallTrigger = 0x48,
|
||||
TargetingPoint = 0x49,
|
||||
ElectroMagneticPulse = 0x4A,
|
||||
IceSheegoth = 0x4B,
|
||||
PlayerActor = 0x4C,
|
||||
Flaahgra = 0x4D,
|
||||
AreaAttributes = 0x4E,
|
||||
FishCloud = 0x4F,
|
||||
FishCloudModifier = 0x50,
|
||||
VisorFlare = 0x51,
|
||||
VisorGoo = 0x53,
|
||||
JellyZap = 0x54,
|
||||
ControllerAction = 0x55,
|
||||
Switch = 0x56,
|
||||
PlayerStateChange = 0x57,
|
||||
Thardus = 0x58,
|
||||
WallCrawlerSwarm = 0x5A,
|
||||
AIJumpPoint = 0x5B,
|
||||
FlaahgraTentacle = 0x5C,
|
||||
RoomAcoustics = 0x5D,
|
||||
ColorModulate = 0x5E,
|
||||
ThardusRockProjectile = 0x5F,
|
||||
Midi = 0x60,
|
||||
StreamedAudio = 0x61,
|
||||
WorldTeleporter = 0x62,
|
||||
Repulsor = 0x63,
|
||||
GunTurret = 0x64,
|
||||
Babygoth = 0x66,
|
||||
Eyeball = 0x67,
|
||||
RadialKnockback = 0x68,
|
||||
CameraPitchVolume = 0x69,
|
||||
EnvFxDensityController = 0x6A,
|
||||
Magdolite = 0x6B,
|
||||
TeamAIMgr = 0x6C,
|
||||
SnakeWeedSwarm = 0x6D,
|
||||
ActorContraption = 0x6E,
|
||||
Oculus = 0x6F,
|
||||
Geemer = 0x70,
|
||||
SpindleCamera = 0x71,
|
||||
AtomicAlpha = 0x72,
|
||||
CameraHintTrigger = 0x73,
|
||||
RumbleEffect = 0x74,
|
||||
AmbientAI = 0x75,
|
||||
AtomicBeta = 0x77,
|
||||
Puffer = 0x79,
|
||||
Tryclops = 0x7A,
|
||||
Ridley = 0x7B,
|
||||
Seedling = 0x7C,
|
||||
ThermalHeatFader = 0x7D,
|
||||
Burrower = 0x7F,
|
||||
ScriptBeam = 0x81,
|
||||
WorldLightFader = 0x82,
|
||||
MetroidPrimeStage2 = 0x83,
|
||||
MetroidPrimeRelay = 0x84,
|
||||
MazeNode = 0x85,
|
||||
OmegaPirate = 0x86,
|
||||
PhazonPool = 0x87,
|
||||
PhazonHealingNodule = 0x88,
|
||||
NewCameraShaker = 0x89,
|
||||
ShadowProjector = 0x8A,
|
||||
BeamEnergyBall = 0x8B
|
||||
};
|
||||
|
||||
#endif // EOBJECTTYPE_H
|
||||
31
src/Core/Resource/Script/EPropertyType.h
Normal file
31
src/Core/Resource/Script/EPropertyType.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef EPROPERTYTYPE
|
||||
#define EPROPERTYTYPE
|
||||
|
||||
#include <Common/TString.h>
|
||||
|
||||
enum EPropertyType
|
||||
{
|
||||
eBoolProperty,
|
||||
eByteProperty,
|
||||
eShortProperty,
|
||||
eLongProperty,
|
||||
eEnumProperty,
|
||||
eBitfieldProperty,
|
||||
eFloatProperty,
|
||||
eStringProperty,
|
||||
eVector3Property,
|
||||
eColorProperty,
|
||||
eFileProperty,
|
||||
eStructProperty,
|
||||
eArrayProperty,
|
||||
eAnimParamsProperty,
|
||||
eUnknownProperty,
|
||||
eInvalidProperty
|
||||
};
|
||||
|
||||
// functions defined in CScriptTemplate.cpp
|
||||
EPropertyType PropStringToPropEnum(const TString& prop);
|
||||
TString PropEnumToPropString(EPropertyType prop);
|
||||
|
||||
#endif // EPROPERTYTYPE
|
||||
|
||||
17
src/Core/Resource/Script/EVolumeShape.h
Normal file
17
src/Core/Resource/Script/EVolumeShape.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef EVOLUMESHAPE
|
||||
#define EVOLUMESHAPE
|
||||
|
||||
enum EVolumeShape
|
||||
{
|
||||
eNoShape,
|
||||
eAxisAlignedBoxShape,
|
||||
eBoxShape,
|
||||
eEllipsoidShape,
|
||||
eCylinderShape,
|
||||
eCylinderLargeShape,
|
||||
eConditionalShape,
|
||||
eInvalidShape
|
||||
};
|
||||
|
||||
#endif // EVOLUMESHAPE
|
||||
|
||||
13
src/Core/Resource/Script/SConnection.h
Normal file
13
src/Core/Resource/Script/SConnection.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SCONNECTION_H
|
||||
#define SCONNECTION_H
|
||||
|
||||
#include <Common/types.h>
|
||||
|
||||
struct SLink
|
||||
{
|
||||
u32 State;
|
||||
u32 Message;
|
||||
u32 ObjectID; // not a pointer because it can refer to objects outside the current area
|
||||
};
|
||||
|
||||
#endif // SCONNECTION_H
|
||||
Reference in New Issue
Block a user