MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / replaceBehaviorTag

Function replaceBehaviorTag

source/game/StarBehaviorDatabase.cpp:83–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83NodeParameterValue replaceBehaviorTag(NodeParameterValue const& parameter, StringMap<NodeParameterValue> const& treeParameters) {
84 Maybe<String> strVal = parameter.maybe<String>();
85 if (!strVal && parameter.get<Json>().isType(Json::Type::String))
86 strVal = parameter.get<Json>().toString();
87 if (strVal) {
88 String key = *strVal;
89 if (key.beginsWith('<') && key.endsWith('>')) {
90 String treeKey = key.substr(1, key.size() - 2);
91
92 if (auto replace = treeParameters.maybe(treeKey)) {
93 return *replace;
94 } else {
95 throw StarException(strf("No parameter specified for tag '{}'", key));
96 }
97 }
98 }
99 return parameter;
100}
101
102Maybe<String> replaceOutputBehaviorTag(Maybe<String> const& output, StringMap<NodeParameterValue> const& treeParameters) {
103 if (auto out = output) {

Callers 2

applyTreeParametersFunction · 0.85
behaviorNodeMethod · 0.85

Calls 9

StarExceptionClass · 0.85
strfFunction · 0.85
isTypeMethod · 0.45
toStringMethod · 0.45
beginsWithMethod · 0.45
endsWithMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
maybeMethod · 0.45

Tested by

no test coverage detected