From: lzk <124214523+lzk228@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:32:21 +0000 (+0200) Subject: Add ability to add additional friendly and hostile factions in prototypes (#29636) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2a6b7dbaf95632d3596511ce6f38988d3d455475;p=space-station-14.git Add ability to add additional friendly and hostile factions in prototypes (#29636) * Make friendly and hostile factions in NpcFactionMemberComponent datafiels * :trollface: * :trollface: --- 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); + } } ///