OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MaterialReaction Struct Reference

#include <C4Material.h>

Collaboration diagram for C4MaterialReaction:
[legend]

Public Member Functions

 C4MaterialReaction (C4MaterialReactionFunc pFunc)
 
 C4MaterialReaction ()
 
void CompileFunc (StdCompiler *pComp)
 
void ResolveScriptFuncs (const char *szMatName)
 
bool operator== (const C4MaterialReaction &rCmp) const
 

Static Public Member Functions

static bool NoReaction (struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 

Public Attributes

C4MaterialReactionFunc pFunc
 
bool fUserDefined
 
StdCopyStrBuf TargetSpec
 
StdCopyStrBuf ScriptFunc
 
C4AulFuncpScriptFunc
 
uint32_t iExecMask
 
bool fReverse
 
bool fInverseSpec
 
bool fInsertionCheck
 
int32_t iDepth
 
StdCopyStrBuf sConvertMat
 
int32_t iConvertMat
 
int32_t iCorrosionRate
 

Detailed Description

Definition at line 45 of file C4Material.h.

Constructor & Destructor Documentation

C4MaterialReaction::C4MaterialReaction ( C4MaterialReactionFunc  pFunc)
inline

Definition at line 63 of file C4Material.h.

63 : pFunc(pFunc), fUserDefined(false), pScriptFunc(nullptr), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) {}
uint32_t iExecMask
Definition: C4Material.h:54
C4MaterialReactionFunc pFunc
Definition: C4Material.h:49
C4AulFunc * pScriptFunc
Definition: C4Material.h:53
int32_t iConvertMat
Definition: C4Material.h:60
int32_t iCorrosionRate
Definition: C4Material.h:61
C4MaterialReaction::C4MaterialReaction ( )
inline

Definition at line 64 of file C4Material.h.

64 : pFunc(&NoReaction), fUserDefined(true), pScriptFunc(nullptr), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) { }
uint32_t iExecMask
Definition: C4Material.h:54
static bool NoReaction(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.h:47
C4MaterialReactionFunc pFunc
Definition: C4Material.h:49
C4AulFunc * pScriptFunc
Definition: C4Material.h:53
int32_t iConvertMat
Definition: C4Material.h:60
int32_t iCorrosionRate
Definition: C4Material.h:61

Member Function Documentation

void C4MaterialReaction::CompileFunc ( StdCompiler pComp)

Definition at line 56 of file C4Material.cpp.

References fInsertionCheck, fInverseSpec, fReverse, StdStrBuf::getData(), iCorrosionRate, iDepth, iExecMask, StdCompiler::isDeserializer(), mkNamingAdapt(), mkParAdapt(), ReactionFuncMapEntry::pFunc, pFunc, pScriptFunc, StdCompiler::RCT_All, StdCompiler::RCT_IdtfAllowEmpty, sConvertMat, ScriptFunc, SEqual(), ReactionFuncMapEntry::szRFName, TargetSpec, and StdCompiler::Value().

57 {
58  if (pComp->isDeserializer()) pScriptFunc = nullptr;
59  // compile reaction func ptr
60  StdStrBuf sReactionFuncName;
61  int32_t i=0; while (ReactionFuncMap[i].szRFName && (ReactionFuncMap[i].pFunc != pFunc)) ++i;
62  sReactionFuncName = ReactionFuncMap[i].szRFName;
63  pComp->Value(mkNamingAdapt(mkParAdapt(sReactionFuncName, StdCompiler::RCT_IdtfAllowEmpty), "Type", StdCopyStrBuf() ));
64  i=0; while (ReactionFuncMap[i].szRFName && !SEqual(ReactionFuncMap[i].szRFName, sReactionFuncName.getData())) ++i;
66  // compile the rest
69  pComp->Value(mkNamingAdapt(iExecMask, "ExecMask", ~0u ));
70  pComp->Value(mkNamingAdapt(fReverse, "Reverse", false ));
71  pComp->Value(mkNamingAdapt(fInverseSpec, "InverseSpec", false ));
72  pComp->Value(mkNamingAdapt(fInsertionCheck, "CheckSlide", true ));
73  pComp->Value(mkNamingAdapt(iDepth, "Depth", 0 ));
75  pComp->Value(mkNamingAdapt(iCorrosionRate, "CorrosionRate", 100 ));
76 }
const char * getData() const
Definition: StdBuf.h:450
StdCopyStrBuf TargetSpec
Definition: C4Material.h:51
uint32_t iExecMask
Definition: C4Material.h:54
C4MaterialReactionFunc pFunc
Definition: C4Material.cpp:43
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
StdCopyStrBuf sConvertMat
Definition: C4Material.h:59
C4MaterialReactionFunc pFunc
Definition: C4Material.h:49
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
StdCopyStrBuf ScriptFunc
Definition: C4Material.h:52
void Value(const T &rStruct)
Definition: StdCompiler.h:171
C4AulFunc * pScriptFunc
Definition: C4Material.h:53
virtual bool isDeserializer()
Definition: StdCompiler.h:63
const char * szRFName
Definition: C4Material.cpp:43
const ReactionFuncMapEntry ReactionFuncMap[]
Definition: C4Material.cpp:45
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
int32_t iCorrosionRate
Definition: C4Material.h:61

Here is the call graph for this function:

static bool C4MaterialReaction::NoReaction ( struct C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
inlinestatic

Definition at line 47 of file C4Material.h.

47 { return false; }
bool C4MaterialReaction::operator== ( const C4MaterialReaction rCmp) const
inline

Definition at line 70 of file C4Material.h.

70 { return false; } // never actually called; only comparing with empty vector of C4MaterialReactions
void C4MaterialReaction::ResolveScriptFuncs ( const char *  szMatName)

Definition at line 79 of file C4Material.cpp.

References DebugLogF(), StdStrBuf::getData(), C4PropList::GetFunc(), C4AulScriptEngine::GetPropList(), C4MaterialMap::mrfScript(), pFunc, pScriptFunc, ScriptEngine, and ScriptFunc.

80 {
81  // get script func for script-defined behaviour
83  {
85  if (!pScriptFunc)
86  DebugLogF("Error getting function \"%s\" for Material reaction of \"%s\"", this->ScriptFunc.getData(), szMatName);
87  }
88  else
89  pScriptFunc = nullptr;
90 }
const char * getData() const
Definition: StdBuf.h:450
C4PropListStatic * GetPropList()
Definition: C4Aul.h:153
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:107
C4MaterialReactionFunc pFunc
Definition: C4Material.h:49
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:281
static bool mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:931
StdCopyStrBuf ScriptFunc
Definition: C4Material.h:52
C4AulFunc * pScriptFunc
Definition: C4Material.h:53

Here is the call graph for this function:

Member Data Documentation

bool C4MaterialReaction::fInsertionCheck

Definition at line 57 of file C4Material.h.

Referenced by CompileFunc(), and mrfUserCheck().

bool C4MaterialReaction::fInverseSpec

Definition at line 56 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::CrossMapMaterials().

bool C4MaterialReaction::fReverse

Definition at line 55 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::SetMatReaction().

int32_t C4MaterialReaction::iConvertMat

Definition at line 60 of file C4Material.h.

Referenced by C4MaterialMap::CrossMapMaterials(), and C4MaterialMap::mrfConvert().

int32_t C4MaterialReaction::iCorrosionRate

Definition at line 61 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::mrfCorrode().

int32_t C4MaterialReaction::iDepth

Definition at line 58 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::mrfConvert().

uint32_t C4MaterialReaction::iExecMask

Definition at line 54 of file C4Material.h.

Referenced by CompileFunc(), and mrfUserCheck().

C4AulFunc* C4MaterialReaction::pScriptFunc

Definition at line 53 of file C4Material.h.

Referenced by CompileFunc(), C4MaterialMap::mrfScript(), and ResolveScriptFuncs().

StdCopyStrBuf C4MaterialReaction::sConvertMat

Definition at line 59 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::CrossMapMaterials().

StdCopyStrBuf C4MaterialReaction::ScriptFunc

Definition at line 52 of file C4Material.h.

Referenced by CompileFunc(), and ResolveScriptFuncs().

StdCopyStrBuf C4MaterialReaction::TargetSpec

Definition at line 51 of file C4Material.h.

Referenced by CompileFunc(), and C4MaterialMap::CrossMapMaterials().


The documentation for this struct was generated from the following files: