SupaLidlGame/Characters/Boss.cs

51 lines
1.1 KiB
C#
Raw Normal View History

2023-07-22 20:23:48 -07:00
using Godot;
2023-07-23 11:05:01 -07:00
using GodotUtilities;
2023-07-22 20:23:48 -07:00
namespace SupaLidlGame.Characters;
public abstract partial class Boss : Enemy
{
[Export]
public State.NPC.NPCStateMachine BossStateMachine { get; set; }
2023-07-23 11:05:01 -07:00
[Export]
public string BossName { get; set; }
2023-07-23 23:39:20 -07:00
[Export]
public AudioStream Music { get; set; }
2023-07-22 20:23:48 -07:00
public abstract int Intensity { get; }
2023-07-23 11:05:01 -07:00
private bool _isActive;
2023-07-22 20:23:48 -07:00
[Export]
2023-07-25 03:47:31 -07:00
public virtual bool IsActive
2023-07-23 11:05:01 -07:00
{
get => _isActive;
set
{
_isActive = value;
// register or deregister ourselves when we are active/inactive
this.GetAncestor<Utils.World>()
.RegisterBoss(_isActive ? this : null);
}
}
2023-07-24 21:29:14 -07:00
public override void _Ready()
{
base._Ready();
2023-08-01 23:49:48 -07:00
Death += (Events.HealthChangedArgs args) =>
{
UpdateBossStatus(true);
};
}
protected void UpdateBossStatus(bool status)
{
GetNode<State.Global.GlobalState>("/root/GlobalState")
.Progression.BossStatus[SceneFilePath] = status;
2023-07-24 21:29:14 -07:00
}
2023-07-22 20:23:48 -07:00
}