mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 13:11:42 +00:00
more mid-game join stuff
This commit is contained in:
parent
2dcb47ffc0
commit
2b4eb2ca4c
4 changed files with 31 additions and 2 deletions
|
|
@ -536,6 +536,18 @@ class MarbleWorld extends Scheduler {
|
||||||
this.initMarble(cc, () -> {
|
this.initMarble(cc, () -> {
|
||||||
var addedMarble = clientMarbles.get(cc);
|
var addedMarble = clientMarbles.get(cc);
|
||||||
this.restart(addedMarble); // spawn it
|
this.restart(addedMarble); // spawn it
|
||||||
|
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||||
|
this.playGui.redrawPlayerList();
|
||||||
|
onAdded();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addJoiningClientGhost(cc:GameConnection, onAdded:() -> Void) {
|
||||||
|
this.initMarble(cc, () -> {
|
||||||
|
var addedMarble = clientMarbles.get(cc);
|
||||||
|
this.restart(addedMarble); // spawn it
|
||||||
|
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||||
|
this.playGui.redrawPlayerList();
|
||||||
onAdded();
|
onAdded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1310,6 +1322,8 @@ class MarbleWorld extends Scheduler {
|
||||||
var m = arr.packets[0];
|
var m = arr.packets[0];
|
||||||
// if (m.serverTicks == ourLastMoveTime) {
|
// if (m.serverTicks == ourLastMoveTime) {
|
||||||
var marbleToUpdate = clientMarbles[Net.clientIdMap[client]];
|
var marbleToUpdate = clientMarbles[Net.clientIdMap[client]];
|
||||||
|
if (@:privateAccess marbleToUpdate.newPos == null)
|
||||||
|
continue;
|
||||||
// Debug.drawSphere(@:privateAccess marbleToUpdate.newPos, marbleToUpdate._radius);
|
// Debug.drawSphere(@:privateAccess marbleToUpdate.newPos, marbleToUpdate._radius);
|
||||||
|
|
||||||
// var distFromUs = @:privateAccess marbleToUpdate.newPos.distance(this.marble.newPos);
|
// var distFromUs = @:privateAccess marbleToUpdate.newPos.distance(this.marble.newPos);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class CreateMatchGui extends GuiImage {
|
||||||
optionCollection.extent = new Vector(815, 500);
|
optionCollection.extent = new Vector(815, 500);
|
||||||
innerCtrl.addChild(optionCollection);
|
innerCtrl.addChild(optionCollection);
|
||||||
|
|
||||||
var maxPlayers = 2;
|
var maxPlayers = 8;
|
||||||
var privateSlots = 0;
|
var privateSlots = 0;
|
||||||
var privateGame = false;
|
var privateGame = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,13 @@ class Net {
|
||||||
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
||||||
NetCommands.playLevelMidJoinClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
NetCommands.playLevelMidJoinClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
||||||
MarbleGame.instance.world.addJoiningClient(conn, () -> {});
|
MarbleGame.instance.world.addJoiningClient(conn, () -> {});
|
||||||
|
var playerInfoBytes = sendPlayerInfosBytes();
|
||||||
|
for (dc => cc in clients) {
|
||||||
|
if (cc != conn) {
|
||||||
|
cc.sendBytes(playerInfoBytes);
|
||||||
|
NetCommands.addMidGameJoinMarbleClient(cc, conn.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (serverInfo.state == "LOBBY") {
|
if (serverInfo.state == "LOBBY") {
|
||||||
// Connect client to lobby
|
// Connect client to lobby
|
||||||
|
|
@ -454,7 +461,7 @@ class Net {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newP) {
|
if (newP) {
|
||||||
AudioManager.playSound(ResourceLoader.getAudio("sounds/spawn_alternate.wav").resource);
|
// AudioManager.playSound(ResourceLoader.getAudio("sounds/spawn_alternate.wav").resource);
|
||||||
}
|
}
|
||||||
if (MarbleGame.canvas.content is MultiplayerLevelSelectGui) {
|
if (MarbleGame.canvas.content is MultiplayerLevelSelectGui) {
|
||||||
cast(MarbleGame.canvas.content, MultiplayerLevelSelectGui).updateLobbyNames();
|
cast(MarbleGame.canvas.content, MultiplayerLevelSelectGui).updateLobbyNames();
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,14 @@ class NetCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:rpc(server) public static function addMidGameJoinMarble(cc:Int) {
|
||||||
|
if (Net.isClient) {
|
||||||
|
if (MarbleGame.instance.world != null) {
|
||||||
|
MarbleGame.instance.world.addJoiningClientGhost(Net.clientIdMap[cc], () -> {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@:rpc(server) public static function setStartTicks(ticks:Int) {
|
@:rpc(server) public static function setStartTicks(ticks:Int) {
|
||||||
if (MarbleGame.instance.world != null) {
|
if (MarbleGame.instance.world != null) {
|
||||||
MarbleGame.instance.world.serverStartTicks = ticks + 1; // Extra tick so we don't get 0
|
MarbleGame.instance.world.serverStartTicks = ticks + 1; // Extra tick so we don't get 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue