mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
more mid-game join stuff
This commit is contained in:
parent
b3fab7bc2a
commit
d79ff47598
4 changed files with 31 additions and 2 deletions
|
|
@ -536,6 +536,18 @@ class MarbleWorld extends Scheduler {
|
|||
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();
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
|
@ -1311,6 +1323,8 @@ class MarbleWorld extends Scheduler {
|
|||
var m = arr.packets[0];
|
||||
// if (m.serverTicks == ourLastMoveTime) {
|
||||
var marbleToUpdate = clientMarbles[Net.clientIdMap[client]];
|
||||
if (@:privateAccess marbleToUpdate.newPos == null)
|
||||
continue;
|
||||
// Debug.drawSphere(@:privateAccess marbleToUpdate.newPos, marbleToUpdate._radius);
|
||||
|
||||
// var distFromUs = @:privateAccess marbleToUpdate.newPos.distance(this.marble.newPos);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class CreateMatchGui extends GuiImage {
|
|||
optionCollection.extent = new Vector(815, 500);
|
||||
innerCtrl.addChild(optionCollection);
|
||||
|
||||
var maxPlayers = 2;
|
||||
var maxPlayers = 8;
|
||||
var privateSlots = 0;
|
||||
var privateGame = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -299,6 +299,13 @@ class Net {
|
|||
if (serverInfo.state == "PLAYING") { // We initiated the game, directly add in the marble
|
||||
NetCommands.playLevelMidJoinClient(conn, MultiplayerLevelSelectGui.currentSelectionStatic);
|
||||
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") {
|
||||
// Connect client to lobby
|
||||
|
|
@ -454,7 +461,7 @@ class Net {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
if (MarbleGame.instance.world != null) {
|
||||
MarbleGame.instance.world.serverStartTicks = ticks + 1; // Extra tick so we don't get 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue