From 7a7756ca3ab13889283efae24f4caac41c6d4197 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:38:16 +0530 Subject: [PATCH] add support for marble attribute changing --- src/Marble.hx | 33 +++++++++++++++++++++++++++++++++ src/Mission.hx | 2 ++ src/mis/MisParser.hx | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Marble.hx b/src/Marble.hx index 250cd757..dbdae0e2 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -1,5 +1,6 @@ package src; +import mis.MisParser; import triggers.Trigger; import net.Net; import gui.MarbleSelectGui; @@ -580,6 +581,8 @@ class Marble extends GameObject { worker.addTask(fwd -> level.addDtsObject(this.helicopter, fwd)); worker.addTask(fwd -> level.addDtsObject(this.megaHelicopter, fwd)); worker.run(); + + loadMarbleAttributes(); } function buildShadowVolume() { @@ -661,6 +664,36 @@ class Marble extends GameObject { shadowVolume.setRotationQuat(q); } + function loadMarbleAttributes() { + var attribs = this.level.mission.marbleAttributes; + if (attribs.exists("maxrollvelocity")) + this._maxRollVelocity = MisParser.parseNumber(attribs.get("maxrollvelocity")); + if (attribs.exists("angularacceleration")) + this._angularAcceleration = MisParser.parseNumber(attribs.get("angularacceleration")); + if (attribs.exists("jumpimpulse")) + this._jumpImpulse = MisParser.parseNumber(attribs.get("jumpimpulse")); + if (attribs.exists("kineticfriction")) + this._kineticFriction = MisParser.parseNumber(attribs.get("kineticfriction")); + if (attribs.exists("staticfriction")) + this._staticFriction = MisParser.parseNumber(attribs.get("staticfriction")); + if (attribs.exists("brakingacceleration")) + this._brakingAcceleration = MisParser.parseNumber(attribs.get("brakingacceleration")); + if (attribs.exists("gravity")) + this._gravity = MisParser.parseNumber(attribs.get("gravity")); + if (attribs.exists("airaccel")) + this._airAccel = MisParser.parseNumber(attribs.get("airaccel")); + if (attribs.exists("maxdotslide")) + this._maxDotSlide = MisParser.parseNumber(attribs.get("maxdotslide")); + if (attribs.exists("minbouncevel")) + this._minBounceVel = MisParser.parseNumber(attribs.get("minbouncevel")); + if (attribs.exists("minbouncespeed")) + this._minBounceSpeed = MisParser.parseNumber(attribs.get("minbouncespeed")); + if (attribs.exists("mintrailvel")) + this._minTrailVel = MisParser.parseNumber(attribs.get("mintrailvel")); + if (attribs.exists("bouncekineticfriction")) + this._bounceKineticFriction = MisParser.parseNumber(attribs.get("bouncekineticfriction")); + } + function findContacts(collisiomWorld:CollisionWorld, timeState:TimeState) { this.contacts = queuedContacts; CollisionPool.clear(); diff --git a/src/Mission.hx b/src/Mission.hx index 2727f77f..210d25cd 100644 --- a/src/Mission.hx +++ b/src/Mission.hx @@ -43,6 +43,7 @@ class Mission { public var isCustom:Bool; public var gameMode:String; public var addedAt:Int64; + public var marbleAttributes:Map; var next:Mission; @@ -66,6 +67,7 @@ class Mission { var misParser = new MisParser(misText); var contents = misParser.parse(); root = contents.root; + marbleAttributes = contents.marbleAttributes; function scanMission(simGroup:MissionElementSimGroup) { for (element in simGroup.elements) { diff --git a/src/mis/MisParser.hx b/src/mis/MisParser.hx index 99aeefb9..5a38d02c 100644 --- a/src/mis/MisParser.hx +++ b/src/mis/MisParser.hx @@ -67,7 +67,7 @@ class MisParser { startText = outsideText; while (marbleAttributesRegEx.match(startText)) { - marbleAttributes.set(marbleAttributesRegEx.matched(1), this.resolveExpression(marbleAttributesRegEx.matched(2))); + marbleAttributes.set(marbleAttributesRegEx.matched(1).toLowerCase(), this.resolveExpression(marbleAttributesRegEx.matched(2))); startText = marbleAttributesRegEx.matchedRight(); }