mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix some bugs and clean up stuff
This commit is contained in:
parent
d12b98e0f3
commit
13ab96f7b6
9 changed files with 65 additions and 41 deletions
|
|
@ -80,8 +80,6 @@ class MarbleWorldMacros {
|
|||
shape = new EasterEgg(cast element);
|
||||
else if (dataBlockLowerCase == "checkpointshape") {
|
||||
shape = new Checkpoint(cast element);
|
||||
if (_previousCheckpointTrigger != null)
|
||||
_previousCheckpointTrigger.checkpoint = cast shape;
|
||||
} else if (dataBlockLowerCase == "ductfan")
|
||||
shape = new DuctFan();
|
||||
else if (dataBlockLowerCase == "smallductfan")
|
||||
|
|
@ -152,6 +150,7 @@ class MarbleWorldMacros {
|
|||
mat.setPosition(shapePosition);
|
||||
|
||||
this.addDtsObject(shape, () -> {
|
||||
addToSimgroup(shape, simGroup);
|
||||
shape.setTransform(mat);
|
||||
onFinish();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1945,6 +1945,7 @@ class Marble extends GameObject {
|
|||
this.helicopter.setPosition(x, y, z);
|
||||
this.helicopter.setRotationQuat(this.level.getOrientationQuat(currentTime));
|
||||
this.helicopterSound.pause = false;
|
||||
this.helicopter.setScale(this._renderScale);
|
||||
} else {
|
||||
this.helicopter.setPosition(1e8, 1e8, 1e8);
|
||||
this.helicopterSound.pause = true;
|
||||
|
|
@ -1952,6 +1953,7 @@ class Marble extends GameObject {
|
|||
if (currentTime - this.blastUseTime < this.blastWave.dts.sequences[0].duration) {
|
||||
this.blastWave.setPosition(x, y, z);
|
||||
this.blastWave.setRotationQuat(this.level.getOrientationQuat(this.level.timeState.currentAttemptTime));
|
||||
this.blastWave.setScale(this._renderScale);
|
||||
} else {
|
||||
this.blastWave.setPosition(1e8, 1e8, 1e8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class MarbleWorld extends Scheduler {
|
|||
public var triggers:Array<Trigger> = [];
|
||||
public var gems:Array<Gem> = [];
|
||||
public var namedObjects:Map<String, {obj:DtsObject, elem:MissionElementBase}> = [];
|
||||
public var simGroups:Map<MissionElementSimGroup, Array<GameObject>> = [];
|
||||
|
||||
var shapeImmunity:Array<DtsObject> = [];
|
||||
var shapeOrTriggerInside:Array<GameObject> = [];
|
||||
|
|
@ -160,10 +161,8 @@ class MarbleWorld extends Scheduler {
|
|||
var currentCheckpointTrigger:CheckpointTrigger = null;
|
||||
var checkpointCollectedGems:Map<Gem, Bool> = [];
|
||||
var checkpointHeldPowerup:PowerUp = null;
|
||||
var checkpointUp:Vector = null;
|
||||
var cheeckpointBlast:Float = 0;
|
||||
var checkpointSequence:Int = 0;
|
||||
var _previousCheckpointTrigger:CheckpointTrigger;
|
||||
|
||||
// Replay
|
||||
public var replay:Replay;
|
||||
|
|
@ -389,6 +388,7 @@ class MarbleWorld extends Scheduler {
|
|||
marblefiles.push("shapes/balls/marble20.normal.png");
|
||||
marblefiles.push("shapes/balls/marble18.normal.png");
|
||||
marblefiles.push("shapes/balls/marble01.normal.png");
|
||||
marblefiles.push("shapes/balls/marble02.normal.png");
|
||||
marblefiles.push("sound/use_blast.wav");
|
||||
}
|
||||
// Hacky
|
||||
|
|
@ -444,7 +444,6 @@ class MarbleWorld extends Scheduler {
|
|||
this.currentCheckpointTrigger = null;
|
||||
this.checkpointCollectedGems.clear();
|
||||
this.checkpointHeldPowerup = null;
|
||||
this.checkpointUp = null;
|
||||
this.cheeckpointBlast = 0;
|
||||
this.checkpointSequence = 0;
|
||||
|
||||
|
|
@ -552,6 +551,15 @@ class MarbleWorld extends Scheduler {
|
|||
};
|
||||
}
|
||||
|
||||
function addToSimgroup(obj:GameObject, simGroup:MissionElementSimGroup) {
|
||||
if (simGroup == null)
|
||||
return;
|
||||
if (!simGroups.exists(simGroup))
|
||||
simGroups[simGroup] = [obj];
|
||||
else
|
||||
simGroups[simGroup].push(obj);
|
||||
}
|
||||
|
||||
public function addSimGroup(simGroup:MissionElementSimGroup) {
|
||||
if (simGroup.elements.filter((element) -> element._type == MissionElementType.PathedInterior).length != 0) {
|
||||
// Create the pathed interior
|
||||
|
|
@ -583,15 +591,15 @@ class MarbleWorld extends Scheduler {
|
|||
case MissionElementType.SimGroup:
|
||||
this.addSimGroup(cast element);
|
||||
case MissionElementType.InteriorInstance:
|
||||
resourceLoadFuncs.push(fwd -> this.addInteriorFromMis(cast element, fwd));
|
||||
resourceLoadFuncs.push(fwd -> this.addInteriorFromMis(cast element, simGroup, fwd));
|
||||
case MissionElementType.StaticShape:
|
||||
resourceLoadFuncs.push(fwd -> this.addStaticShape(cast element, fwd));
|
||||
resourceLoadFuncs.push(fwd -> this.addStaticShape(cast element, simGroup, fwd));
|
||||
case MissionElementType.Item:
|
||||
resourceLoadFuncs.push(fwd -> this.addItem(cast element, fwd));
|
||||
resourceLoadFuncs.push(fwd -> this.addItem(cast element, simGroup, fwd));
|
||||
case MissionElementType.Trigger:
|
||||
resourceLoadFuncs.push(fwd -> this.addTrigger(cast element, fwd));
|
||||
resourceLoadFuncs.push(fwd -> this.addTrigger(cast element, simGroup, fwd));
|
||||
case MissionElementType.TSStatic:
|
||||
resourceLoadFuncs.push(fwd -> this.addTSStatic(cast element, fwd));
|
||||
resourceLoadFuncs.push(fwd -> this.addTSStatic(cast element, simGroup, fwd));
|
||||
case MissionElementType.ParticleEmitterNode:
|
||||
resourceLoadFuncs.push(fwd -> {
|
||||
this.addParticleEmitterNode(cast element);
|
||||
|
|
@ -602,7 +610,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
public function addInteriorFromMis(element:MissionElementInteriorInstance, onFinish:Void->Void) {
|
||||
public function addInteriorFromMis(element:MissionElementInteriorInstance, simGroup:MissionElementSimGroup, onFinish:Void->Void) {
|
||||
var difPath = this.mission.getDifPath(element.interiorfile);
|
||||
if (difPath == "") {
|
||||
onFinish();
|
||||
|
|
@ -614,6 +622,8 @@ class MarbleWorld extends Scheduler {
|
|||
// DifBuilder.loadDif(difPath, interior);
|
||||
// this.interiors.push(interior);
|
||||
this.addInterior(interior, () -> {
|
||||
addToSimgroup(interior, simGroup);
|
||||
|
||||
var interiorPosition = MisParser.parseVector3(element.position);
|
||||
interiorPosition.x = -interiorPosition.x;
|
||||
var interiorRotation = MisParser.parseRotation(element.rotation);
|
||||
|
|
@ -649,17 +659,17 @@ class MarbleWorld extends Scheduler {
|
|||
// this.physics.addInterior(interior);
|
||||
}
|
||||
|
||||
public function addStaticShape(element:MissionElementStaticShape, onFinish:Void->Void) {
|
||||
public function addStaticShape(element:MissionElementStaticShape, simGroup:MissionElementSimGroup, onFinish:Void->Void) {
|
||||
var shape:DtsObject = null;
|
||||
MarbleWorldMacros.addStaticShapeOrItem();
|
||||
}
|
||||
|
||||
public function addItem(element:MissionElementItem, onFinish:Void->Void) {
|
||||
public function addItem(element:MissionElementItem, simGroup:MissionElementSimGroup, onFinish:Void->Void) {
|
||||
var shape:DtsObject = null;
|
||||
MarbleWorldMacros.addStaticShapeOrItem();
|
||||
}
|
||||
|
||||
public function addTrigger(element:MissionElementTrigger, onFinish:Void->Void) {
|
||||
public function addTrigger(element:MissionElementTrigger, simGroup:MissionElementSimGroup, onFinish:Void->Void) {
|
||||
var trigger:Trigger = null;
|
||||
|
||||
var datablockLowercase = element.datablock.toLowerCase();
|
||||
|
|
@ -672,8 +682,9 @@ class MarbleWorld extends Scheduler {
|
|||
} else if (datablockLowercase == "helptrigger") {
|
||||
trigger = new HelpTrigger(element, cast this);
|
||||
} else if (datablockLowercase == "checkpointtrigger") {
|
||||
trigger = new CheckpointTrigger(element, cast this);
|
||||
_previousCheckpointTrigger = cast trigger;
|
||||
var chk = new CheckpointTrigger(element, cast this);
|
||||
trigger = chk;
|
||||
chk.simGroup = simGroup;
|
||||
} else {
|
||||
Console.error("Unknown trigger: " + element.datablock);
|
||||
onFinish();
|
||||
|
|
@ -682,12 +693,13 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
trigger.init(() -> {
|
||||
this.triggers.push(trigger);
|
||||
addToSimgroup(trigger, simGroup);
|
||||
this.collisionWorld.addEntity(trigger.collider);
|
||||
onFinish();
|
||||
});
|
||||
}
|
||||
|
||||
public function addTSStatic(element:MissionElementTSStatic, onFinish:Void->Void) {
|
||||
public function addTSStatic(element:MissionElementTSStatic, simGroup:MissionElementSimGroup, onFinish:Void->Void) {
|
||||
// !! WARNING - UNTESTED !!
|
||||
var shapeName = element.shapename;
|
||||
var index = shapeName.indexOf('data/');
|
||||
|
|
@ -740,6 +752,7 @@ class MarbleWorld extends Scheduler {
|
|||
mat.setPosition(shapePosition);
|
||||
|
||||
this.addDtsObject(tsShape, () -> {
|
||||
addToSimgroup(tsShape, simGroup);
|
||||
tsShape.setTransform(mat);
|
||||
onFinish();
|
||||
}, true);
|
||||
|
|
@ -1606,7 +1619,6 @@ class MarbleWorld extends Scheduler {
|
|||
this.currentCheckpoint = shape;
|
||||
this.currentCheckpointTrigger = trigger;
|
||||
this.checkpointCollectedGems.clear();
|
||||
this.checkpointUp = this.currentUp.clone();
|
||||
this.cheeckpointBlast = this.blastAmount;
|
||||
// Remember all gems that were collected up to this point
|
||||
for (gem in this.gems) {
|
||||
|
|
@ -1624,6 +1636,7 @@ class MarbleWorld extends Scheduler {
|
|||
var marble = this.marble;
|
||||
// Determine where to spawn the marble
|
||||
var offset = new Vector(0, 0, 0.727843);
|
||||
offset.transform(this.currentCheckpoint.getRotationQuat().toMatrix());
|
||||
var mpos = this.currentCheckpoint.getAbsPos().getPosition().add(offset);
|
||||
this.marble.setMarblePosition(mpos.x, mpos.y, mpos.z);
|
||||
marble.velocity.load(new Vector(0, 0, 0));
|
||||
|
|
@ -1654,15 +1667,12 @@ class MarbleWorld extends Scheduler {
|
|||
gravityField = @:privateAccess this.currentCheckpointTrigger.element.fields.get('gravity')[0];
|
||||
}
|
||||
}
|
||||
if (MisParser.parseBoolean(gravityField)) {
|
||||
// In this case, we set the gravity to the relative "up" vector of the checkpoint shape.
|
||||
var up = new Vector(0, 0, 1);
|
||||
up.transform(this.currentCheckpoint.getRotationQuat().toMatrix());
|
||||
this.setUp(up, this.timeState, true);
|
||||
} else {
|
||||
// Otherwise, we restore gravity to what was stored.
|
||||
this.setUp(this.checkpointUp, this.timeState, true);
|
||||
}
|
||||
|
||||
// In this case, we set the gravity to the relative "up" vector of the checkpoint shape.
|
||||
var up = new Vector(0, 0, 1);
|
||||
up.transform(this.currentCheckpoint.getRotationQuat().toMatrix());
|
||||
this.setUp(up, this.timeState, true);
|
||||
|
||||
// Restore gem states
|
||||
for (gem in this.gems) {
|
||||
if (gem.pickedUp && !this.checkpointCollectedGems.exists(gem)) {
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ class PreviewWorld extends Scheduler {
|
|||
|
||||
scene.camera.setFovX(90, Settings.optionsSettings.screenWidth / Settings.optionsSettings.screenHeight);
|
||||
|
||||
scene.camera.up.set(0, 0, 1);
|
||||
scene.camera.pos.load(camPos.add(off));
|
||||
scene.camera.target.load(scene.camera.pos.add(directionVector));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,8 +223,16 @@ class MarblePickerGui extends GuiImage {
|
|||
}
|
||||
];
|
||||
|
||||
var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile();
|
||||
var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile();
|
||||
super(res);
|
||||
|
||||
var fadeEdge = new GuiImage(ResourceLoader.getResource("data/ui/xbox/BG_fadeOutSoftEdge.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
fadeEdge.position = new Vector(0, 0);
|
||||
fadeEdge.extent = new Vector(640, 480);
|
||||
fadeEdge.vertSizing = Height;
|
||||
fadeEdge.horizSizing = Width;
|
||||
this.addChild(fadeEdge);
|
||||
|
||||
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
||||
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
||||
|
|
@ -267,6 +275,7 @@ class MarblePickerGui extends GuiImage {
|
|||
var prevPreview = @:privateAccess MarbleGame.instance.previewWorld.currentMission;
|
||||
|
||||
MarbleGame.instance.setPreviewMission("marblepicker", () -> {
|
||||
this.bmp.visible = false;
|
||||
@:privateAccess MarbleGame.instance.previewWorld.spawnMarble(marb -> {
|
||||
var spawnPos = @:privateAccess MarbleGame.instance.scene.camera.pos.add(new Vector(0, 1, 1));
|
||||
var velAdd = new Vector((1 - 2 * Math.random()) * 2, (1 - 2 * Math.random()) * 1.5, (1 - 2 * Math.random()) * 1);
|
||||
|
|
@ -319,8 +328,10 @@ class MarblePickerGui extends GuiImage {
|
|||
backButton.horizSizing = Right;
|
||||
backButton.gamepadAccelerator = ["OK"];
|
||||
backButton.pressedAction = (e) -> {
|
||||
MarbleGame.canvas.setContent(new OptionsListGui());
|
||||
MarbleGame.instance.setPreviewMission(prevPreview, () -> {}, false);
|
||||
this.bmp.visible = true;
|
||||
MarbleGame.instance.setPreviewMission(prevPreview, () -> {
|
||||
MarbleGame.canvas.setContent(new OptionsListGui());
|
||||
}, false);
|
||||
};
|
||||
|
||||
bottomBar.addChild(backButton);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class RewindFrame {
|
|||
currentCheckpointTrigger:CheckpointTrigger,
|
||||
checkpointCollectedGems:Map<Gem, Bool>,
|
||||
checkpointHeldPowerup:PowerUp,
|
||||
checkpointUp:Vector,
|
||||
checkpointBlast:Float
|
||||
};
|
||||
|
||||
|
|
@ -95,7 +94,6 @@ class RewindFrame {
|
|||
currentCheckpointTrigger: checkpointState.currentCheckpointTrigger,
|
||||
checkpointCollectedGems: checkpointState.checkpointCollectedGems.copy(),
|
||||
checkpointHeldPowerup: checkpointState.checkpointHeldPowerup,
|
||||
checkpointUp: checkpointState.checkpointUp != null ? checkpointState.checkpointUp.clone() : null,
|
||||
checkpointBlast: checkpointState.checkpointBlast,
|
||||
};
|
||||
return c;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ class RewindManager {
|
|||
checkpointBlast: @:privateAccess level.cheeckpointBlast,
|
||||
checkpointCollectedGems: @:privateAccess level.checkpointCollectedGems.copy(),
|
||||
checkpointHeldPowerup: @:privateAccess level.checkpointHeldPowerup,
|
||||
checkpointUp: @:privateAccess level.checkpointUp != null ? @:privateAccess level.checkpointUp.clone() : null,
|
||||
};
|
||||
frames.push(rf);
|
||||
}
|
||||
|
|
@ -165,7 +164,6 @@ class RewindManager {
|
|||
level.marble.camera.oob = rf.oobState.oob;
|
||||
level.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null;
|
||||
level.blastAmount = rf.blastAmt;
|
||||
@:privateAccess level.checkpointUp = rf.checkpointState.checkpointUp;
|
||||
@:privateAccess level.checkpointCollectedGems = rf.checkpointState.checkpointCollectedGems;
|
||||
@:privateAccess level.cheeckpointBlast = rf.checkpointState.checkpointBlast;
|
||||
@:privateAccess level.checkpointHeldPowerup = rf.checkpointState.checkpointHeldPowerup;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package triggers;
|
||||
|
||||
import mis.MissionElement.MissionElementSimGroup;
|
||||
import shapes.Checkpoint;
|
||||
import h3d.Vector;
|
||||
import src.MarbleWorld;
|
||||
|
|
@ -10,7 +11,7 @@ import mis.MisParser;
|
|||
class CheckpointTrigger extends Trigger {
|
||||
public var disableOOB = false;
|
||||
public var add:Vector = null;
|
||||
public var checkpoint:Checkpoint;
|
||||
public var simGroup:MissionElementSimGroup;
|
||||
public var seqNum:Int;
|
||||
|
||||
override public function new(element:MissionElementTrigger, level:MarbleWorld) {
|
||||
|
|
@ -29,13 +30,16 @@ class CheckpointTrigger extends Trigger {
|
|||
|
||||
public override function onMarbleEnter(time:src.TimeState) {
|
||||
super.onMarbleEnter(time);
|
||||
var shape = checkpoint;
|
||||
if (shape == null)
|
||||
if (simGroup == null)
|
||||
return;
|
||||
if (this.level.saveCheckpointState(shape, this)) {
|
||||
shape.lastActivatedTime = time.timeSinceLoad;
|
||||
var shape = level.simGroups[simGroup].filter(x -> x.identifier == "Checkpoint");
|
||||
if (shape.length == 0)
|
||||
return;
|
||||
var chk:Checkpoint = cast shape[0];
|
||||
if (this.level.saveCheckpointState(chk, this)) {
|
||||
chk.lastActivatedTime = time.timeSinceLoad;
|
||||
for (obj in this.level.dtsObjects) {
|
||||
if (obj.identifier == "Checkpoint" && obj != shape)
|
||||
if (obj.identifier == "Checkpoint" && obj != chk)
|
||||
cast(obj, Checkpoint).lastActivatedTime = Math.POSITIVE_INFINITY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import src.AudioManager;
|
|||
class HelpTrigger extends Trigger {
|
||||
override function onMarbleEnter(timeState:TimeState) {
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/infotutorial.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.displayHelp(this.element.text);
|
||||
if (this.element.text != null && this.element.text != "")
|
||||
this.level.displayHelp(this.element.text);
|
||||
// this.level.replay.recordMarbleEnter(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue