Cleanup factions code (#11075)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.NPC.Components
|
||||
{
|
||||
[Prototype("aiFaction")]
|
||||
public sealed class AiFactionPrototype : IPrototype
|
||||
{
|
||||
// These are immutable so any dynamic changes aren't saved back over.
|
||||
// AiFactionSystem will just read these and then store them.
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("hostile")]
|
||||
public IReadOnlyList<string> Hostile { get; private set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using Content.Server.NPC.Systems;
|
||||
|
||||
namespace Content.Server.NPC.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class AiFactionTagComponent : Component
|
||||
{
|
||||
[DataField("factions")]
|
||||
public Faction Factions { get; set; } = Faction.None;
|
||||
}
|
||||
}
|
||||
29
Content.Server/NPC/Components/FactionComponent.cs
Normal file
29
Content.Server/NPC/Components/FactionComponent.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Content.Server.NPC.Systems;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.NPC.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Access(typeof(FactionSystem))]
|
||||
public sealed class FactionComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Factions this entity is a part of.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite),
|
||||
DataField("factions", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<FactionPrototype>))]
|
||||
public HashSet<string> Factions = new();
|
||||
|
||||
/// <summary>
|
||||
/// Cached friendly factions.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public readonly HashSet<string> FriendlyFactions = new();
|
||||
|
||||
/// <summary>
|
||||
/// Cached hostile factions.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public readonly HashSet<string> HostileFactions = new();
|
||||
}
|
||||
}
|
||||
23
Content.Server/NPC/Components/FactionPrototype.cs
Normal file
23
Content.Server/NPC/Components/FactionPrototype.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.NPC.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains data about this faction's relations with other factions.
|
||||
/// </summary>
|
||||
[Prototype("faction")]
|
||||
public sealed class FactionPrototype : IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("friendly", customTypeSerializer:typeof(PrototypeIdListSerializer<FactionPrototype>))]
|
||||
public List<string> Friendly = new();
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("hostile", customTypeSerializer:typeof(PrototypeIdListSerializer<FactionPrototype>))]
|
||||
public List<string> Hostile = new();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user