-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add carp hardsuit for traitors (#25155)
* FactionClothing * swtich carp to the Dragon faction * add carp hardsuit * add carp hardsuit to uplink * fixes * webedit ops 1 * why did i name it that wtf * among --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
- Loading branch information
1 parent
22efc2b
commit 1cb9f5d
Showing
7 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
Content.Shared/Clothing/Components/FactionClothingComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Content.Shared.Clothing.EntitySystems; | ||
using Content.Shared.NPC.Prototypes; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared.Clothing.Components; | ||
|
||
/// <summary> | ||
/// When equipped, adds the wearer to a faction. | ||
/// When removed, removes the wearer from a faction. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, Access(typeof(FactionClothingSystem))] | ||
public sealed partial class FactionClothingComponent : Component | ||
{ | ||
/// <summary> | ||
/// Faction to add and remove. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public ProtoId<NpcFactionPrototype> Faction = string.Empty; | ||
|
||
/// <summary> | ||
/// If true, the wearer was already part of the faction. | ||
/// This prevents wrongly removing them after removing the item. | ||
/// </summary> | ||
[DataField] | ||
public bool AlreadyMember; | ||
} |
42 changes: 42 additions & 0 deletions
42
Content.Shared/Clothing/EntitySystems/FactionClothingSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Content.Shared.Clothing.Components; | ||
using Content.Shared.Inventory.Events; | ||
using Content.Shared.NPC.Components; | ||
using Content.Shared.NPC.Systems; | ||
|
||
namespace Content.Shared.Clothing.EntitySystems; | ||
|
||
/// <summary> | ||
/// Handles <see cref="FactionClothingComponent"/> faction adding and removal. | ||
/// </summary> | ||
public sealed class FactionClothingSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly NpcFactionSystem _faction = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FactionClothingComponent, GotEquippedEvent>(OnEquipped); | ||
SubscribeLocalEvent<FactionClothingComponent, GotUnequippedEvent>(OnUnequipped); | ||
} | ||
|
||
private void OnEquipped(Entity<FactionClothingComponent> ent, ref GotEquippedEvent args) | ||
{ | ||
TryComp<NpcFactionMemberComponent>(args.Equipee, out var factionComp); | ||
var faction = (args.Equipee, factionComp); | ||
ent.Comp.AlreadyMember = _faction.IsMember(faction, ent.Comp.Faction); | ||
|
||
_faction.AddFaction(faction, ent.Comp.Faction); | ||
} | ||
|
||
private void OnUnequipped(Entity<FactionClothingComponent> ent, ref GotUnequippedEvent args) | ||
{ | ||
if (ent.Comp.AlreadyMember) | ||
{ | ||
ent.Comp.AlreadyMember = false; | ||
return; | ||
} | ||
|
||
_faction.RemoveFaction(args.Equipee, ent.Comp.Faction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters