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 {true}
 
StdCopyStrBuf TargetSpec
 
StdCopyStrBuf ScriptFunc
 
C4AulFuncpScriptFunc {nullptr}
 
uint32_t iExecMask
 
bool fReverse {false}
 
bool fInverseSpec {false}
 
bool fInsertionCheck {true}
 
int32_t iDepth {0}
 
StdCopyStrBuf sConvertMat
 
int32_t iConvertMat {-1}
 
int32_t iCorrosionRate {100}
 

Detailed Description

Definition at line 43 of file C4Material.h.

Constructor & Destructor Documentation

C4MaterialReaction::C4MaterialReaction ( C4MaterialReactionFunc  pFunc)
inline

Definition at line 61 of file C4Material.h.

61 : pFunc(pFunc), fUserDefined(false), pScriptFunc(nullptr), iExecMask(~0u) {}
uint32_t iExecMask
Definition: C4Material.h:52
C4MaterialReactionFunc pFunc
Definition: C4Material.h:47
C4AulFunc * pScriptFunc
Definition: C4Material.h:51
C4MaterialReaction::C4MaterialReaction ( )
inline

Definition at line 62 of file C4Material.h.

62 : pFunc(&NoReaction), iExecMask(~0u) { }
uint32_t iExecMask
Definition: C4Material.h:52
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:45
C4MaterialReactionFunc pFunc
Definition: C4Material.h:47

Member Function Documentation

void C4MaterialReaction::CompileFunc ( StdCompiler pComp)

Definition at line 55 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().

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

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 45 of file C4Material.h.

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

Definition at line 68 of file C4Material.h.

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

Definition at line 78 of file C4Material.cpp.

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

79 {
80  // get script func for script-defined behaviour
82  {
84  if (!pScriptFunc)
85  DebugLogF(R"(Error getting function "%s" for Material reaction of "%s")", this->ScriptFunc.getData(), szMatName);
86  }
87  else
88  pScriptFunc = nullptr;
89 }
const char * getData() const
Definition: StdBuf.h:442
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4MaterialReactionFunc pFunc
Definition: C4Material.h:47
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:288
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:935
StdCopyStrBuf ScriptFunc
Definition: C4Material.h:50
C4AulFunc * pScriptFunc
Definition: C4Material.h:51

Here is the call graph for this function:

Member Data Documentation

bool C4MaterialReaction::fInsertionCheck {true}

Definition at line 55 of file C4Material.h.

Referenced by CompileFunc(), and mrfUserCheck().

bool C4MaterialReaction::fInverseSpec {false}

Definition at line 54 of file C4Material.h.

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

bool C4MaterialReaction::fReverse {false}

Definition at line 53 of file C4Material.h.

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

bool C4MaterialReaction::fUserDefined {true}
int32_t C4MaterialReaction::iConvertMat {-1}

Definition at line 58 of file C4Material.h.

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

int32_t C4MaterialReaction::iCorrosionRate {100}

Definition at line 59 of file C4Material.h.

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

int32_t C4MaterialReaction::iDepth {0}

Definition at line 56 of file C4Material.h.

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

uint32_t C4MaterialReaction::iExecMask

Definition at line 52 of file C4Material.h.

Referenced by CompileFunc(), and mrfUserCheck().

C4AulFunc* C4MaterialReaction::pScriptFunc {nullptr}

Definition at line 51 of file C4Material.h.

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

StdCopyStrBuf C4MaterialReaction::sConvertMat

Definition at line 57 of file C4Material.h.

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

StdCopyStrBuf C4MaterialReaction::ScriptFunc

Definition at line 50 of file C4Material.h.

Referenced by CompileFunc(), and ResolveScriptFuncs().

StdCopyStrBuf C4MaterialReaction::TargetSpec

Definition at line 49 of file C4Material.h.

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


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