From 2a6b7dbaf95632d3596511ce6f38988d3d455475 Mon Sep 17 00:00:00 2001 From: lzk <124214523+lzk228@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:32:21 +0200 Subject: [PATCH] Add ability to add additional friendly and hostile factions in prototypes (#29636) * Make friendly and hostile factions in NpcFactionMemberComponent datafiels * :trollface: * :trollface: --- .../NPC/Components/NpcFactionMemberComponent.cs | 12 ++++++++++++ Content.Shared/NPC/Systems/NpcFactionSystem.cs | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/Content.Shared/NPC/Components/NpcFactionMemberComponent.cs b/Content.Shared/NPC/Components/NpcFactionMemberComponent.cs index 91521e9854..208dfd4681 100644 --- a/Content.Shared/NPC/Components/NpcFactionMemberComponent.cs +++ b/Content.Shared/NPC/Components/NpcFactionMemberComponent.cs @@ -25,4 +25,16 @@ public sealed partial class NpcFactionMemberComponent : Component /// [ViewVariables] public readonly HashSet> HostileFactions = new(); + + /// + /// Used to add friendly factions in prototypes. + /// + [DataField, ViewVariables] + public HashSet>? AddFriendlyFactions; + + /// + /// Used to add hostile factions in prototypes. + /// + [DataField, ViewVariables] + public HashSet>? AddHostileFactions; } diff --git a/Content.Shared/NPC/Systems/NpcFactionSystem.cs b/Content.Shared/NPC/Systems/NpcFactionSystem.cs index ad81f01e1d..355f5bbb3a 100644 --- a/Content.Shared/NPC/Systems/NpcFactionSystem.cs +++ b/Content.Shared/NPC/Systems/NpcFactionSystem.cs @@ -59,6 +59,15 @@ public sealed partial class NpcFactionSystem : EntitySystem ent.Comp.FriendlyFactions.UnionWith(factionData.Friendly); ent.Comp.HostileFactions.UnionWith(factionData.Hostile); } + // Add additional factions if it is written in prototype + if (ent.Comp.AddFriendlyFactions != null) + { + ent.Comp.FriendlyFactions.UnionWith(ent.Comp.AddFriendlyFactions); + } + if (ent.Comp.AddHostileFactions != null) + { + ent.Comp.HostileFactions.UnionWith(ent.Comp.AddHostileFactions); + } } /// -- 2.51.2