Implement factions with bitflags instead

pull/37/head
HumanoidSandvichDispenser 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 public abstract partial class BoundingBox : Area2D, IFaction
{ {
[Export] [Export(PropertyHint.Flags)]
public ushort Faction { get; set; } public FactionName Faction { get; set; }
} }

View File

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

View File

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

View File

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