mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
get OOBs working sorta without sound
This commit is contained in:
parent
3b16113d02
commit
3bf672df9a
12 changed files with 149 additions and 132 deletions
|
|
@ -249,6 +249,10 @@ class Marble extends GameObject {
|
|||
public var lastContactPosition:Vector;
|
||||
public var currentUp = new Vector(0, 0, 1);
|
||||
|
||||
public var outOfBounds:Bool = false;
|
||||
public var outOfBoundsTime:TimeState;
|
||||
public var oobSchedule:Float;
|
||||
|
||||
var helicopter:HelicopterImage;
|
||||
var blastWave:BlastWave;
|
||||
var helicopterEnableTime:Float = -1e8;
|
||||
|
|
@ -567,14 +571,15 @@ class Marble extends GameObject {
|
|||
A = A.multiply(0.25);
|
||||
}
|
||||
if (this.level != null) {
|
||||
var mass = this.getMass();
|
||||
for (obj in level.forceObjects) {
|
||||
var force = cast(obj, ForceObject).getForce(this.collider.transform.getPosition());
|
||||
A = A.add(force.multiply(1 / _mass));
|
||||
A = A.add(force.multiply(1 / mass));
|
||||
}
|
||||
for (marble in level.marbles) {
|
||||
if (marble != this) {
|
||||
var force = marble.getForce(this.collider.transform.getPosition(), tick);
|
||||
A = A.add(force.multiply(1 / _mass));
|
||||
A = A.add(force.multiply(1 / mass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -603,7 +608,7 @@ class Marble extends GameObject {
|
|||
if (forceObjectCount != 0) {
|
||||
contactNormal.normalize();
|
||||
|
||||
var a = contactForce / this._mass;
|
||||
var a = contactForce / this.getMass();
|
||||
var dot = this.velocity.dot(contactNormal);
|
||||
if (a > dot) {
|
||||
if (dot > 0)
|
||||
|
|
@ -699,8 +704,8 @@ class Marble extends GameObject {
|
|||
} else if (contacts[i].collider != null) {
|
||||
var otherMarble:Marble = cast contacts[i].collider.go;
|
||||
|
||||
var ourMass = this._mass;
|
||||
var theirMass = otherMarble._mass;
|
||||
var ourMass = this.getMass();
|
||||
var theirMass = otherMarble.getMass();
|
||||
|
||||
var bounce = Math.max(this._bounceRestitution, otherMarble._bounceRestitution);
|
||||
|
||||
|
|
@ -1599,7 +1604,7 @@ class Marble extends GameObject {
|
|||
this.collisionWorld.updateTransform(this.collider);
|
||||
this.collider.velocity = this.velocity;
|
||||
|
||||
if (this.heldPowerup != null && m.powerup && !this.level.outOfBounds) {
|
||||
if (this.heldPowerup != null && m.powerup && !this.outOfBounds) {
|
||||
var pTime = timeState.clone();
|
||||
pTime.dt = timeStep;
|
||||
pTime.currentAttemptTime = passedTime;
|
||||
|
|
@ -1664,6 +1669,7 @@ class Marble extends GameObject {
|
|||
marbleUpdate.blastTick = this.blastUseTick;
|
||||
marbleUpdate.heliTick = this.helicopterUseTick;
|
||||
marbleUpdate.megaTick = this.megaMarbleUseTick;
|
||||
marbleUpdate.oob = this.outOfBounds;
|
||||
marbleUpdate.serialize(b);
|
||||
return b.getBytes();
|
||||
}
|
||||
|
|
@ -1686,6 +1692,8 @@ class Marble extends GameObject {
|
|||
this.blastUseTick = p.blastTick;
|
||||
this.helicopterUseTick = p.heliTick;
|
||||
this.megaMarbleUseTick = p.megaTick;
|
||||
this.outOfBounds = p.oob;
|
||||
this.camera.oob = p.oob;
|
||||
if (this.controllable && Net.isClient) {
|
||||
// We are client, need to do something about the queue
|
||||
var mm = Net.clientConnection.moveManager;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ class MarbleGame {
|
|||
@:privateAccess world.playGui.setGuiVisibility(true);
|
||||
canvas.popDialog(exitGameDlg);
|
||||
var w = getWorld();
|
||||
w.restart(true);
|
||||
w.restart(w.marble, true);
|
||||
// world.setCursorLock(true);
|
||||
paused = !paused;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -152,8 +152,6 @@ class MarbleWorld extends Scheduler {
|
|||
public var game:String;
|
||||
|
||||
public var marble:Marble;
|
||||
public var outOfBounds:Bool = false;
|
||||
public var outOfBoundsTime:TimeState;
|
||||
public var finishTime:TimeState;
|
||||
public var finishPitch:Float;
|
||||
public var finishYaw:Float;
|
||||
|
|
@ -231,7 +229,6 @@ class MarbleWorld extends Scheduler {
|
|||
var soundResources:Array<Resource<Sound>> = [];
|
||||
|
||||
var oobSchedule:Float;
|
||||
var oobSchedule2:Float;
|
||||
|
||||
var _cubemapNeedsUpdate:Bool = false;
|
||||
|
||||
|
|
@ -483,7 +480,7 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
public function start() {
|
||||
Console.log("LEVEL START");
|
||||
restart(true);
|
||||
restart(this.marble, true);
|
||||
for (interior in this.interiors)
|
||||
interior.onLevelStart();
|
||||
for (shape in this.dtsObjects)
|
||||
|
|
@ -492,7 +489,7 @@ class MarbleWorld extends Scheduler {
|
|||
NetCommands.clientIsReady(Net.clientId);
|
||||
}
|
||||
|
||||
public function restart(full:Bool = false) {
|
||||
public function restart(marble:Marble, full:Bool = false) {
|
||||
Console.log("LEVEL RESTART");
|
||||
if (!full && this.currentCheckpoint != null) {
|
||||
this.loadCheckpointState();
|
||||
|
|
@ -502,7 +499,7 @@ class MarbleWorld extends Scheduler {
|
|||
if (!full) {
|
||||
var respawnT = this.gameMode.getRespawnTransform();
|
||||
if (respawnT != null) {
|
||||
respawn(respawnT.position, respawnT.orientation, respawnT.up);
|
||||
respawn(marble, respawnT.position, respawnT.orientation, respawnT.up);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -518,10 +515,10 @@ class MarbleWorld extends Scheduler {
|
|||
this.timeState.currentAttemptTime = 0;
|
||||
this.timeState.gameplayClock = this.gameMode.getStartTime();
|
||||
this.bonusTime = 0;
|
||||
this.outOfBounds = false;
|
||||
this.marble.outOfBounds = false;
|
||||
this.marble.blastAmount = 0;
|
||||
this.renderBlastAmount = 0;
|
||||
this.outOfBoundsTime = null;
|
||||
this.marble.outOfBoundsTime = null;
|
||||
this.finishTime = null;
|
||||
this.skipStartBugPauseTime = 0.0;
|
||||
|
||||
|
|
@ -564,7 +561,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
this.cancel(this.oobSchedule);
|
||||
this.cancel(this.oobSchedule2);
|
||||
this.cancel(this.marble.oobSchedule);
|
||||
|
||||
var startquat = this.gameMode.getSpawnTransform();
|
||||
|
||||
|
|
@ -584,6 +581,7 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
if (isMultiplayer) {
|
||||
for (client => marble in clientMarbles) {
|
||||
this.cancel(marble.oobSchedule);
|
||||
var marbleStartQuat = this.gameMode.getSpawnTransform();
|
||||
marble.setMarblePosition(marbleStartQuat.position.x, marbleStartQuat.position.y, marbleStartQuat.position.z);
|
||||
marble.reset();
|
||||
|
|
@ -601,7 +599,7 @@ class MarbleWorld extends Scheduler {
|
|||
for (interior in this.interiors)
|
||||
interior.reset();
|
||||
|
||||
this.setUp(startquat.up, this.timeState, true);
|
||||
this.setUp(this.marble, startquat.up, this.timeState, true);
|
||||
this.deselectPowerUp(this.marble);
|
||||
playGui.setCenterText('');
|
||||
|
||||
|
|
@ -612,10 +610,9 @@ class MarbleWorld extends Scheduler {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public function respawn(respawnPos:Vector, respawnQuat:Quat, respawnUp:Vector) {
|
||||
var marble = this.marble;
|
||||
public function respawn(marble:Marble, respawnPos:Vector, respawnQuat:Quat, respawnUp:Vector) {
|
||||
// Determine where to spawn the marble
|
||||
this.marble.setMarblePosition(respawnPos.x, respawnPos.y, respawnPos.z);
|
||||
marble.setMarblePosition(respawnPos.x, respawnPos.y, respawnPos.z);
|
||||
marble.velocity.set(0, 0, 0);
|
||||
marble.omega.set(0, 0, 0);
|
||||
Console.log('Respawn:');
|
||||
|
|
@ -624,15 +621,20 @@ class MarbleWorld extends Scheduler {
|
|||
Console.log('Marble Angular: ${marble.omega.x} ${marble.omega.y} ${marble.omega.z}');
|
||||
// Set camera orientation
|
||||
var euler = respawnQuat.toEuler();
|
||||
this.marble.camera.CameraYaw = euler.z + Math.PI / 2;
|
||||
this.marble.camera.CameraPitch = 0.45;
|
||||
this.marble.camera.nextCameraYaw = this.marble.camera.CameraYaw;
|
||||
this.marble.camera.nextCameraPitch = this.marble.camera.CameraPitch;
|
||||
this.marble.camera.oob = false;
|
||||
@:privateAccess this.marble.helicopterEnableTime = -1e8;
|
||||
@:privateAccess this.marble.megaMarbleEnableTime = -1e8;
|
||||
marble.camera.CameraYaw = euler.z + Math.PI / 2;
|
||||
marble.camera.CameraPitch = 0.45;
|
||||
marble.camera.nextCameraYaw = marble.camera.CameraYaw;
|
||||
marble.camera.nextCameraPitch = marble.camera.CameraPitch;
|
||||
marble.camera.oob = false;
|
||||
if (isMultiplayer) {
|
||||
marble.megaMarbleUseTick = 0;
|
||||
marble.helicopterUseTick = 0;
|
||||
} else {
|
||||
@:privateAccess marble.helicopterEnableTime = -1e8;
|
||||
@:privateAccess marble.megaMarbleEnableTime = -1e8;
|
||||
}
|
||||
if (this.isRecording) {
|
||||
this.replay.recordCameraState(this.marble.camera.CameraYaw, this.marble.camera.CameraPitch);
|
||||
this.replay.recordCameraState(marble.camera.CameraYaw, marble.camera.CameraPitch);
|
||||
this.replay.recordMarbleInput(0, 0);
|
||||
this.replay.recordMarbleState(respawnPos, marble.velocity, marble.getRotationQuat(), marble.omega);
|
||||
this.replay.recordMarbleStateFlags(false, false, true, false);
|
||||
|
|
@ -641,13 +643,16 @@ class MarbleWorld extends Scheduler {
|
|||
// 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(respawnQuat.toMatrix());
|
||||
this.setUp(up, this.timeState, true);
|
||||
this.setUp(marble, up, this.timeState, true);
|
||||
|
||||
this.playGui.setCenterText('');
|
||||
this.clearSchedule();
|
||||
this.outOfBounds = false;
|
||||
this.gameMode.onRespawn();
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
if (marble == this.marble)
|
||||
this.playGui.setCenterText('');
|
||||
if (!this.isMultiplayer)
|
||||
this.clearSchedule();
|
||||
marble.outOfBounds = false;
|
||||
this.gameMode.onRespawn(marble);
|
||||
if (marble == this.marble)
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
|
||||
public function allClientsReady() {
|
||||
|
|
@ -655,7 +660,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function updateGameState() {
|
||||
if (this.outOfBounds)
|
||||
if (this.marble.outOfBounds)
|
||||
return; // We will update state manually
|
||||
if (!this.isMultiplayer) {
|
||||
if (this.timeState.currentAttemptTime < 0.5) {
|
||||
|
|
@ -1024,7 +1029,7 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
public function performRestart() {
|
||||
this.respawnPressedTime = timeState.timeSinceLoad;
|
||||
this.restart();
|
||||
this.restart(this.marble);
|
||||
if (!this.isWatching) {
|
||||
Settings.playStatistics.respawns++;
|
||||
|
||||
|
|
@ -1143,9 +1148,6 @@ class MarbleWorld extends Scheduler {
|
|||
for (pw in marble.level.powerUps) {
|
||||
pw.lastPickUpTime = mvs.shift();
|
||||
}
|
||||
@:privateAccess marble.helicopterEnableTime = qm.helicopterState;
|
||||
@:privateAccess marble.megaMarbleEnableTime = qm.megaState;
|
||||
marble.blastAmount = qm.blastAmt;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1171,7 +1173,7 @@ class MarbleWorld extends Scheduler {
|
|||
if (distFromUs < 5)
|
||||
m.calculationTicks = ourQueuedMoves.length; // ourQueuedMoves.length;
|
||||
else
|
||||
m.calculationTicks = Std.int(Math.max(1, ourQueuedMoves.length - (distFromUs - 5) / 5));
|
||||
m.calculationTicks = Std.int(Math.max(1, ourQueuedMoves.length - (distFromUs - 5) / 3));
|
||||
// - Std.int((@:privateAccess Net.clientConnection.moveManager.ackRTT - ourLastMove.moveQueueSize) / 2);
|
||||
|
||||
marblesToTick.set(client, m);
|
||||
|
|
@ -1378,7 +1380,7 @@ class MarbleWorld extends Scheduler {
|
|||
// Replay gravity
|
||||
if (this.isWatching) {
|
||||
if (this.replay.currentPlaybackFrame.gravityChange) {
|
||||
this.setUp(this.replay.currentPlaybackFrame.gravity, timeState, this.replay.currentPlaybackFrame.gravityInstant);
|
||||
this.setUp(this.marble, this.replay.currentPlaybackFrame.gravity, timeState, this.replay.currentPlaybackFrame.gravityInstant);
|
||||
}
|
||||
if (this.replay.currentPlaybackFrame.powerupPickup != null) {
|
||||
this.pickUpPowerUpReplay(this.replay.currentPlaybackFrame.powerupPickup);
|
||||
|
|
@ -1474,11 +1476,11 @@ class MarbleWorld extends Scheduler {
|
|||
ProfilerUI.measure("updateAudio");
|
||||
AudioManager.update(this.scene);
|
||||
|
||||
if (this.outOfBounds
|
||||
if (this.marble.outOfBounds
|
||||
&& this.finishTime == null
|
||||
&& (Key.isDown(Settings.controlsSettings.jump) || Gamepad.isDown(Settings.gamepadSettings.jump))
|
||||
&& !this.isWatching) {
|
||||
this.restart();
|
||||
this.restart(this.marble);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1817,7 +1819,7 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
function touchFinish() {
|
||||
if (this.finishTime != null
|
||||
|| (this.outOfBounds && this.timeState.currentAttemptTime - this.outOfBoundsTime.currentAttemptTime >= 0.5))
|
||||
|| (this.marble.outOfBounds && this.timeState.currentAttemptTime - this.marble.outOfBoundsTime.currentAttemptTime >= 0.5))
|
||||
return;
|
||||
|
||||
if (this.gemCount < this.totalGems) {
|
||||
|
|
@ -1904,7 +1906,7 @@ class MarbleWorld extends Scheduler {
|
|||
var restartGameCode = () -> {
|
||||
MarbleGame.canvas.popDialog(egg);
|
||||
playGui.setGuiVisibility(true);
|
||||
this.restart(true);
|
||||
this.restart(this.marble, true);
|
||||
#if js
|
||||
pointercontainer.hidden = true;
|
||||
#end
|
||||
|
|
@ -1993,64 +1995,66 @@ class MarbleWorld extends Scheduler {
|
|||
return q;
|
||||
}
|
||||
|
||||
public function setUp(vec:Vector, timeState:TimeState, instant:Bool = false) {
|
||||
this.marble.currentUp = vec;
|
||||
var currentQuat = this.getOrientationQuat(timeState.currentAttemptTime);
|
||||
var oldUp = new Vector(0, 0, 1);
|
||||
oldUp.transform(currentQuat.toMatrix());
|
||||
public function setUp(marble:Marble, vec:Vector, timeState:TimeState, instant:Bool = false) {
|
||||
marble.currentUp = vec;
|
||||
if (marble == this.marble) {
|
||||
var currentQuat = this.getOrientationQuat(timeState.currentAttemptTime);
|
||||
var oldUp = new Vector(0, 0, 1);
|
||||
oldUp.transform(currentQuat.toMatrix());
|
||||
|
||||
function getRotQuat(v1:Vector, v2:Vector) {
|
||||
function orthogonal(v:Vector) {
|
||||
var x = Math.abs(v.x);
|
||||
var y = Math.abs(v.y);
|
||||
var z = Math.abs(v.z);
|
||||
var other = x < y ? (x < z ? new Vector(1, 0, 0) : new Vector(0, 0, 1)) : (y < z ? new Vector(0, 1, 0) : new Vector(0, 0, 1));
|
||||
return v.cross(other);
|
||||
}
|
||||
function getRotQuat(v1:Vector, v2:Vector) {
|
||||
function orthogonal(v:Vector) {
|
||||
var x = Math.abs(v.x);
|
||||
var y = Math.abs(v.y);
|
||||
var z = Math.abs(v.z);
|
||||
var other = x < y ? (x < z ? new Vector(1, 0, 0) : new Vector(0, 0, 1)) : (y < z ? new Vector(0, 1, 0) : new Vector(0, 0, 1));
|
||||
return v.cross(other);
|
||||
}
|
||||
|
||||
var u = v1.normalized();
|
||||
var v = v2.normalized();
|
||||
if (Math.abs(u.dot(v) + 1) < hxd.Math.EPSILON) {
|
||||
var u = v1.normalized();
|
||||
var v = v2.normalized();
|
||||
if (Math.abs(u.dot(v) + 1) < hxd.Math.EPSILON) {
|
||||
var q = new Quat();
|
||||
var o = orthogonal(u).normalized();
|
||||
q.x = o.x;
|
||||
q.y = o.y;
|
||||
q.z = o.z;
|
||||
q.w = 0;
|
||||
return q;
|
||||
}
|
||||
var half = u.add(v).normalized();
|
||||
var q = new Quat();
|
||||
var o = orthogonal(u).normalized();
|
||||
q.x = o.x;
|
||||
q.y = o.y;
|
||||
q.z = o.z;
|
||||
q.w = 0;
|
||||
q.w = u.dot(half);
|
||||
var vr = u.cross(half);
|
||||
q.x = vr.x;
|
||||
q.y = vr.y;
|
||||
q.z = vr.z;
|
||||
return q;
|
||||
}
|
||||
var half = u.add(v).normalized();
|
||||
var q = new Quat();
|
||||
q.w = u.dot(half);
|
||||
var vr = u.cross(half);
|
||||
q.x = vr.x;
|
||||
q.y = vr.y;
|
||||
q.z = vr.z;
|
||||
return q;
|
||||
|
||||
var quatChange = getRotQuat(oldUp, vec);
|
||||
// Instead of calculating the new quat from nothing, calculate it from the last one to guarantee the shortest possible rotation.
|
||||
// quatChange.initMoveTo(oldUp, vec);
|
||||
quatChange.multiply(quatChange, currentQuat);
|
||||
|
||||
if (this.isRecording) {
|
||||
this.replay.recordGravity(vec, instant);
|
||||
}
|
||||
|
||||
this.newOrientationQuat = quatChange;
|
||||
this.oldOrientationQuat = currentQuat;
|
||||
this.orientationChangeTime = instant ? -1e8 : timeState.currentAttemptTime;
|
||||
}
|
||||
|
||||
var quatChange = getRotQuat(oldUp, vec);
|
||||
// Instead of calculating the new quat from nothing, calculate it from the last one to guarantee the shortest possible rotation.
|
||||
// quatChange.initMoveTo(oldUp, vec);
|
||||
quatChange.multiply(quatChange, currentQuat);
|
||||
|
||||
if (this.isRecording) {
|
||||
this.replay.recordGravity(vec, instant);
|
||||
}
|
||||
|
||||
this.newOrientationQuat = quatChange;
|
||||
this.oldOrientationQuat = currentQuat;
|
||||
this.orientationChangeTime = instant ? -1e8 : timeState.currentAttemptTime;
|
||||
}
|
||||
|
||||
public function goOutOfBounds() {
|
||||
if (this.outOfBounds || this.finishTime != null)
|
||||
public function goOutOfBounds(marble:Marble) {
|
||||
if (marble.outOfBounds || this.finishTime != null)
|
||||
return;
|
||||
// this.updateCamera(this.timeState); // Update the camera at the point of OOB-ing
|
||||
this.outOfBounds = true;
|
||||
this.outOfBoundsTime = this.timeState.clone();
|
||||
this.marble.camera.oob = true;
|
||||
if (!this.isWatching) {
|
||||
marble.outOfBounds = true;
|
||||
marble.outOfBoundsTime = this.timeState.clone();
|
||||
marble.camera.oob = true;
|
||||
if (!this.isWatching && !this.isMultiplayer) {
|
||||
Settings.playStatistics.oobs++;
|
||||
if (!Settings.levelStatistics.exists(mission.path)) {
|
||||
Settings.levelStatistics.set(mission.path, {
|
||||
|
|
@ -2061,19 +2065,24 @@ class MarbleWorld extends Scheduler {
|
|||
} else {
|
||||
Settings.levelStatistics[mission.path].oobs++;
|
||||
}
|
||||
|
||||
// sky.follow = null;
|
||||
// this.oobCameraPosition = camera.position.clone();
|
||||
}
|
||||
if (marble == this.marble) {
|
||||
playGui.setCenterText('Out of Bounds');
|
||||
// if (this.replay.mode != = 'playback')
|
||||
this.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2, () -> {
|
||||
playGui.setCenterText('');
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if (Net.isHost) {
|
||||
marble.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2.5, () -> {
|
||||
this.restart(marble);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
// sky.follow = null;
|
||||
// this.oobCameraPosition = camera.position.clone();
|
||||
playGui.setCenterText('Out of Bounds');
|
||||
// if (this.replay.mode != = 'playback')
|
||||
this.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2, () -> {
|
||||
playGui.setCenterText('');
|
||||
return null;
|
||||
});
|
||||
this.oobSchedule2 = this.schedule(this.timeState.currentAttemptTime + 2.5, () -> {
|
||||
this.restart();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/** Sets a new active checkpoint. */
|
||||
|
|
@ -2087,7 +2096,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
checkpointSequence = trigger.seqNum;
|
||||
// (shape.srcElement as any) ?.disableOob || trigger?.element.disableOob;
|
||||
if (disableOob && this.outOfBounds)
|
||||
if (disableOob && this.marble.outOfBounds)
|
||||
return false; // The checkpoint is configured to not work when the player is already OOB
|
||||
this.currentCheckpoint = shape;
|
||||
this.currentCheckpointTrigger = trigger;
|
||||
|
|
@ -2145,7 +2154,7 @@ class MarbleWorld extends Scheduler {
|
|||
// 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);
|
||||
this.setUp(marble, up, this.timeState, true);
|
||||
|
||||
// Restore gem states
|
||||
for (gem in this.gems) {
|
||||
|
|
@ -2157,7 +2166,7 @@ class MarbleWorld extends Scheduler {
|
|||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||
this.playGui.setCenterText('');
|
||||
this.clearSchedule();
|
||||
this.outOfBounds = false;
|
||||
this.marble.outOfBounds = false;
|
||||
this.deselectPowerUp(this.marble); // Always deselect first
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package modes;
|
||||
|
||||
import src.Marble;
|
||||
import rewind.RewindableState;
|
||||
import shapes.Gem;
|
||||
import h3d.Quat;
|
||||
|
|
@ -24,7 +25,7 @@ interface GameMode {
|
|||
public function applyRewindState(state:RewindableState):Void;
|
||||
public function onTimeExpire():Void;
|
||||
public function onRestart():Void;
|
||||
public function onRespawn():Void;
|
||||
public function onRespawn(marble:Marble):Void;
|
||||
public function onGemPickup(gem:Gem):Void;
|
||||
|
||||
public function getPreloadFiles():Array<String>;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import mis.MissionElement.MissionElementSpawnSphere;
|
|||
import src.AudioManager;
|
||||
import src.ResourceLoader;
|
||||
import src.Settings;
|
||||
import src.Marble;
|
||||
|
||||
@:publicFields
|
||||
class GemSpawnSphere {
|
||||
|
|
@ -240,7 +241,7 @@ class HuntMode extends NullMode {
|
|||
return null;
|
||||
}
|
||||
|
||||
override function onRespawn() {
|
||||
override function onRespawn(marble:Marble) {
|
||||
if (activeGemSpawnGroup.length != 0) {
|
||||
var gemAvg = new Vector();
|
||||
for (gi in activeGemSpawnGroup) {
|
||||
|
|
@ -248,15 +249,15 @@ class HuntMode extends NullMode {
|
|||
gemAvg = gemAvg.add(g.position);
|
||||
}
|
||||
gemAvg.scale(1 / activeGemSpawnGroup.length);
|
||||
var delta = gemAvg.sub(level.marble.getAbsPos().getPosition());
|
||||
var delta = gemAvg.sub(marble.getAbsPos().getPosition());
|
||||
var gravFrame = level.getOrientationQuat(0).toMatrix();
|
||||
var v1 = gravFrame.front();
|
||||
var v2 = gravFrame.right();
|
||||
var deltaRot = new Vector(delta.dot(v2), delta.dot(v1));
|
||||
if (deltaRot.length() >= 0.001) {
|
||||
var ang = Math.atan2(deltaRot.x, deltaRot.y);
|
||||
level.marble.camera.CameraYaw = ang;
|
||||
level.marble.camera.nextCameraYaw = ang;
|
||||
marble.camera.CameraYaw = ang;
|
||||
marble.camera.nextCameraYaw = ang;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -477,7 +478,7 @@ class HuntMode extends NullMode {
|
|||
level.finishPitch = level.marble.camera.CameraPitch;
|
||||
level.displayAlert("Congratulations! You've finished!");
|
||||
level.cancel(@:privateAccess level.oobSchedule);
|
||||
level.cancel(@:privateAccess level.oobSchedule2);
|
||||
level.cancel(@:privateAccess level.marble.oobSchedule);
|
||||
if (!level.isWatching) {
|
||||
var myScore = {
|
||||
name: "Player",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package modes;
|
||||
|
||||
import src.Marble;
|
||||
import rewind.RewindableState;
|
||||
import modes.GameMode.ScoreType;
|
||||
import shapes.Gem;
|
||||
|
|
@ -56,7 +57,7 @@ class NullMode implements GameMode {
|
|||
|
||||
public function onRestart() {}
|
||||
|
||||
public function onRespawn() {}
|
||||
public function onRespawn(marble:Marble) {}
|
||||
|
||||
public function onGemPickup(gem:Gem) {
|
||||
this.level.gemCount++;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,6 @@ class NetMove {
|
|||
// For rewind purposes
|
||||
var powerup:PowerUp;
|
||||
var powerupStates:Array<Float>;
|
||||
var helicopterState:Float;
|
||||
var megaState:Float;
|
||||
var blastAmt:Float;
|
||||
|
||||
public function new(move:Move, motionDir:Vector, timeState:TimeState, id:Int) {
|
||||
this.move = move;
|
||||
|
|
@ -101,9 +98,6 @@ class MoveManager {
|
|||
var netMove = new NetMove(move, motionDir, timeState.clone(), nextMoveId++);
|
||||
netMove.powerup = marble.heldPowerup;
|
||||
netMove.powerupStates = [];
|
||||
netMove.helicopterState = @:privateAccess marble.helicopterEnableTime;
|
||||
netMove.megaState = @:privateAccess marble.megaMarbleEnableTime;
|
||||
netMove.blastAmt = marble.blastAmount;
|
||||
for (pw in marble.level.powerUps) {
|
||||
netMove.powerupStates.push(pw.lastPickUpTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class MarbleUpdatePacket implements NetPacket {
|
|||
var blastTick:Int;
|
||||
var megaTick:Int;
|
||||
var heliTick:Int;
|
||||
var oob:Bool;
|
||||
var moveQueueSize:Int;
|
||||
|
||||
public function new() {}
|
||||
|
|
@ -64,6 +65,7 @@ class MarbleUpdatePacket implements NetPacket {
|
|||
b.writeUInt16(blastTick);
|
||||
b.writeUInt16(heliTick);
|
||||
b.writeUInt16(megaTick);
|
||||
b.writeByte(oob ? 1 : 0);
|
||||
}
|
||||
|
||||
public inline function deserialize(b:haxe.io.BytesInput) {
|
||||
|
|
@ -78,5 +80,6 @@ class MarbleUpdatePacket implements NetPacket {
|
|||
blastTick = b.readUInt16();
|
||||
heliTick = b.readUInt16();
|
||||
megaTick = b.readUInt16();
|
||||
oob = b.readByte() != 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ class RewindManager {
|
|||
}
|
||||
rf.blastAmt = level.marble.blastAmount;
|
||||
rf.oobState = {
|
||||
oob: level.outOfBounds,
|
||||
timeState: level.outOfBoundsTime != null ? level.outOfBoundsTime.clone() : null
|
||||
oob: level.marble.outOfBounds,
|
||||
timeState: level.marble.outOfBoundsTime != null ? level.marble.outOfBoundsTime.clone() : null
|
||||
};
|
||||
rf.checkpointState = {
|
||||
currentCheckpoint: @:privateAccess level.currentCheckpoint,
|
||||
|
|
@ -148,7 +148,7 @@ class RewindManager {
|
|||
if (level.marble.currentUp.x != rf.currentUp.x
|
||||
|| level.marble.currentUp.y != rf.currentUp.y
|
||||
|| level.marble.currentUp.z != rf.currentUp.z) {
|
||||
level.setUp(rf.currentUp, level.timeState);
|
||||
level.setUp(level.marble, rf.currentUp, level.timeState);
|
||||
// Hacky things
|
||||
@:privateAccess level.orientationChangeTime = level.timeState.currentAttemptTime - 300;
|
||||
var oldorient = level.newOrientationQuat;
|
||||
|
|
@ -203,18 +203,18 @@ class RewindManager {
|
|||
|
||||
if (!rf.oobState.oob) {
|
||||
@:privateAccess level.cancel(level.oobSchedule);
|
||||
@:privateAccess level.cancel(level.oobSchedule2);
|
||||
@:privateAccess level.cancel(level.marble.oobSchedule);
|
||||
} else {
|
||||
level.goOutOfBounds();
|
||||
level.goOutOfBounds(level.marble);
|
||||
}
|
||||
|
||||
level.outOfBounds = rf.oobState.oob;
|
||||
if (level.outOfBounds)
|
||||
level.marble.outOfBounds = rf.oobState.oob;
|
||||
if (level.marble.outOfBounds)
|
||||
@:privateAccess level.playGui.setCenterText('Out of Bounds');
|
||||
else
|
||||
@:privateAccess level.playGui.setCenterText('');
|
||||
level.marble.camera.oob = rf.oobState.oob;
|
||||
level.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null;
|
||||
level.marble.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null;
|
||||
level.marble.blastAmount = rf.blastAmt;
|
||||
@:privateAccess level.checkpointCollectedGems = rf.checkpointState.checkpointCollectedGems;
|
||||
@:privateAccess level.cheeckpointBlast = rf.checkpointState.checkpointBlast;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class AntiGravity extends PowerUp {
|
|||
var direction = new Vector(0, 0, -1);
|
||||
direction.transform(this.getRotationQuat().toMatrix());
|
||||
if (marble == level.marble)
|
||||
this.level.setUp(direction, timeState);
|
||||
this.level.setUp(marble, direction, timeState);
|
||||
else
|
||||
marble.currentUp.load(direction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import src.Marble;
|
|||
|
||||
class InBoundsTrigger extends Trigger {
|
||||
override function onMarbleLeave(marble:Marble, timeState:TimeState) {
|
||||
this.level.goOutOfBounds();
|
||||
this.level.goOutOfBounds(marble);
|
||||
// this.level.replay.recordMarbleLeave(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import src.Marble;
|
|||
|
||||
class OutOfBoundsTrigger extends Trigger {
|
||||
override function onMarbleInside(marble:Marble, time:TimeState) {
|
||||
this.level.goOutOfBounds();
|
||||
this.level.goOutOfBounds(marble);
|
||||
// this.level.replay.recordMarbleInside(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue