Implement factions with bitflags instead

pull/37/head
John Montagu, the 4th Earl of Sandvich 2024-06-01 19:12:23 -07:00
parent a590aa9209
commit 96977ac79f
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
4 changed files with 13 additions and 5 deletions

View File

@ -5,6 +5,6 @@ namespace SupaLidlGame.BoundingBoxes;
public abstract partial class BoundingBox : Area2D, IFaction
{
[Export]
public ushort Faction { get; set; }
[Export(PropertyHint.Flags)]
public FactionName Faction { get; set; }
}

View File

@ -93,8 +93,8 @@ public partial class Character : CharacterBody2D, IFaction
[Export]
public BoundingBoxes.Hurtbox Hurtbox { get; set; }
[Export]
public ushort Faction { get; set; }
[Export(PropertyHint.Flags)]
public FactionName Faction { get; set; }
public AnimationPlayer MovementAnimation { get; set; }

View File

@ -573,6 +573,7 @@ Sprite = NodePath("Sprite")
Inventory = NodePath("Inventory")
StateMachine = NodePath("StateMachine")
Hurtbox = NodePath("Hurtbox")
Faction = 2
[node name="Stats" type="Node" parent="."]
script = ExtResource("5_a7fiw")

View File

@ -2,13 +2,20 @@ using Godot;
namespace SupaLidlGame.Utils;
[System.Flags]
public enum FactionName
{
Player = 1,
Doc = 2,
}
public interface IFaction
{
/// <summary>
/// The faction index that this entity belongs to.
/// </summary>
[Export]
public ushort Faction { get; set; }
public FactionName Faction { get; set; }
public bool AlignsWith(IFaction other)
{