Player owner

This commit is contained in:
Marco 2025-03-06 11:42:45 +01:00
commit 3064a0a5a0
3 changed files with 9 additions and 6 deletions

View file

@ -43,7 +43,7 @@
[sub_resource type="Resource" id="Resource_6wo78"] [sub_resource type="Resource" id="Resource_6wo78"]
script = ExtResource("4_u1i8n") script = ExtResource("4_u1i8n")
EggIndex = 0 EggIndex = 0
StartingEquipment = [] StartingEquipment = Array[ExtResource("5_u1i8n")]([])
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rff8l"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rff8l"]
size = Vector2(30, 52.5) size = Vector2(30, 52.5)

View file

@ -12,7 +12,7 @@ public abstract partial class ElevatorMovementState : BaseState<ElevatorState, E
{ {
protected GTween Tween; protected GTween Tween;
protected Node2D OldPlayerParent; //protected Node2D OldPlayerParent;
protected abstract Vector2 StartingPosition { get; } protected abstract Vector2 StartingPosition { get; }
protected abstract Vector2 EndingPosition { get; } protected abstract Vector2 EndingPosition { get; }
@ -37,15 +37,15 @@ public abstract partial class ElevatorMovementState : BaseState<ElevatorState, E
private void RestorePlayerParent() private void RestorePlayerParent()
{ {
if (PlayerBody is null) return; if (PlayerBody is null) return;
PlayerBody.Reparent(OldPlayerParent); PlayerBody.Reparent(PlayerBody.Owner);
OldPlayerParent = null; //OldPlayerParent = null;
MainObject.CachedPlayer?.StateMachine.SetState(PlayerState.Active); MainObject.CachedPlayer?.StateMachine.SetState(PlayerState.Active);
} }
private void CatchPlayer() private void CatchPlayer()
{ {
if (PlayerBody is null) return; if (PlayerBody is null) return;
OldPlayerParent = PlayerBody.GetParent<Node2D>(); //OldPlayerParent = PlayerBody.GetParent<Node2D>();
MainObject.CachedPlayer.StateMachine.SetState(PlayerState.Cutscene); MainObject.CachedPlayer.StateMachine.SetState(PlayerState.Cutscene);
PlayerBody.Reparent(MainObject); PlayerBody.Reparent(MainObject);
} }

View file

@ -164,8 +164,11 @@ public partial class GameManager : Node2D
//_player = this.CreateChild<PlayerMovement>(PlayerTemplate, PlayerSpawnMarker.Position ); //_player = this.CreateChild<PlayerMovement>(PlayerTemplate, PlayerSpawnMarker.Position );
_player = PlayerTemplate.Instantiate<PlayerFSMProxy>(); _player = PlayerTemplate.Instantiate<PlayerFSMProxy>();
this.CallDeferred("add_child", _player); //this.CallDeferred("add_child", _player);
this.AddChild(_player);
_player.Owner = this;
_player.Transform = this.GlobalTransform; _player.Transform = this.GlobalTransform;
_player.GlobalPosition = GetStartPosition(); _player.GlobalPosition = GetStartPosition();