Add ability to add additional friendly and hostile factions in prototypes (#29636)
* Make friendly and hostile factions in NpcFactionMemberComponent datafiels * :trollface: * :trollface:
This commit is contained in:
parent
5c8962823e
commit
2a6b7dbaf9
2 changed files with 21 additions and 0 deletions
|
|
@ -25,4 +25,16 @@ public sealed partial class NpcFactionMemberComponent : Component
|
|||
/// </summary>
|
||||
[ViewVariables]
|
||||
public readonly HashSet<ProtoId<NpcFactionPrototype>> HostileFactions = new();
|
||||
|
||||
/// <summary>
|
||||
/// Used to add friendly factions in prototypes.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables]
|
||||
public HashSet<ProtoId<NpcFactionPrototype>>? AddFriendlyFactions;
|
||||
|
||||
/// <summary>
|
||||
/// Used to add hostile factions in prototypes.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables]
|
||||
public HashSet<ProtoId<NpcFactionPrototype>>? AddHostileFactions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue