Skip to content

Commit

Permalink
Merge pull request #35 from RoddieKieley/godot62970
Browse files Browse the repository at this point in the history
godot62970: swapped AddChild for CallDeferred add_child.
  • Loading branch information
thoraxe authored Nov 21, 2022
2 parents 318d6d8 + 68f2c10 commit 43f1c6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Scenes/MainScenes/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public override void _Ready()
//else cslogger.Error("WTF - map canvas layer");

serverConnection = new ServerConnection();
this.AddChild(serverConnection);
this.CallDeferred("add_child", serverConnection);

PackedScene packedLoginScene = (PackedScene)ResourceLoader.Load("res://Scenes/LoginScreen.tscn");
loginScreen = (LoginScreen)packedLoginScene.Instance();
loginScreen.Visible = false;
this.AddChild(loginScreen);
this.CallDeferred("add_child", loginScreen);
loginScreen.Visible = true;

// TODO: check for server connection and do some retries if something is wrong
Expand Down Expand Up @@ -147,7 +147,7 @@ void updateGameRadar()
newBlip.Texture = shipBlip;
newBlip.Offset = new Vector2(finalX, finalY);

gameRadar.AddChild(newBlip);
gameRadar.CallDeferred("add_child", newBlip);
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@ public PlayerShip CreateShipForUUID(string uuid)
shipInstance.uuid = uuid;

_serilogger.Debug("Adding ship to scene tree");
AddChild(playerShipThingInstance);
CallDeferred("add_child", playerShipThingInstance);

// TODO: this is inconsistent with the way the server uses the playerObjects array
// where the server is using the ShipThing, this is using the PlayerShip. It may
Expand Down Expand Up @@ -326,7 +326,7 @@ public SpaceMissile CreateMissileForUUID(GameEvent egeb)
missileInstance.GlobalPosition = new Vector2(egeb.PositionX, egeb.PositionY);
missileInstance.RotationDegrees = egeb.Angle;
_serilogger.Debug("Game.cs: Adding missile to scene tree");
AddChild(missileInstance);
CallDeferred("add_child", missileInstance);

// just in case we need to use it later
missileInstance.AddToGroup("missiles");
Expand Down Expand Up @@ -395,7 +395,7 @@ void CreateLocalMissileForUUID(string uuid)
missileInstance.Position = missileInstance.Position + offset;

_serilogger.Debug("Game.cs: Adding missile to scene tree");
AddChild(missileInstance);
CallDeferred("add_child", missileInstance);

// Run the missile animation
_serilogger.Debug($"Game.cs: Starting missile animation for {missileInstance.uuid}");
Expand Down
2 changes: 1 addition & 1 deletion Scenes/SupportScenes/PlayerShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void FireMissile()
MyMissile.AddToGroup("missiles");

Node rootNode = GetNode<Node>("/root/");
rootNode.AddChild(MyMissile);
rootNode.CallDeferred("add_child", MyMissile);
_serilogger.Debug("Added missile instance!");
}

Expand Down

0 comments on commit 43f1c6b

Please sign in to comment.