| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465 |
- #include "JsonExpression.h"
- #include "Dimension.h"
- #include "DimensionGenerator.h"
- #include "Game.h"
- JExpressionMemory::JExpressionMemory()
- : ReferenceCounter(),
- currentChunk(0)
- {}
- JExpressionMemory::~JExpressionMemory()
- {
- if (currentChunk) currentChunk->release();
- }
- void JExpressionMemory::lock()
- {
- cs.lock();
- }
- void JExpressionMemory::unlock()
- {
- cs.unlock();
- }
- float JExpressionMemory::getNoise(
- Framework::Text name, float x, float y, float z) const
- {
- Noise* currentNoise = noises.z(name, name.getLength());
- if (currentNoise)
- return (float)currentNoise->getNoise((double)x, (double)y, (double)z);
- return 0.f;
- }
- Noise* JExpressionMemory::zNoiseP(Framework::Text name)
- {
- return noises.z(name, name.getLength());
- }
- void JExpressionMemory::setNoise(Framework::Text name, Noise* noise)
- {
- noises.set(name, name.getLength(), noise);
- }
- void JExpressionMemory::setCurrentChunk(Chunk* chunk)
- {
- if (currentChunk) currentChunk->release();
- currentChunk = chunk;
- }
- float JExpressionMemory::getFloatVariable(const Framework::Text& name) const
- {
- return floatVariables.get(name, name.getLength());
- }
- float* JExpressionMemory::getFloatVariableP(const Framework::Text& name)
- {
- if (!floatVariables.contains(name, name.getLength()))
- {
- floatVariables.set(name, name.getLength(), 0.f);
- }
- return floatVariables.getP(name, name.getLength());
- }
- void JExpressionMemory::setFloatVariable(
- const Framework::Text& name, float value)
- {
- floatVariables.set(name, name.getLength(), value);
- }
- bool JExpressionMemory::getBoolVariable(const Framework::Text& name) const
- {
- return boolVariables.get(name, name.getLength());
- }
- bool* JExpressionMemory::getBoolVariableP(const Framework::Text& name)
- {
- if (!boolVariables.contains(name, name.getLength()))
- {
- boolVariables.set(name, name.getLength(), 0);
- }
- return boolVariables.getP(name, name.getLength());
- }
- void JExpressionMemory::setBoolVariable(const Framework::Text& name, bool value)
- {
- return boolVariables.set(name, name.getLength(), value);
- }
- Chunk* JExpressionMemory::zCurrentChunk()
- {
- return currentChunk;
- }
- Chunk** JExpressionMemory::zzCurrentChunk()
- {
- return ¤tChunk;
- }
- JFloatExpression::JFloatExpression()
- : ReferenceCounter(),
- compiled(0)
- {}
- float JFloatExpression::getValue(JExpressionMemory* zMemory)
- {
- FloatFunc func = compile(zMemory);
- float result = func();
- /* float old = getValueOld(zMemory);
- if (result != old)
- {
- float x = func();
- Framework::Logging::debug() << "fehler" << x << " != " << old;
- }*/
- return result;
- }
- FloatFunc JFloatExpression::compile(JExpressionMemory* zMemory)
- {
- if (compiled)
- {
- if (zMemory != memory)
- {
- throw "Cannot compile the same expression for different memories";
- }
- return compiled;
- }
- memory = zMemory;
- return compiled = buildAssembly(zMemory).compileToFunction<FloatFunc>();
- }
- JBoolExpression::JBoolExpression()
- : ReferenceCounter(),
- compiled(0)
- {}
- bool JBoolExpression::getValue(JExpressionMemory* zMemory)
- {
- bool result = compile(zMemory)();
- /* bool old = getValueOld(zMemory);
- if (result != old)
- {
- Framework::Logging::debug() << "fehler";
- }*/
- return result;
- }
- BoolFunc JBoolExpression::compile(JExpressionMemory* zMemory)
- {
- if (compiled)
- {
- if (zMemory != memory)
- {
- throw "Cannot compile the same expression for different "
- "memories";
- }
- return compiled;
- }
- memory = zMemory;
- return compiled = buildAssembly(zMemory).compileToFunction<BoolFunc>();
- }
- JVariableFloatExpression::JVariableFloatExpression()
- : JFloatExpression()
- {}
- float JVariableFloatExpression::getValueOld(JExpressionMemory* zMemory)
- {
- return zMemory->getFloatVariable(name);
- }
- Framework::Assembly::AssemblyBlock& JVariableFloatExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- codeBlock.addLoadValue(
- zMemory->getFloatVariableP(name), Framework::Assembly::MM0);
- return codeBlock;
- }
- void JVariableFloatExpression::setName(Framework::Text name)
- {
- this->name = name;
- }
- Framework::Text JVariableFloatExpression::getName() const
- {
- return name;
- }
- JVariableFloatExpressionFactory::JVariableFloatExpressionFactory()
- : SubTypeFactory()
- {}
- JVariableFloatExpression* JVariableFloatExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JVariableFloatExpression* result = new JVariableFloatExpression();
- result->setName(zJson->zValue("name")->asString()->getString());
- return result;
- }
- Framework::JSON::JSONObject* JVariableFloatExpressionFactory::toJsonObject(
- JVariableFloatExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "name", new Framework::JSON::JSONString(zObject->getName()));
- return result;
- }
- JSONObjectValidationBuilder* JVariableFloatExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("name")->finishString();
- }
- const char* JVariableFloatExpressionFactory::getTypeToken() const
- {
- return "variable";
- }
- JVariableBoolExpression::JVariableBoolExpression()
- : JBoolExpression()
- {}
- bool JVariableBoolExpression::getValueOld(JExpressionMemory* zMemory)
- {
- return zMemory->getBoolVariable(name);
- }
- Framework::Assembly::AssemblyBlock& JVariableBoolExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- codeBlock.addLoadValue(
- (char*)zMemory->getBoolVariableP(name), Framework::Assembly::RAX);
- return codeBlock;
- }
- void JVariableBoolExpression::setName(Framework::Text name)
- {
- this->name = name;
- }
- Framework::Text JVariableBoolExpression::getName() const
- {
- return name;
- }
- JVariableBoolExpressionFactory::JVariableBoolExpressionFactory()
- : SubTypeFactory()
- {}
- JVariableBoolExpression* JVariableBoolExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JVariableBoolExpression* result = new JVariableBoolExpression();
- result->setName(zJson->zValue("name")->asString()->getString());
- return result;
- }
- Framework::JSON::JSONObject* JVariableBoolExpressionFactory::toJsonObject(
- JVariableBoolExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "name", new Framework::JSON::JSONString(zObject->getName()));
- return result;
- }
- JSONObjectValidationBuilder* JVariableBoolExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("name")->finishString();
- }
- const char* JVariableBoolExpressionFactory::getTypeToken() const
- {
- return "variable";
- }
- JConstantFloatExpression::JConstantFloatExpression()
- : JFloatExpression(),
- value(0)
- {}
- float JConstantFloatExpression::getValueOld(JExpressionMemory* zMemory)
- {
- return value;
- }
- Framework::Assembly::AssemblyBlock& JConstantFloatExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- codeBlock.addLoadValue(&value, Framework::Assembly::MM0);
- return codeBlock;
- }
- void JConstantFloatExpression::setValue(float value)
- {
- this->value = value;
- }
- float JConstantFloatExpression::getValue() const
- {
- return value;
- }
- JConstantFloatExpressionFactory::JConstantFloatExpressionFactory()
- : SubTypeFactory()
- {}
- JConstantFloatExpression* JConstantFloatExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JConstantFloatExpression* result = new JConstantFloatExpression();
- result->setValue((float)zJson->zValue("value")->asNumber()->getNumber());
- return result;
- }
- Framework::JSON::JSONObject* JConstantFloatExpressionFactory::toJsonObject(
- JConstantFloatExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "value", new Framework::JSON::JSONNumber(zObject->getValue()));
- return result;
- }
- JSONObjectValidationBuilder* JConstantFloatExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredNumber("value")->finishNumber();
- }
- const char* JConstantFloatExpressionFactory::getTypeToken() const
- {
- return "constant";
- }
- JConstantBoolExpression::JConstantBoolExpression()
- : JBoolExpression()
- {}
- bool JConstantBoolExpression::getValueOld(JExpressionMemory* zMemory)
- {
- return value;
- }
- Framework::Assembly::AssemblyBlock& JConstantBoolExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)(value ? 1 : 0));
- return codeBlock;
- }
- void JConstantBoolExpression::setValue(bool value)
- {
- this->value = value;
- }
- bool JConstantBoolExpression::getValue() const
- {
- return value;
- }
- JConstantBoolExpressionFactory::JConstantBoolExpressionFactory()
- : SubTypeFactory()
- {}
- JConstantBoolExpression* JConstantBoolExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JConstantBoolExpression* result = new JConstantBoolExpression();
- result->setValue(zJson->zValue("value")->asBool()->getBool());
- return result;
- }
- Framework::JSON::JSONObject* JConstantBoolExpressionFactory::toJsonObject(
- JConstantBoolExpression* zObject) const
- {
- Framework::JSON::JSONObject* zResult = new Framework::JSON::JSONObject();
- zResult->addValue(
- "value", new Framework::JSON::JSONBool(zObject->getValue()));
- return zResult;
- }
- JSONObjectValidationBuilder* JConstantBoolExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredBool("value")->finishBool();
- }
- const char* JConstantBoolExpressionFactory::getTypeToken() const
- {
- return "constant";
- }
- JNoiseFloatExpression::JNoiseFloatExpression()
- : JFloatExpression(),
- x(0),
- y(0),
- z(0)
- {}
- JNoiseFloatExpression::~JNoiseFloatExpression()
- {
- if (x) x->release();
- if (y) y->release();
- if (z) z->release();
- }
- float JNoiseFloatExpression::getValueOld(JExpressionMemory* zMemory)
- {
- return zMemory->getNoise(name,
- x->getValueOld(zMemory),
- y->getValueOld(zMemory),
- z->getValueOld(zMemory));
- }
- Framework::Assembly::AssemblyBlock& JNoiseFloatExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- Noise* noise = zMemory->zNoiseP(name);
- if (!noise)
- {
- Framework::Logging::error() << "no noise with name '" << name.getText()
- << "' found, behavior is undefined\n";
- return codeBlock;
- }
- Framework::Assembly::AssemblyBlock& xBlock = x->buildAssembly(zMemory);
- Framework::Assembly::AssemblyBlock& yBlock = y->buildAssembly(zMemory);
- Framework::Assembly::AssemblyBlock& zBlock = z->buildAssembly(zMemory);
- Framework::Assembly::FPRegister xTarget = Framework::Assembly::MM0;
- if (xBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM1))
- {
- xBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM1);
- xTarget = Framework::Assembly::MM1;
- }
- Framework::Assembly::FPRegister yTarget = Framework::Assembly::MM0;
- if (yBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM2))
- {
- yBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM2);
- yTarget = Framework::Assembly::MM2;
- }
- Framework::Assembly::FPRegister zTarget = Framework::Assembly::MM0;
- if (zBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM3))
- {
- zBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM3);
- zTarget = Framework::Assembly::MM3;
- }
- codeBlock.addBlock(&zBlock, {}, {}, {}, 0, &zTarget);
- if (zTarget != Framework::Assembly::MM3)
- {
- codeBlock.addMoveValue(Framework::Assembly::MM3,
- zTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- codeBlock.addBlock(&yBlock,
- {},
- {Framework::Assembly::MM3},
- {Framework::Assembly::SINGLE_FLOAT},
- 0,
- &yTarget);
- if (yTarget != Framework::Assembly::MM2)
- {
- codeBlock.addMoveValue(Framework::Assembly::MM2,
- yTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- codeBlock.addBlock(&xBlock,
- {},
- {Framework::Assembly::MM2, Framework::Assembly::MM3},
- {Framework::Assembly::SINGLE_FLOAT, Framework::Assembly::SINGLE_FLOAT},
- 0,
- &xTarget);
- if (xTarget != Framework::Assembly::MM1)
- {
- codeBlock.addMoveValue(Framework::Assembly::MM1,
- xTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- codeBlock.addLoadAddress(noise, Framework::Assembly::RCX);
- codeBlock.addMemberCall<float (Noise::*)(float, float, float)>(
- &Noise::getNoise,
- Framework::Assembly::FLOAT_VALUE,
- {Framework::Assembly::RCX},
- {Framework::Assembly::MM1,
- Framework::Assembly::MM2,
- Framework::Assembly::MM3});
- return codeBlock;
- }
- void JNoiseFloatExpression::setName(Framework::Text name)
- {
- this->name = name;
- }
- Framework::Text JNoiseFloatExpression::getName() const
- {
- return name;
- }
- void JNoiseFloatExpression::setX(JFloatExpression* x)
- {
- if (this->x) this->x->release();
- this->x = x;
- }
- JFloatExpression* JNoiseFloatExpression::zX() const
- {
- return x;
- }
- void JNoiseFloatExpression::setY(JFloatExpression* y)
- {
- if (this->y) this->y->release();
- this->y = y;
- }
- JFloatExpression* JNoiseFloatExpression::zY() const
- {
- return y;
- }
- void JNoiseFloatExpression::setZ(JFloatExpression* z)
- {
- if (this->z) this->z->release();
- this->z = z;
- }
- JFloatExpression* JNoiseFloatExpression::zZ() const
- {
- return z;
- }
- JNoiseFloatExpressionFactory::JNoiseFloatExpressionFactory()
- : SubTypeFactory()
- {}
- JNoiseFloatExpression* JNoiseFloatExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JNoiseFloatExpression* result = new JNoiseFloatExpression();
- result->setName(zJson->zValue("name")->asString()->getString());
- result->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("x")));
- result->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("y")));
- result->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("z")));
- return result;
- }
- Framework::JSON::JSONObject* JNoiseFloatExpressionFactory::toJsonObject(
- JNoiseFloatExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "name", new Framework::JSON::JSONString(zObject->getName()));
- result->addValue(
- "x", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zX()));
- result->addValue(
- "y", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zY()));
- result->addValue(
- "z", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zZ()));
- return result;
- }
- JSONObjectValidationBuilder* JNoiseFloatExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("name")
- ->finishString()
- ->withRequiredAttribute("x",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->withRequiredAttribute("y",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->withRequiredAttribute("z",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>());
- }
- const char* JNoiseFloatExpressionFactory::getTypeToken() const
- {
- return "noise";
- }
- JOperatorFloatExpression::JOperatorFloatExpression()
- : JFloatExpression(),
- accumulator([](float a, float b) { return 0.f; })
- {}
- float JOperatorFloatExpression::getValueOld(JExpressionMemory* zMemory)
- {
- bool first = 1;
- float val = 0.f;
- for (JFloatExpression* expression : values)
- {
- if (first)
- {
- first = 0;
- val = expression->getValueOld(zMemory);
- }
- else
- {
- val = accumulator(val, expression->getValueOld(zMemory));
- }
- }
- return val;
- }
- Framework::Assembly::AssemblyBlock& JOperatorFloatExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- bool first = 1;
- if (!values.getEintragAnzahl())
- {
- codeBlock.addMoveValue(Framework::Assembly::MM0, 0.f);
- }
- for (JFloatExpression* expression : values)
- {
- if (first)
- {
- first = 0;
- codeBlock.addBlock(
- &expression->buildAssembly(zMemory), {}, {}, {}, 0, 0);
- }
- else
- {
- Framework::Assembly::AssemblyBlock& exprBlock
- = expression->buildAssembly(zMemory);
- if (exprBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM1))
- {
- exprBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM1);
- }
- else
- {
- exprBlock.addMoveValue(Framework::Assembly::MM1,
- Framework::Assembly::MM0,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- codeBlock.addBlock(&exprBlock,
- {},
- {Framework::Assembly::MM0},
- {Framework::Assembly::SINGLE_FLOAT},
- 0,
- 0);
- if (op.istGleich("+"))
- {
- codeBlock.addAddition(Framework::Assembly::MM0,
- Framework::Assembly::MM1,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- else if (op.istGleich("-"))
- {
- codeBlock.addSubtraction(Framework::Assembly::MM0,
- Framework::Assembly::MM1,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- else if (op.istGleich("*"))
- {
- codeBlock.addMultiplication(Framework::Assembly::MM0,
- Framework::Assembly::MM1,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- else if (op.istGleich("/"))
- {
- codeBlock.addDivision(Framework::Assembly::MM0,
- Framework::Assembly::MM1,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- }
- }
- return codeBlock;
- }
- void JOperatorFloatExpression::setOperator(
- Framework::Text op, std::function<float(float a, float b)> accumulator)
- {
- this->op = op;
- this->accumulator = accumulator;
- }
- Framework::Text JOperatorFloatExpression::getOperator()
- {
- return op;
- }
- void JOperatorFloatExpression::addValue(JFloatExpression* value)
- {
- values.add(value);
- }
- const Framework::RCArray<JFloatExpression>&
- JOperatorFloatExpression::getValues() const
- {
- return values;
- }
- JOperatorFloatExpressionFactory::JOperatorFloatExpressionFactory()
- : SubTypeFactory()
- {}
- JOperatorFloatExpression* JOperatorFloatExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JOperatorFloatExpression* result = new JOperatorFloatExpression();
- Framework::Text op = zJson->zValue("operator")->asString()->getString();
- if (op.istGleich("+"))
- {
- result->setOperator("+", [](float a, float b) { return a + b; });
- }
- else if (op.istGleich("-"))
- {
- result->setOperator("-", [](float a, float b) { return a - b; });
- }
- else if (op.istGleich("*"))
- {
- result->setOperator("*", [](float a, float b) { return a * b; });
- }
- else if (op.istGleich("/"))
- {
- result->setOperator("/", [](float a, float b) { return a / b; });
- }
- for (Framework::JSON::JSONValue* value :
- *zJson->zValue("values")->asArray())
- {
- result->addValue(
- Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(value));
- }
- return result;
- }
- Framework::JSON::JSONObject* JOperatorFloatExpressionFactory::toJsonObject(
- JOperatorFloatExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "operator", new Framework::JSON::JSONString(zObject->getOperator()));
- Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
- for (JFloatExpression* expression : zObject->getValues())
- {
- values->addValue(
- Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
- expression));
- }
- result->addValue("values", values);
- return result;
- }
- JSONObjectValidationBuilder* JOperatorFloatExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("operator")
- ->whichIsOneOf({"+", "-", "*", "/"})
- ->finishString()
- ->withRequiredArray("values")
- ->addAcceptedTypeInArray(
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->finishArray();
- }
- const char* JOperatorFloatExpressionFactory::getTypeToken() const
- {
- return "operator";
- }
- JBoolOperatorBoolExpression::JBoolOperatorBoolExpression()
- : JBoolExpression()
- {}
- bool JBoolOperatorBoolExpression::getValueOld(JExpressionMemory* zMemory)
- {
- bool first = 1;
- bool val = 0;
- for (JBoolExpression* expression : values)
- {
- if (first)
- {
- first = 0;
- val = expression->getValueOld(zMemory);
- }
- else
- {
- val = accumulator(val, expression->getValueOld(zMemory));
- }
- }
- return val;
- }
- Framework::Assembly::AssemblyBlock& JBoolOperatorBoolExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- bool first = 1;
- if (!values.getEintragAnzahl())
- {
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)0);
- }
- for (JBoolExpression* expression : values)
- {
- if (first)
- {
- first = 0;
- codeBlock.addBlock(
- &expression->buildAssembly(zMemory), {}, {}, {}, 0, 0);
- }
- else
- {
- Framework::Assembly::AssemblyBlock& exprBlock
- = expression->buildAssembly(zMemory);
- if (exprBlock.isReplacementPossible(
- Framework::Assembly::RAX, Framework::Assembly::RCX))
- {
- exprBlock.replaceRegister(
- Framework::Assembly::RAX, Framework::Assembly::RCX);
- }
- else
- {
- exprBlock.addMoveValue(Framework::Assembly::RCX,
- Framework::Assembly::RAX,
- Framework::Assembly::LOWER8);
- }
- codeBlock.addBlock(
- &exprBlock, {Framework::Assembly::RAX}, {}, {}, 0, 0);
- if (op.istGleich("&&"))
- {
- codeBlock.addAnd(Framework::Assembly::RAX,
- Framework::Assembly::RCX,
- Framework::Assembly::LOWER8);
- }
- else if (op.istGleich("||"))
- {
- codeBlock.addOr(Framework::Assembly::RAX,
- Framework::Assembly::RCX,
- Framework::Assembly::LOWER8);
- }
- }
- }
- return codeBlock;
- }
- void JBoolOperatorBoolExpression::setOperator(
- Framework::Text op, std::function<float(float a, float b)> accumulator)
- {
- this->op = op;
- this->accumulator = accumulator;
- }
- Framework::Text JBoolOperatorBoolExpression::getOperator()
- {
- return op;
- }
- void JBoolOperatorBoolExpression::addValue(JBoolExpression* value)
- {
- values.add(value);
- }
- const Framework::RCArray<JBoolExpression>&
- JBoolOperatorBoolExpression::getValues() const
- {
- return values;
- }
- JBoolOperatorBoolExpressionFactory::JBoolOperatorBoolExpressionFactory()
- : SubTypeFactory()
- {}
- JBoolOperatorBoolExpression* JBoolOperatorBoolExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JBoolOperatorBoolExpression* result = new JBoolOperatorBoolExpression();
- for (Framework::JSON::JSONValue* value :
- *zJson->zValue("values")->asArray())
- {
- result->addValue(
- Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(value));
- }
- Framework::Text op = zJson->zValue("operator")->asString()->getString();
- if (op.istGleich("&&"))
- {
- result->setOperator("&&", [](bool a, bool b) { return a && b; });
- }
- else if (op.istGleich("||"))
- {
- result->setOperator("||", [](bool a, bool b) { return a || b; });
- }
- return result;
- }
- Framework::JSON::JSONObject* JBoolOperatorBoolExpressionFactory::toJsonObject(
- JBoolOperatorBoolExpression* zObject) const
- {
- Framework::JSON::JSONObject* zResult = new Framework::JSON::JSONObject();
- Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
- for (JBoolExpression* expression : zObject->getValues())
- {
- values->addValue(
- Game::INSTANCE->zTypeRegistry()->toJson<JBoolExpression>(
- expression));
- }
- zResult->addValue("values", values);
- zResult->addValue(
- "operator", new Framework::JSON::JSONString(zObject->getOperator()));
- return zResult;
- }
- JSONObjectValidationBuilder* JBoolOperatorBoolExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("operator")
- ->whichIsOneOf({"&&", "||"})
- ->finishString()
- ->withRequiredArray("values")
- ->addAcceptedTypeInArray(
- Game::INSTANCE->zTypeRegistry()->getValidator<JBoolExpression>())
- ->finishArray();
- }
- const char* JBoolOperatorBoolExpressionFactory::getTypeToken() const
- {
- return "operator";
- }
- JFloatOperatorBoolExpression::JFloatOperatorBoolExpression()
- : JBoolExpression()
- {}
- bool JFloatOperatorBoolExpression::getValueOld(JExpressionMemory* zMemory)
- {
- bool first = 1;
- bool val = 1;
- float last = 0.f;
- for (JFloatExpression* expression : values)
- {
- float current = expression->getValueOld(zMemory);
- if (!first) val &= accumulator(last, current);
- first = 0;
- last = current;
- if (!val) break;
- }
- return val;
- }
- Framework::Assembly::AssemblyBlock& JFloatOperatorBoolExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- bool first = 1;
- Framework::Assembly::FPRegister lastResultSorage = Framework::Assembly::MM0;
- for (JFloatExpression* expression : values)
- {
- if (first)
- {
- first = 0;
- codeBlock.addBlock(
- &expression->buildAssembly(zMemory), {}, {}, {}, 0, 0);
- }
- else
- {
- Framework::Assembly::FPRegister currentResultSorage
- = lastResultSorage == Framework::Assembly::MM0
- ? Framework::Assembly::MM1
- : Framework::Assembly::MM0;
- Framework::Assembly::AssemblyBlock& exprBlock
- = expression->buildAssembly(zMemory);
- if (currentResultSorage != Framework::Assembly::MM0)
- {
- if (exprBlock.isReplacementPossible(
- Framework::Assembly::MM0, currentResultSorage))
- {
- exprBlock.replaceRegister(
- Framework::Assembly::MM0, currentResultSorage);
- }
- else
- {
- exprBlock.addMoveValue(currentResultSorage,
- Framework::Assembly::MM0,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::X);
- }
- }
- codeBlock.addBlock(&exprBlock,
- {},
- {lastResultSorage},
- {Framework::Assembly::SINGLE_FLOAT},
- 0,
- 0);
- Framework::Assembly::Operation jumpOp = Framework::Assembly::NOP;
- bool needConversion = false;
- if (op.istGleich(">"))
- {
- jumpOp = Framework::Assembly::JBE; // jump if below or equal
- }
- else if (op.istGleich("<"))
- {
- jumpOp = Framework::Assembly::JNB; // jump if not below
- }
- else if (op.istGleich(">="))
- {
- jumpOp = Framework::Assembly::JB; // jump if below
- }
- else if (op.istGleich("<="))
- {
- jumpOp = Framework::Assembly::JA; // jump if above
- }
- else if (op.istGleich("=="))
- {
- jumpOp = Framework::Assembly::JNE; // jump if not equal
- }
- else if (op.istGleich("!="))
- {
- jumpOp = Framework::Assembly::JE; // jump if equal
- }
- else
- {
- needConversion = true;
- if (op.istGleich(">i"))
- {
- jumpOp = Framework::Assembly::JLE; // jump if less or equal
- }
- else if (op.istGleich("<i"))
- {
- jumpOp = Framework::Assembly::JGE; // jump if greater or
- // equal
- }
- else if (op.istGleich(">=i"))
- {
- jumpOp = Framework::Assembly::JL; // jump if less
- }
- else if (op.istGleich("<=i"))
- {
- jumpOp = Framework::Assembly::JG; // jump if greater
- }
- else if (op.istGleich("==i"))
- {
- jumpOp = Framework::Assembly::JNE; // jump if not equal
- }
- else if (op.istGleich("!=i"))
- {
- jumpOp = Framework::Assembly::JE; // jump if equal
- }
- }
- if (needConversion)
- {
- codeBlock.addConversion(Framework::Assembly::RAX,
- lastResultSorage,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::LOWER32);
- codeBlock.addConversion(Framework::Assembly::RCX,
- currentResultSorage,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::LOWER32);
- codeBlock.addCompare(Framework::Assembly::RAX,
- Framework::Assembly::RCX,
- Framework::Assembly::LOWER32);
- }
- else
- {
- codeBlock.addCompare(lastResultSorage,
- currentResultSorage,
- Framework::Assembly::SINGLE_FLOAT);
- }
- codeBlock.addJump(jumpOp, "end_false");
- lastResultSorage = currentResultSorage;
- }
- }
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)1);
- codeBlock.addJump(Framework::Assembly::JMP, "end");
- codeBlock.defineJumpTarget("end_false");
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)0);
- codeBlock.defineJumpTarget("end");
- return codeBlock;
- }
- void JFloatOperatorBoolExpression::setOperator(
- Framework::Text op, std::function<bool(float a, float b)> accumulator)
- {
- this->op = op;
- this->accumulator = accumulator;
- }
- Framework::Text JFloatOperatorBoolExpression::getOperator()
- {
- return op;
- }
- void JFloatOperatorBoolExpression::addValue(JFloatExpression* value)
- {
- values.add(value);
- }
- const Framework::RCArray<JFloatExpression>&
- JFloatOperatorBoolExpression::getValues() const
- {
- return values;
- }
- JFloatOperatorBoolExpressionFactory::JFloatOperatorBoolExpressionFactory()
- : SubTypeFactory()
- {}
- JFloatOperatorBoolExpression* JFloatOperatorBoolExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JFloatOperatorBoolExpression* result = new JFloatOperatorBoolExpression();
- Framework::Text op = zJson->zValue("operator")->asString()->getString();
- if (op.istGleich(">"))
- {
- result->setOperator(">", [](float a, float b) { return a > b; });
- }
- else if (op.istGleich("<"))
- {
- result->setOperator("<", [](float a, float b) { return a < b; });
- }
- else if (op.istGleich(">="))
- {
- result->setOperator(">=", [](float a, float b) { return a >= b; });
- }
- else if (op.istGleich("<="))
- {
- result->setOperator("<=", [](float a, float b) { return a <= b; });
- }
- else if (op.istGleich("=="))
- {
- result->setOperator("==", [](float a, float b) { return a == b; });
- }
- else if (op.istGleich("!="))
- {
- result->setOperator("!=", [](float a, float b) { return a != b; });
- }
- else if (op.istGleich(">i"))
- {
- result->setOperator(
- ">i", [](float a, float b) { return (int)a > (int)b; });
- }
- else if (op.istGleich("<i"))
- {
- result->setOperator(
- "<i", [](float a, float b) { return (int)a < (int)b; });
- }
- else if (op.istGleich(">=i"))
- {
- result->setOperator(
- ">=i", [](float a, float b) { return (int)a >= (int)b; });
- }
- else if (op.istGleich("<=i"))
- {
- result->setOperator(
- "<=i", [](float a, float b) { return (int)a <= (int)b; });
- }
- else if (op.istGleich("==i"))
- {
- result->setOperator(
- "==i", [](float a, float b) { return (int)a == (int)b; });
- }
- else if (op.istGleich("!=i"))
- {
- result->setOperator(
- "!=i", [](float a, float b) { return (int)a != (int)b; });
- }
- for (Framework::JSON::JSONValue* value :
- *zJson->zValue("values")->asArray())
- {
- result->addValue(
- Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(value));
- }
- return result;
- }
- Framework::JSON::JSONObject* JFloatOperatorBoolExpressionFactory::toJsonObject(
- JFloatOperatorBoolExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue(
- "operator", new Framework::JSON::JSONString(zObject->getOperator()));
- Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
- for (JFloatExpression* expression : zObject->getValues())
- {
- values->addValue(
- Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
- expression));
- }
- result->addValue("values", values);
- return result;
- }
- JSONObjectValidationBuilder*
- JFloatOperatorBoolExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder->withRequiredString("operator")
- ->whichIsOneOf({">",
- "<",
- ">=",
- "<=",
- "==",
- "!=",
- "<i",
- ">i",
- ">=i",
- "<=i",
- "==i",
- "!=i"})
- ->finishString()
- ->withRequiredArray("values")
- ->addAcceptedTypeInArray(
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->finishArray();
- }
- const char* JFloatOperatorBoolExpressionFactory::getTypeToken() const
- {
- return "comparsion";
- }
- JBlockTypeBoolExpression::JBlockTypeBoolExpression()
- : JBoolExpression(),
- typeId(0),
- x(0),
- y(0),
- z(0)
- {}
- JBlockTypeBoolExpression ::~JBlockTypeBoolExpression()
- {
- if (x) x->release();
- if (y) y->release();
- if (z) z->release();
- }
- bool JBlockTypeBoolExpression::isValidPosition(
- int x, int y, Chunk* currentChunk)
- {
- return currentChunk
- && Game::getChunkCenter(x, y) == currentChunk->getCenter();
- }
- bool JBlockTypeBoolExpression::getValueOld(JExpressionMemory* zMemory)
- {
- int x = (int)(round(this->x->getValueOld(zMemory)));
- int y = (int)(round(this->y->getValueOld(zMemory)));
- int z = (int)(round(this->z->getValueOld(zMemory)));
- if (z < 0 || z >= WORLD_HEIGHT || !zMemory->zCurrentChunk()
- || Game::getChunkCenter(x, y) != zMemory->zCurrentChunk()->getCenter())
- {
- return 0;
- }
- return zMemory->zCurrentChunk()->getBlockTypeAt(
- Dimension::chunkCoordinates({x, y, z}))
- == typeId;
- }
- Framework::Assembly::AssemblyBlock& JBlockTypeBoolExpression::buildAssembly(
- JExpressionMemory* zMemory)
- {
- Framework::Assembly::AssemblyBlock& xBlock = x->buildAssembly(zMemory);
- Framework::Assembly::AssemblyBlock& yBlock = y->buildAssembly(zMemory);
- Framework::Assembly::AssemblyBlock& zBlock = z->buildAssembly(zMemory);
- Framework::Assembly::FPRegister xTarget = Framework::Assembly::MM0;
- if (xBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM1))
- {
- xBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM1);
- xTarget = Framework::Assembly::MM1;
- }
- Framework::Assembly::FPRegister yTarget = Framework::Assembly::MM0;
- if (yBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM2))
- {
- yBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM2);
- yTarget = Framework::Assembly::MM2;
- }
- Framework::Assembly::FPRegister zTarget = Framework::Assembly::MM0;
- if (zBlock.isReplacementPossible(
- Framework::Assembly::MM0, Framework::Assembly::MM3))
- {
- zBlock.replaceRegister(
- Framework::Assembly::MM0, Framework::Assembly::MM3);
- zTarget = Framework::Assembly::MM3;
- }
- codeBlock.addBlock(&zBlock, {}, {}, {}, 0, &zTarget);
- codeBlock.addConversion(Framework::Assembly::R9,
- zTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::LOWER32,
- 1);
- codeBlock.addTest(Framework::Assembly::R9,
- Framework::Assembly::R9,
- Framework::Assembly::LOWER32);
- codeBlock.addJump(Framework::Assembly::JL, "end_false");
- codeBlock.addCompare(Framework::Assembly::R9, WORLD_HEIGHT);
- codeBlock.addJump(Framework::Assembly::JGE, "end_false");
- codeBlock.addBlock(&yBlock, {Framework::Assembly::R9}, {}, {}, 0, &yTarget);
- codeBlock.addConversion(Framework::Assembly::R8,
- yTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::LOWER32,
- 1);
- codeBlock.addBlock(&xBlock,
- {Framework::Assembly::R8, Framework::Assembly::R9},
- {},
- {},
- 0,
- &xTarget);
- codeBlock.addConversion(Framework::Assembly::RDX,
- xTarget,
- Framework::Assembly::SINGLE_FLOAT,
- Framework::Assembly::LOWER32,
- 1);
- codeBlock.addLoadAddress(this, Framework::Assembly::RCX);
- codeBlock.addPush(Framework::Assembly::RDX, Framework::Assembly::LOWER32);
- codeBlock.addPush(Framework::Assembly::R8, Framework::Assembly::LOWER32);
- codeBlock.addPush(Framework::Assembly::R9, Framework::Assembly::LOWER32);
- codeBlock.addLoadValue(
- (__int64*)zMemory->zzCurrentChunk(), Framework::Assembly::R9);
- codeBlock
- .addMemberCall<bool (JBlockTypeBoolExpression::*)(int, int, Chunk*)>(
- &JBlockTypeBoolExpression::isValidPosition,
- Framework::Assembly::INT_VALUE,
- {Framework::Assembly::R9},
- {});
- codeBlock.addPop(Framework::Assembly::R9, Framework::Assembly::LOWER32);
- codeBlock.addPop(Framework::Assembly::R8, Framework::Assembly::LOWER32);
- codeBlock.addPop(Framework::Assembly::RDX, Framework::Assembly::LOWER32);
- codeBlock.addTest(Framework::Assembly::RAX,
- Framework::Assembly::RAX,
- Framework::Assembly::LOWER8);
- codeBlock.addJump(Framework::Assembly::JZ, "end");
- codeBlock.addLoadValue(
- (__int64*)zMemory->zzCurrentChunk(), Framework::Assembly::RCX);
- codeBlock.addMemberCall<int (Chunk::*)(int, int, int) const>(
- &Chunk::getBlockTypeAtWC,
- Framework::Assembly::INT_VALUE,
- {Framework::Assembly::RCX,
- Framework::Assembly::RDX,
- Framework::Assembly::R8,
- Framework::Assembly::R9},
- {});
- codeBlock.addCompare(Framework::Assembly::RAX,
- Framework::Assembly::RCX,
- Framework::Assembly::LOWER32);
- codeBlock.addJump(Framework::Assembly::JNE, "end_false");
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)1);
- codeBlock.addJump(Framework::Assembly::JMP, "end");
- codeBlock.defineJumpTarget("end_false");
- codeBlock.addMoveValue(Framework::Assembly::RAX, (char)0);
- codeBlock.defineJumpTarget("end");
- return codeBlock;
- }
- void JBlockTypeBoolExpression::setTypeId(int typeId)
- {
- this->typeId = typeId;
- }
- int JBlockTypeBoolExpression::getTypeId() const
- {
- return typeId;
- }
- void JBlockTypeBoolExpression::setX(JFloatExpression* x)
- {
- if (this->x) this->x->release();
- this->x = x;
- }
- JFloatExpression* JBlockTypeBoolExpression::zX() const
- {
- return x;
- }
- void JBlockTypeBoolExpression::setY(JFloatExpression* y)
- {
- if (this->y) this->y->release();
- this->y = y;
- }
- JFloatExpression* JBlockTypeBoolExpression::zY() const
- {
- return y;
- }
- void JBlockTypeBoolExpression::setZ(JFloatExpression* z)
- {
- if (this->z) this->z->release();
- this->z = z;
- }
- JFloatExpression* JBlockTypeBoolExpression::zZ() const
- {
- return z;
- }
- JBlockTypeBoolExpressionFactory::JBlockTypeBoolExpressionFactory()
- : SubTypeFactory()
- {}
- JBlockTypeBoolExpression* JBlockTypeBoolExpressionFactory::fromJson(
- Framework::JSON::JSONObject* zJson) const
- {
- JBlockTypeBoolExpression* result = new JBlockTypeBoolExpression();
- result->setTypeId(Game::INSTANCE->getBlockTypeId(
- zJson->zValue("blockType")->asString()->getString()));
- result->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("x")));
- result->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("y")));
- result->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
- zJson->zValue("z")));
- return result;
- }
- Framework::JSON::JSONObject* JBlockTypeBoolExpressionFactory::toJsonObject(
- JBlockTypeBoolExpression* zObject) const
- {
- Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
- result->addValue("blockType",
- new Framework::JSON::JSONString(
- Game::INSTANCE->zBlockType(zObject->getTypeId())->getName()));
- result->addValue(
- "x", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zX()));
- result->addValue(
- "y", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zY()));
- result->addValue(
- "z", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zZ()));
- return result;
- }
- JSONObjectValidationBuilder* JBlockTypeBoolExpressionFactory::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return builder
- ->withRequiredAttribute("blockType",
- Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
- BlockTypeNameFactory::TYPE_ID))
- ->withRequiredAttribute("x",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->withRequiredAttribute("y",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>())
- ->withRequiredAttribute("z",
- Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>());
- }
- const char* JBlockTypeBoolExpressionFactory::getTypeToken() const
- {
- return "blockType";
- }
|