Player warp item implementation

This commit is contained in:
2025-03-03 01:17:30 -08:00
parent 05295f535a
commit 4ac70b1ca7
48 changed files with 231 additions and 138 deletions

View File

@@ -21,7 +21,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
#region Dependencies
[Dependency] IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
[Dependency] IGame Game => this.DependOn<IGame>();
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
#endregion
@@ -154,7 +154,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
var tweener = GetTree().CreateTween();
tweener.TweenInterval(1.0f);
tweener.TweenCallback(Callable.From(QueueFree));
GameEventDepot.OnEnemyDefeated(GlobalPosition, _enemyStatResource);
Game.EnemyDefeated(GlobalPosition, _enemyStatResource);
}
public void StartAttackTimer()
@@ -171,7 +171,20 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
public void SetEnemyGlobalPosition(Vector3 target)
{
GlobalPosition = target;
GlobalPosition = new Vector3(target.X, -0.5f, target.Z);
}
public IDungeonRoom GetCurrentRoom()
{
var currentRooms = Game.CurrentFloor.Rooms;
foreach (var room in currentRooms)
{
var enemiesInCurrentRoom = room.EnemiesInRoom;
if (enemiesInCurrentRoom.Contains(this))
return room;
}
return null;
}
private void OnAttackTimeout()