using Content.Server.NPC.Components; using Content.Server.Store.Systems; using Content.Shared.Clothing.Components; using Content.Shared.Inventory.Events; namespace Content.Server.NPC.Systems; public partial class NpcFactionSystem : EntitySystem { public void InitializeItems() { SubscribeLocalEvent(OnItemPurchased); SubscribeLocalEvent(OnClothingEquipped); SubscribeLocalEvent(OnClothingUnequipped); } /// /// If we bought something we probably don't want it to start biting us after it's automatically placed in our hands. /// If you do, consider finding a better solution to grenade penguin CBT. /// private void OnItemPurchased(EntityUid uid, NpcFactionMemberComponent component, ref ItemPurchasedEvent args) { component.ExceptionalFriendlies.Add(args.Purchaser); } private void OnClothingEquipped(EntityUid uid, ClothingAddFactionComponent component, GotEquippedEvent args) { if (!TryComp(uid, out var clothing)) return; if (!clothing.Slots.HasFlag(args.SlotFlags)) return; if (!TryComp(args.Equipee, out var factionComponent)) return; if (factionComponent.Factions.Contains(component.Faction)) return; component.IsActive = true; AddFaction(args.Equipee, component.Faction); } private void OnClothingUnequipped(EntityUid uid, ClothingAddFactionComponent component, GotUnequippedEvent args) { if (!component.IsActive) return; component.IsActive = false; RemoveFaction(args.Equipee, component.Faction); } }