Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

godot62970: swapped AddChild for CallDeferred add_child. #35

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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