add support for marble attribute changing

This commit is contained in:
RandomityGuy 2025-02-07 14:38:16 +05:30
parent 53b7525920
commit ce7ed5f679
3 changed files with 36 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package src;
import mis.MisParser;
import gui.MarblePickerGui;
import collision.CollisionPool;
import net.NetPacket.MarbleNetFlags;
@ -564,6 +565,8 @@ class Marble extends GameObject {
this.helicopter.z = 1e8;
this.helicopter.scale(0.3 / 0.2);
loadMarbleAttributes();
if (this.controllable || this.connection != null) {
var worker = new ResourceLoaderWorker(onFinish);
worker.addTask(fwd -> level.addDtsObject(this.helicopter, fwd));
@ -654,6 +657,36 @@ class Marble extends GameObject {
shadowVolume.material.removePass(shadowVolume.material.mainPass);
}
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(collisionWorld:CollisionWorld, timeState:TimeState) {
this.contacts = queuedContacts;
CollisionPool.clear();

View file

@ -40,6 +40,7 @@ class Mission {
public var game:String;
public var hasEgg:Bool;
public var isCustom:Bool;
public var marbleAttributes:Map<String, String>;
var next:Mission;
@ -64,6 +65,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) {

View file

@ -88,7 +88,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();
}