fixed building deletion

This commit is contained in:
Victor Turgeon 2023-06-11 17:28:47 -04:00
parent 9d4a9c6fd0
commit 8ccf984de3

View File

@ -85,7 +85,7 @@ public partial class player : Camera3D
{
if (CurrentBuilding != null)
{
GetTree().Root.RemoveChild(CurrentBuilding);
GetParent().RemoveChild(CurrentBuilding);
CurrentBuilding.QueueFree();
CurrentBuilding = null;
game_manager.CurrentState = game_manager.State.Play;
@ -113,7 +113,7 @@ public partial class player : Camera3D
}
CurrentBuilding = toInstantiate.Instantiate<base_building>();
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
this.GetParent().CallDeferred("add_child", CurrentBuilding);
game_manager.CurrentState = game_manager.State.Building;
}
@ -248,7 +248,8 @@ public partial class player : Camera3D
KashFlow += kashFlow;
base_building tempBuilding = (base_building)CurrentBuilding.Duplicate();
GetTree().Root.CallDeferred("add_child", tempBuilding);
GetParent().CallDeferred("add_child", tempBuilding);
game_manager.CurrentState = game_manager.State.Play;
SetBarLabels();
@ -315,7 +316,8 @@ public partial class player : Camera3D
}
}
public void Nuke() {
public void Nuke()
{
var scene = GD.Load<PackedScene>("res://endings/mad.tscn");
var instance = scene.Instantiate();