mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-02 05:12:21 +00:00
server side only quick respawn
This commit is contained in:
parent
f990ed02a7
commit
39fbcc2ec4
8 changed files with 64 additions and 16 deletions
|
|
@ -83,6 +83,15 @@ class Gamepad {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static function releaseKey(buttons:Array<String>) {
|
||||
for (button in buttons) {
|
||||
var buttonId = getId(button);
|
||||
if (buttonId < 0 || buttonId > gamepad.buttons.length)
|
||||
continue;
|
||||
@:privateAccess gamepad.buttons[buttonId] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function isPressed(buttons:Array<String>) {
|
||||
if (!hasPad)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -330,6 +330,7 @@ class Marble extends GameObject {
|
|||
var serverTicks:Int;
|
||||
var recvServerTick:Int;
|
||||
var serverUsePowerup:Bool;
|
||||
var lastRespawnTick:Int = -100000;
|
||||
var trapdoorContacts:Map<Int, Int> = [];
|
||||
|
||||
public function new() {
|
||||
|
|
@ -1049,6 +1050,7 @@ class Marble extends GameObject {
|
|||
a.set(a.x + aFriction.x, a.y + aFriction.y, a.z + aFriction.z);
|
||||
|
||||
lastContactNormal = bestContact.normal;
|
||||
lastContactPosition = this.getAbsPos().getPosition();
|
||||
}
|
||||
a.set(a.x + aControl.x, a.y + aControl.y, a.z + aControl.z);
|
||||
if (this.mode == Finish) {
|
||||
|
|
@ -1863,6 +1865,13 @@ class Marble extends GameObject {
|
|||
for (interior in pathedInteriors) {
|
||||
interior.popTickState();
|
||||
}
|
||||
|
||||
if (m.respawn) {
|
||||
if (timeState.ticks - lastRespawnTick > (25000 >> 5)) {
|
||||
this.level.restart(cast this);
|
||||
lastRespawnTick = timeState.ticks;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2157,6 +2166,12 @@ class Marble extends GameObject {
|
|||
|| Gamepad.isDown(Settings.gamepadSettings.blast))
|
||||
move.blast = true;
|
||||
|
||||
if (Key.isDown(Settings.controlsSettings.respawn) || Gamepad.isDown(Settings.gamepadSettings.respawn)) {
|
||||
move.respawn = true;
|
||||
@:privateAccess Key.keyPressed[Settings.controlsSettings.respawn] = 0;
|
||||
Gamepad.releaseKey(Settings.gamepadSettings.respawn);
|
||||
}
|
||||
|
||||
if (MarbleGame.instance.touchInput.movementInput.pressed) {
|
||||
move.d.y = -MarbleGame.instance.touchInput.movementInput.value.x;
|
||||
move.d.x = MarbleGame.instance.touchInput.movementInput.value.y;
|
||||
|
|
@ -2553,6 +2568,7 @@ class Marble extends GameObject {
|
|||
this.contactEntities = [];
|
||||
this.cloak = false;
|
||||
this._firstTick = true;
|
||||
this.lastRespawnTick = -100000;
|
||||
if (this.teleporting) {
|
||||
var ourDts:DtsObject = cast this.children[0];
|
||||
ourDts.setOpacity(1);
|
||||
|
|
|
|||
|
|
@ -1803,22 +1803,24 @@ class MarbleWorld extends Scheduler {
|
|||
ProfilerUI.measure("updateTimer");
|
||||
this.updateTimer(dt);
|
||||
|
||||
if ((Key.isPressed(Settings.controlsSettings.respawn) || Gamepad.isPressed(Settings.gamepadSettings.respawn))
|
||||
&& this.finishTime == null) {
|
||||
performRestart();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Key.isDown(Settings.controlsSettings.respawn)
|
||||
|| MarbleGame.instance.touchInput.restartButton.pressed
|
||||
|| Gamepad.isDown(Settings.gamepadSettings.respawn))
|
||||
&& !this.isWatching
|
||||
&& this.finishTime == null) {
|
||||
if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
||||
this.restart(this.marble, true);
|
||||
this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
||||
if (!this.isMultiplayer) {
|
||||
if ((Key.isPressed(Settings.controlsSettings.respawn) || Gamepad.isPressed(Settings.gamepadSettings.respawn))
|
||||
&& this.finishTime == null) {
|
||||
performRestart();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Key.isDown(Settings.controlsSettings.respawn)
|
||||
|| MarbleGame.instance.touchInput.restartButton.pressed
|
||||
|| Gamepad.isDown(Settings.gamepadSettings.respawn))
|
||||
&& !this.isWatching
|
||||
&& this.finishTime == null) {
|
||||
if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
||||
this.restart(this.marble, true);
|
||||
this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.tickSchedule(timeState.currentAttemptTime);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import hxd.res.BitmapFont;
|
|||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
import src.Settings;
|
||||
import hxd.Key;
|
||||
|
||||
class MPExitGameDlg extends GuiControl {
|
||||
public function new(resumeFunc:() -> Void, exitFunc:() -> Void) {
|
||||
|
|
@ -93,6 +94,9 @@ class MPExitGameDlg extends GuiControl {
|
|||
quickspawnBtn.position = new Vector(224, 132);
|
||||
quickspawnBtn.extent = new Vector(104, 45);
|
||||
quickspawnBtn.vertSizing = Top;
|
||||
quickspawnBtn.pressedAction = (e) -> {
|
||||
@:privateAccess Key.keyPressed[Settings.controlsSettings.respawn] = Key.getFrame() - 1; // jank
|
||||
}
|
||||
dialogImg.addChild(quickspawnBtn);
|
||||
|
||||
var completeRestart = new GuiButton(loadButtonImagesExt("data/ui/mp/exit/complete"));
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ class MPPlayMissionGui extends GuiImage {
|
|||
leaveBtn.position = new Vector(59, 514);
|
||||
leaveBtn.extent = new Vector(93, 44);
|
||||
leaveBtn.pressedAction = (e) -> {
|
||||
Net.disconnect();
|
||||
MarbleGame.canvas.setContent(new JoinServerGui());
|
||||
}
|
||||
window.addChild(leaveBtn);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class Move {
|
|||
public var jump:Bool;
|
||||
public var powerup:Bool;
|
||||
public var blast:Bool;
|
||||
public var respawn:Bool;
|
||||
|
||||
public function new() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,12 @@ class MoveManager {
|
|||
|| Gamepad.isDown(Settings.gamepadSettings.blast))
|
||||
move.blast = true;
|
||||
|
||||
if (Key.isDown(Settings.controlsSettings.respawn) || Gamepad.isDown(Settings.gamepadSettings.respawn)) {
|
||||
move.respawn = true;
|
||||
@:privateAccess Key.keyPressed[Settings.controlsSettings.respawn] = 0;
|
||||
Gamepad.releaseKey(Settings.gamepadSettings.respawn);
|
||||
}
|
||||
|
||||
if (MarbleGame.instance.touchInput.movementInput.pressed) {
|
||||
move.d.y = -MarbleGame.instance.touchInput.movementInput.value.x;
|
||||
move.d.x = MarbleGame.instance.touchInput.movementInput.value.y;
|
||||
|
|
@ -159,6 +165,7 @@ class MoveManager {
|
|||
b.writeFlag(m.move.jump);
|
||||
b.writeFlag(m.move.powerup);
|
||||
b.writeFlag(m.move.blast);
|
||||
b.writeFlag(m.move.respawn);
|
||||
b.writeFloat(m.motionDir.x);
|
||||
b.writeFloat(m.motionDir.y);
|
||||
b.writeFloat(m.motionDir.z);
|
||||
|
|
@ -174,6 +181,7 @@ class MoveManager {
|
|||
move.jump = b.readFlag();
|
||||
move.powerup = b.readFlag();
|
||||
move.blast = b.readFlag();
|
||||
move.respawn = b.readFlag();
|
||||
var motionDir = new Vector();
|
||||
motionDir.x = b.readFloat();
|
||||
motionDir.y = b.readFloat();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package touch;
|
|||
import src.MarbleGame;
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
import src.Settings;
|
||||
import hxd.Key;
|
||||
|
||||
class RestartButton extends TouchButton {
|
||||
public function new() {
|
||||
|
|
@ -11,8 +13,13 @@ class RestartButton extends TouchButton {
|
|||
this.guiElement.horizSizing = Right;
|
||||
this.guiElement.vertSizing = Bottom;
|
||||
this.onClick = () -> {
|
||||
if (MarbleGame.instance.world.finishTime == null && !MarbleGame.instance.paused)
|
||||
MarbleGame.instance.world.performRestart();
|
||||
if (MarbleGame.instance.world.finishTime == null && !MarbleGame.instance.paused) {
|
||||
if (MarbleGame.instance.world.isMultiplayer) {
|
||||
@:privateAccess Key.keyPressed[Settings.controlsSettings.respawn] = Key.getFrame() - 1; // jank
|
||||
} else {
|
||||
MarbleGame.instance.world.performRestart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue