mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
get gravity and server stop mission working
This commit is contained in:
parent
ecaa938f95
commit
10093c1ed3
5 changed files with 59 additions and 15 deletions
|
|
@ -1757,8 +1757,8 @@ class Marble extends GameObject {
|
|||
this.blastUseTick = p.blastTick;
|
||||
this.helicopterUseTick = p.heliTick;
|
||||
this.megaMarbleUseTick = p.megaTick;
|
||||
this.currentUp = p.gravityDirection;
|
||||
this.level.setUp(cast this, this.currentUp, this.level.timeState, true);
|
||||
// this.currentUp = p.gravityDirection;
|
||||
this.level.setUp(cast this, p.gravityDirection, this.level.timeState);
|
||||
this.outOfBounds = p.oob;
|
||||
this.camera.oob = p.oob;
|
||||
if (p.powerUpId == 0x1FF) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package src;
|
||||
|
||||
import gui.MultiplayerLevelSelectGui;
|
||||
import net.NetCommands;
|
||||
import net.Net;
|
||||
import gui.LevelSelectGui;
|
||||
import gui.MainMenuGui;
|
||||
|
|
@ -235,6 +237,9 @@ class MarbleGame {
|
|||
quitMission();
|
||||
}));
|
||||
} else {
|
||||
if (Net.isMP && Net.isClient) {
|
||||
Net.disconnect();
|
||||
}
|
||||
quitMission();
|
||||
}
|
||||
}, (sender) -> {
|
||||
|
|
@ -284,7 +289,9 @@ class MarbleGame {
|
|||
public function quitMission() {
|
||||
Console.log("Quitting mission");
|
||||
if (Net.isMP) {
|
||||
Net.disconnect();
|
||||
if (Net.isHost) {
|
||||
NetCommands.endGame();
|
||||
}
|
||||
}
|
||||
var watching = world.isWatching;
|
||||
var missionType = world.mission.type;
|
||||
|
|
@ -310,12 +317,17 @@ class MarbleGame {
|
|||
canvas.setContent(new MainMenuGui());
|
||||
#end
|
||||
} else {
|
||||
var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic);
|
||||
if (_exitingToMenu) {
|
||||
_exitingToMenu = false;
|
||||
canvas.setContent(new MainMenuGui());
|
||||
if (Net.isMP) {
|
||||
var lobby = new MultiplayerLevelSelectGui(Net.isHost);
|
||||
canvas.setContent(lobby);
|
||||
} else {
|
||||
canvas.setContent(pmg);
|
||||
var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic);
|
||||
if (_exitingToMenu) {
|
||||
_exitingToMenu = false;
|
||||
canvas.setContent(new MainMenuGui());
|
||||
} else {
|
||||
canvas.setContent(pmg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1949,10 +1949,20 @@ class MarbleWorld extends Scheduler {
|
|||
MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl);
|
||||
}
|
||||
var endGameCode = () -> {
|
||||
this.dispose();
|
||||
LevelSelectGui.currentSelectionStatic = mission.index + 1;
|
||||
var pmg = new LevelSelectGui(["beginner", "intermediate", "advanced", "multiplayer"][mission.difficultyIndex]);
|
||||
MarbleGame.canvas.setContent(pmg);
|
||||
if (isMultiplayer) {
|
||||
if (Net.isHost) {
|
||||
NetCommands.endGame();
|
||||
}
|
||||
if (Net.isClient) {
|
||||
Net.disconnect();
|
||||
MarbleGame.instance.quitMission();
|
||||
}
|
||||
} else {
|
||||
this.dispose();
|
||||
LevelSelectGui.currentSelectionStatic = mission.index + 1;
|
||||
var pmg = new LevelSelectGui(["beginner", "intermediate", "advanced", "multiplayer"][mission.difficultyIndex]);
|
||||
MarbleGame.canvas.setContent(pmg);
|
||||
}
|
||||
#if js
|
||||
pointercontainer.hidden = false;
|
||||
#end
|
||||
|
|
@ -2048,6 +2058,10 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
/** Get the current interpolated orientation quaternion. */
|
||||
public function getOrientationQuat(time:Float) {
|
||||
if (time < this.orientationChangeTime)
|
||||
return this.oldOrientationQuat;
|
||||
if (time > this.orientationChangeTime + 1.25)
|
||||
return this.newOrientationQuat;
|
||||
var completion = Util.clamp((time - this.orientationChangeTime) / 0.8, 0, 1);
|
||||
var newDt = completion / 0.15;
|
||||
var smooth = 1.0 / (newDt * (newDt * 0.235 * newDt) + newDt + 1.0 + 0.48 * newDt * newDt);
|
||||
|
|
@ -2059,12 +2073,12 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
public function setUp(marble:Marble, vec:Vector, timeState:TimeState, instant:Bool = false) {
|
||||
if (vec == marble.currentUp)
|
||||
if (marble.currentUp == vec)
|
||||
return;
|
||||
marble.currentUp = vec;
|
||||
if (isMultiplayer && Net.isHost) {
|
||||
@:privateAccess marble.netFlags |= MarbleNetFlags.GravityChange;
|
||||
}
|
||||
marble.currentUp = vec;
|
||||
if (marble == this.marble) {
|
||||
var currentQuat = this.getOrientationQuat(timeState.currentAttemptTime);
|
||||
var oldUp = new Vector(0, 0, 1);
|
||||
|
|
|
|||
|
|
@ -120,4 +120,19 @@ class NetCommands {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@:rpc(server) public static function endGame() {
|
||||
if (Net.isClient) {
|
||||
if (MarbleGame.instance.world != null) {
|
||||
MarbleGame.instance.quitMission();
|
||||
}
|
||||
}
|
||||
if (Net.isHost) {
|
||||
for (c => v in Net.clientIdMap) {
|
||||
v.state = LOBBY;
|
||||
v.lobbyReady = false;
|
||||
}
|
||||
Net.lobbyHostReady = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package shapes;
|
||||
|
||||
import net.NetPacket.MarbleNetFlags;
|
||||
import src.Marble;
|
||||
import mis.MisParser;
|
||||
import dts.DtsFile;
|
||||
|
|
@ -40,8 +41,10 @@ class AntiGravity extends PowerUp {
|
|||
direction.transform(this.getRotationQuat().toMatrix());
|
||||
if (marble == level.marble)
|
||||
this.level.setUp(marble, direction, timeState);
|
||||
else
|
||||
else {
|
||||
@:privateAccess marble.netFlags |= MarbleNetFlags.GravityChange;
|
||||
marble.currentUp.load(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue