more ultra stuff and fixes

This commit is contained in:
RandomityGuy 2023-06-16 00:25:17 +05:30
parent 9e15f6b7b4
commit dc29cc529c
85 changed files with 33 additions and 270 deletions

BIN
data/sound/MegaShrink.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/begin.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/easter_egg.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/finish.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/gem_all.wav Normal file

Binary file not shown.

BIN
data/sound/gem_collect.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/gravity.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/gui_back.wav Normal file

Binary file not shown.

BIN
data/sound/gui_confirm.wav Normal file

Binary file not shown.

BIN
data/sound/gui_next.wav Normal file

Binary file not shown.

BIN
data/sound/gyrocopter.wav Normal file

Binary file not shown.

BIN
data/sound/ice_roll.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/level_finish.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/level_text.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/mega_marble.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/player_join.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/pu_easter.wav Normal file

Binary file not shown.

BIN
data/sound/pu_gravity.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/super_jump.wav Normal file

Binary file not shown.

BIN
data/sound/super_speed.wav Normal file

Binary file not shown.

BIN
data/sound/time_travel.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sound/ultrablast.wav Normal file

Binary file not shown.

BIN
data/sound/use_blast.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/sound/use_mega.wav Normal file

Binary file not shown.

BIN
data/sound/use_speed.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1869,7 +1869,7 @@ class Marble extends GameObject {
return;
var impulse = this.level.currentUp.multiply(Math.max(Math.sqrt(this.level.blastAmount), this.level.blastAmount) * 10);
this.applyImpulse(impulse);
AudioManager.playSound(ResourceLoader.getResource('data/sound/blast.wav', ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource('data/sound/use_blast.wav', ResourceLoader.getAudio, this.soundResources));
this.level.particleManager.createEmitter(this.level.blastAmount > 1 ? blastMaxParticleOptions : blastParticleOptions,
this.level.blastAmount > 1 ? blastMaxEmitterData : blastEmitterData, this.getAbsPos().getPosition(), () -> {
this.getAbsPos().getPosition().add(this.level.currentUp.multiply(-this._radius * 0.4));

View file

@ -19,8 +19,6 @@ import shapes.Checkpoint;
import triggers.CheckpointTrigger;
import shapes.EasterEgg;
import shapes.Sign;
import triggers.TeleportTrigger;
import triggers.DestinationTrigger;
import src.Replay;
import gui.Canvas;
import hxd.snd.Channel;
@ -144,7 +142,6 @@ class MarbleWorld extends Scheduler {
public var cursorLock:Bool = true;
var timeTravelSound:Channel;
var alarmSound:Channel;
var helpTextTimeState:Float = -1e8;
var alertTextTimeState:Float = -1e8;
@ -387,12 +384,7 @@ class MarbleWorld extends Scheduler {
"sound/bouncehard2.wav",
"sound/bouncehard3.wav",
"sound/bouncehard4.wav",
"sound/spawn.wav",
"sound/ready.wav",
"sound/set.wav",
"sound/go.wav",
"sound/alarm.wav",
"sound/alarm_timeout.wav",
"sound/spawn_alternate.wav",
"sound/missinggems.wav",
"shapes/images/glow_bounce.dts",
"shapes/images/glow_bounce.png",
@ -456,10 +448,6 @@ class MarbleWorld extends Scheduler {
this.blastAmount = 0;
this.outOfBoundsTime = null;
this.finishTime = null;
if (this.alarmSound != null) {
this.alarmSound.stop();
this.alarmSound = null;
}
this.currentCheckpoint = null;
this.currentCheckpointTrigger = null;
@ -534,29 +522,7 @@ class MarbleWorld extends Scheduler {
this.newOrientationQuat = new Quat();
this.deselectPowerUp();
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn.wav', ResourceLoader.getAudio, this.soundResources));
Console.log("State Start");
this.clearSchedule();
this.schedule(0.5, () -> {
// setCenterText('ready');
Console.log("State Ready");
AudioManager.playSound(ResourceLoader.getResource('data/sound/ready.wav', ResourceLoader.getAudio, this.soundResources));
return 0;
});
this.schedule(2, () -> {
// setCenterText('set');
Console.log("State Set");
AudioManager.playSound(ResourceLoader.getResource('data/sound/set.wav', ResourceLoader.getAudio, this.soundResources));
return 0;
});
this.schedule(3.5, () -> {
// setCenterText('go');
Console.log("State Go");
AudioManager.playSound(ResourceLoader.getResource('data/sound/go.wav', ResourceLoader.getAudio, this.soundResources));
Console.log("State Play");
return 0;
});
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
return 0;
}
@ -568,19 +534,11 @@ class MarbleWorld extends Scheduler {
this.playGui.setCenterText('none');
this.marble.mode = Start;
}
if ((this.timeState.currentAttemptTime >= 0.5) && (this.timeState.currentAttemptTime < 2)) {
this.playGui.setCenterText('ready');
if ((this.timeState.currentAttemptTime >= 0.5) && (this.timeState.currentAttemptTime < 3.5)) {
this.playGui.setCenterText('none');
this.marble.mode = Start;
}
if ((this.timeState.currentAttemptTime >= 2) && (this.timeState.currentAttemptTime < 3.5)) {
this.playGui.setCenterText('set');
this.marble.mode = Start;
}
if ((this.timeState.currentAttemptTime >= 3.5) && (this.timeState.currentAttemptTime < 5.5)) {
this.playGui.setCenterText('go');
this.marble.mode = Play;
}
if (this.timeState.currentAttemptTime >= 5.5 && this.finishTime == null) {
if (this.timeState.currentAttemptTime >= 3.5 && this.finishTime == null) {
this.playGui.setCenterText('none');
this.marble.mode = Play;
}
@ -724,10 +682,6 @@ class MarbleWorld extends Scheduler {
trigger = new InBoundsTrigger(element, cast this);
} else if (datablockLowercase == "helptrigger") {
trigger = new HelpTrigger(element, cast this);
} else if (datablockLowercase == "teleporttrigger") {
trigger = new TeleportTrigger(element, cast this);
} else if (datablockLowercase == "destinationtrigger") {
trigger = new DestinationTrigger(element, cast this);
} else if (datablockLowercase == "checkpointtrigger") {
trigger = new CheckpointTrigger(element, cast this);
_previousCheckpointTrigger = cast trigger;
@ -1170,16 +1124,6 @@ class MarbleWorld extends Scheduler {
if (timeToDisplay >= this.mission.qualifyTime)
return 2;
if (this.timeState.currentAttemptTime >= 3.5) {
// Create the flashing effect
var alarmStart = this.mission.computeAlarmStartTime();
var elapsed = timeToDisplay - alarmStart;
if (elapsed < 0)
return 0;
if (Math.floor(elapsed) % 2 == 0)
return 2;
}
return 0; // Default yellow
}
@ -1198,16 +1142,11 @@ class MarbleWorld extends Scheduler {
if (timeTravelSound == null) {
var ttsnd = ResourceLoader.getResource("data/sound/timetravelactive.wav", ResourceLoader.getAudio, this.soundResources);
timeTravelSound = AudioManager.playSound(ttsnd, null, true);
if (alarmSound != null)
alarmSound.pause = true;
}
} else {
if (timeTravelSound != null) {
timeTravelSound.stop();
timeTravelSound = null;
if (alarmSound != null)
alarmSound.pause = false;
}
if (this.timeState.currentAttemptTime >= 3.5) {
this.timeState.gameplayClock += dt;
@ -1234,27 +1173,6 @@ class MarbleWorld extends Scheduler {
}
this.timeState.timeSinceLoad += dt;
// Handle alarm warnings (that the user is about to exceed the par time)
if (this.timeState.currentAttemptTime >= 3.5) {
var alarmStart = this.mission.computeAlarmStartTime();
if (prevGameplayClock < alarmStart && this.timeState.gameplayClock >= alarmStart) {
// Start the alarm
this.alarmSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/alarm.wav", ResourceLoader.getAudio, this.soundResources),
null, true); // AudioManager.createAudioSource('alarm.wav');
this.displayHelp('You have ${(this.mission.qualifyTime - alarmStart)} seconds remaining.');
}
if (prevGameplayClock < this.mission.qualifyTime && this.timeState.gameplayClock >= this.mission.qualifyTime) {
// Stop the alarm
if (this.alarmSound != null) {
this.alarmSound.stop();
this.alarmSound = null;
}
this.displayHelp("The clock has passed the Par Time.");
AudioManager.playSound(ResourceLoader.getResource("data/sound/alarm_timeout.wav", ResourceLoader.getAudio, this.soundResources));
}
}
if (finishTime != null)
this.timeState.gameplayClock = finishTime.gameplayClock;
playGui.formatTimer(this.timeState.gameplayClock, determineClockColor(this.timeState.gameplayClock));
@ -1340,7 +1258,7 @@ class MarbleWorld extends Scheduler {
if (this.gemCount == this.totalGems) {
string = "You have all the diamonds, head for the finish!";
// if (!this.rewinding)
AudioManager.playSound(ResourceLoader.getResource('data/sound/gotallgems.wav', ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource('data/sound/gem_all.wav', ResourceLoader.getAudio, this.soundResources));
// Some levels with this package end immediately upon collection of all gems
// if (this.mission.misFile.activatedPackages.includes('endWithTheGems')) {
@ -1359,7 +1277,7 @@ class MarbleWorld extends Scheduler {
}
// if (!this.rewinding)
AudioManager.playSound(ResourceLoader.getResource('data/sound/gotgem.wav', ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource('data/sound/gem_collect.wav', ResourceLoader.getAudio, this.soundResources));
}
displayAlert(string);
@ -1511,10 +1429,6 @@ class MarbleWorld extends Scheduler {
timeTravelSound.stop();
timeTravelSound = null;
}
if (alarmSound != null) {
alarmSound.stop();
alarmSound = null;
}
}
}
@ -1716,7 +1630,6 @@ class MarbleWorld extends Scheduler {
// sky.follow = null;
// this.oobCameraPosition = camera.position.clone();
playGui.setCenterText('outofbounds');
AudioManager.playSound(ResourceLoader.getResource('data/sound/whoosh.wav', ResourceLoader.getAudio, this.soundResources));
// if (this.replay.mode != = 'playback')
this.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2, () -> {
playGui.setCenterText('none');
@ -1820,7 +1733,7 @@ class MarbleWorld extends Scheduler {
// Wait a bit to select the powerup to prevent immediately using it incase the user skipped the OOB screen by clicking
if (this.checkpointHeldPowerup != null)
this.schedule(this.timeState.currentAttemptTime + 0.5, () -> this.pickUpPowerUp(this.checkpointHeldPowerup));
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn.wav', ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
}
public function setCursorLock(enabled:Bool) {

View file

@ -236,19 +236,6 @@ class Mission {
return "";
}
/** Computes the clock time in MBP when the user should be warned that they're about to exceed the par time. */
public function computeAlarmStartTime() {
var alarmStart = this.qualifyTime;
if (this.missionInfo.alarmstarttime != null)
alarmStart -= MisParser.parseNumber(this.missionInfo.alarmstarttime);
else {
alarmStart -= 15;
}
alarmStart = Math.max(0, alarmStart);
return alarmStart;
}
public function download(onFinish:Void->Void) {
if (this.isClaMission) {
Marbleland.download(this.id, (zipEntries) -> {

View file

@ -43,8 +43,8 @@ class AntiGravity extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/gravitychange.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/gravitychange.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/pu_gravity.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/pu_gravity.wav", ResourceLoader.getAudio, this.soundResources);
onFinish();
});
});

View file

@ -20,8 +20,8 @@ class Blast extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/publastvoice.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/publastvoice.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/ultrablast.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/ultrablast.wav", ResourceLoader.getAudio, this.soundResources);
onFinish();
});
});

View file

@ -22,7 +22,7 @@ class EasterEgg extends PowerUp {
}
if (!found) {
Settings.easterEggs.set(this.level.mission.path, this.level.timeState.currentAttemptTime);
this.pickupSound = ResourceLoader.getResource("data/sound/easter.wav", ResourceLoader.getAudio, this.soundResources);
this.pickupSound = ResourceLoader.getResource("data/sound/easter_egg.wav", ResourceLoader.getAudio, this.soundResources);
this.customPickupMessage = "You found an Easter Egg!";
} else {
this.pickupSound = ResourceLoader.getResource("data/sound/easterfound.wav", ResourceLoader.getAudio, this.soundResources);
@ -34,7 +34,7 @@ class EasterEgg extends PowerUp {
public override function init(level:src.MarbleWorld, onFinish:() -> Void) {
super.init(level, () -> {
ResourceLoader.load("sound/easter.wav").entry.load(() -> {
ResourceLoader.load("sound/easter_egg.wav").entry.load(() -> {
ResourceLoader.load("sound/easterfound.wav").entry.load(onFinish);
});
});

View file

@ -35,8 +35,8 @@ class Gem extends DtsObject {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
var worker = new ResourceLoaderWorker(onFinish);
worker.loadFile('sound/gotgem.wav');
worker.loadFile('sound/gotallgems.wav');
worker.loadFile('sound/gem_collect.wav');
worker.loadFile('sound/gem_all.wav');
worker.run();
});
}

View file

@ -21,8 +21,8 @@ class Helicopter extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/pugyrocoptervoice.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/pugyrocoptervoice.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/gyrocopter.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/gyrocopter.wav", ResourceLoader.getAudio, this.soundResources);
onFinish();
});
});

View file

@ -20,15 +20,15 @@ class MegaMarble extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/pumegamarblevoice.wav").entry.load(() -> {
ResourceLoader.load("sound/mega_marble.wav").entry.load(() -> {
var worker = new ResourceLoaderWorker(onFinish);
worker.loadFile("sound/mega_bouncehard1.wav");
worker.loadFile("sound/mega_bouncehard2.wav");
worker.loadFile("sound/mega_bouncehard3.wav");
worker.loadFile("sound/mega_bouncehard4.wav");
worker.loadFile("sound/mega_roll.wav");
worker.loadFile("sound/dosuperjump.wav");
this.pickupSound = ResourceLoader.getResource("data/sound/pumegamarblevoice.wav", ResourceLoader.getAudio, this.soundResources);
worker.loadFile("sound/use_mega.wav");
this.pickupSound = ResourceLoader.getResource("data/sound/mega_marble.wav", ResourceLoader.getAudio, this.soundResources);
worker.run();
});
});
@ -41,7 +41,7 @@ class MegaMarble extends PowerUp {
public function use(timeState:TimeState) {
this.level.marble.enableMegaMarble(timeState.currentAttemptTime);
this.level.deselectPowerUp();
AudioManager.playSound(ResourceLoader.getResource('data/sound/dosuperjump.wav', ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource('data/sound/use_mega.wav', ResourceLoader.getAudio, this.soundResources));
}
override function postProcessMaterial(matName:String, material:h3d.mat.Material) {

View file

@ -51,9 +51,9 @@ class SuperJump extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/pusuperjumpvoice.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperjumpvoice.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/dosuperjump.wav").entry.load(onFinish);
ResourceLoader.load("sound/super_jump.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/super_jump.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/use_superjump.wav").entry.load(onFinish);
});
});
}
@ -68,7 +68,7 @@ class SuperJump extends PowerUp {
this.level.particleManager.createEmitter(superJumpParticleOptions, this.sjEmitterParticleData, null, () -> marble.getAbsPos().getPosition());
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
// if (!this.level.rewinding)
AudioManager.playSound(ResourceLoader.getResource("data/sound/dosuperjump.wav", ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource("data/sound/use_superjump.wav", ResourceLoader.getAudio, this.soundResources));
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
this.level.deselectPowerUp();
}

View file

@ -56,9 +56,9 @@ class SuperSpeed extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/pusuperspeedvoice.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperspeedvoice.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/dosuperspeed.wav").entry.load(onFinish);
ResourceLoader.load("sound/super_speed.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/super_speed.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/use_speed.wav").entry.load(onFinish);
});
});
}
@ -85,7 +85,7 @@ class SuperSpeed extends PowerUp {
// marble.body.addLinearVelocity(Util.vecThreeToOimo(movementVector).scale(24.7)); // Whirligig's determined value
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
// if (!this.level.rewinding)
AudioManager.playSound(ResourceLoader.getResource("data/sound/dosuperspeed.wav", ResourceLoader.getAudio, this.soundResources));
AudioManager.playSound(ResourceLoader.getResource("data/sound/use_speed.wav", ResourceLoader.getAudio, this.soundResources));
this.level.particleManager.createEmitter(superSpeedParticleOptions, this.ssEmitterParticleData, null, () -> marble.getAbsPos().getPosition());
this.level.deselectPowerUp();
}

View file

@ -32,8 +32,8 @@ class TimeTravel extends PowerUp {
public override function init(level:MarbleWorld, onFinish:Void->Void) {
super.init(level, () -> {
ResourceLoader.load("sound/putimetravelvoice.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/putimetravelvoice.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/time_travel.wav").entry.load(() -> {
this.pickupSound = ResourceLoader.getResource("data/sound/time_travel.wav", ResourceLoader.getAudio, this.soundResources);
ResourceLoader.load("sound/timetravelactive.wav").entry.load(onFinish);
});
});

View file

@ -1,5 +0,0 @@
package triggers;
class DestinationTrigger extends Trigger {
// Stub
}

View file

@ -1,132 +0,0 @@
package triggers;
import h3d.Vector;
import src.ResourceLoader;
import src.AudioManager;
import mis.MisParser;
import src.MarbleWorld;
import mis.MissionElement.MissionElementTrigger;
import src.Console;
class TeleportTrigger extends Trigger {
var delay:Float = 2;
var entryTime:Null<Float> = null;
var exitTime:Null<Float> = null;
public function new(element:MissionElementTrigger, level:MarbleWorld) {
super(element, level);
if (element.delay != null)
this.delay = MisParser.parseNumber(element.delay) / 1000;
}
override function onMarbleEnter(time:src.TimeState) {
this.exitTime = null;
this.level.marble.setCloaking(true, time);
if (this.entryTime != null)
return;
this.entryTime = time.currentAttemptTime;
this.level.displayAlert("Teleporter has been activated, please wait.");
AudioManager.playSound(ResourceLoader.getResource("data/sound/teleport.wav", ResourceLoader.getAudio, this.soundResources));
}
override function onMarbleLeave(time:src.TimeState) {
this.exitTime = time.currentAttemptTime;
this.level.marble.setCloaking(false, time);
}
public override function update(timeState:src.TimeState) {
if (this.entryTime == null)
return;
if (timeState.currentAttemptTime - this.entryTime >= this.delay) {
this.executeTeleport();
return;
}
// There's a little delay after exiting before the teleporter gets cancelled
if (this.exitTime != null && timeState.currentAttemptTime - this.exitTime > 0.050) {
this.entryTime = null;
this.exitTime = null;
return;
}
}
override function init(onFinish:() -> Void) {
ResourceLoader.load("sound/teleport.wav").entry.load(onFinish);
}
function executeTeleport() {
this.entryTime = null;
function chooseNonNull(a:String, b:String) {
if (a != null)
return a;
if (b != null)
return b;
return null;
}
// Find the destination trigger
if (this.element.destination == null)
return;
var destinationList = this.level.triggers.filter(x -> x is DestinationTrigger
&& x.element._name.toLowerCase() == this.element.destination.toLowerCase());
if (destinationList.length == 0)
return; // Who knows
var destination = destinationList[0];
var pos = MisParser.parseVector3(destination.element.position);
pos.x = -pos.x;
// Determine where to place the marble
var position:Vector;
if (MisParser.parseBoolean(chooseNonNull(this.element.centerdestpoint, destination.element.centerdestpoint))) {
position = destination.collider.boundingBox.getCenter().toVector(); // Put the marble in the middle of the thing
} else {
position = destination.vertices[0].add(new Vector(0, 0, 3)).add(pos); // destination.vertices[0].clone().add(new Vector(0, 0, 3));
}
position.w = 1;
this.level.marble.prevPos.load(position);
this.level.marble.setPosition(position.x, position.y, position.z);
var ct = this.level.marble.collider.transform.clone();
ct.setPosition(position);
this.level.marble.collider.setTransform(ct);
if (this.level.isRecording) {
this.level.replay.recordMarbleStateFlags(false, false, true, false);
}
if (!MisParser.parseBoolean(chooseNonNull(this.element.keepvelocity, destination.element.keepvelocity)))
this.level.marble.velocity.set(0, 0, 0);
if (MisParser.parseBoolean(chooseNonNull(this.element.inversevelocity, destination.element.inversevelocity)))
this.level.marble.velocity.scale(-1);
if (!MisParser.parseBoolean(chooseNonNull(this.element.keepangular, destination.element.keepangular)))
this.level.marble.omega.set(0, 0, 0);
Console.log('Teleport:');
Console.log('Marble Position: ${position.x} ${position.y} ${position.z}');
Console.log('Marble Velocity: ${this.level.marble.velocity.x} ${this.level.marble.velocity.y} ${this.level.marble.velocity.z}');
Console.log('Marble Angular: ${this.level.marble.omega.x} ${this.level.marble.omega.y} ${this.level.marble.omega.z}');
// Determine camera orientation
if (!MisParser.parseBoolean(chooseNonNull(this.element.keepcamera, destination.element.keepcamera))) {
var yaw:Float;
if (this.element.camerayaw != null)
yaw = MisParser.parseNumber(this.element.camerayaw) * Math.PI / 180;
else if (destination.element.camerayaw != null)
yaw = MisParser.parseNumber(destination.element.camerayaw) * Math.PI / 180;
else
yaw = 0;
yaw = -yaw; // Need to flip it for some reason
this.level.marble.camera.CameraYaw = yaw + Math.PI / 2;
this.level.marble.camera.CameraPitch = 0.45;
this.level.marble.camera.nextCameraYaw = yaw + Math.PI / 2;
this.level.marble.camera.nextCameraPitch = 0.45;
}
AudioManager.playSound(ResourceLoader.getResource("data/sound/spawn.wav", ResourceLoader.getAudio, this.soundResources));
}
}