diff --git a/Content.Server/Corvax/Loadout/LoadoutPrototype.cs b/Content.Server/Corvax/Loadout/LoadoutPrototype.cs deleted file mode 100644 index 0d6b6c14d4e..00000000000 --- a/Content.Server/Corvax/Loadout/LoadoutPrototype.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Content.Shared.Roles; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; - -namespace Content.Server.Corvax.Loadout; - -[Prototype("loadout")] -public sealed class LoadoutItemPrototype : IPrototype -{ - [IdDataFieldAttribute] public string ID { get; } = default!; - - [DataField("entity", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] - public string EntityId { get; } = default!; - - // Corvax-Sponsors-Start - [DataField("sponsorOnly")] - public bool SponsorOnly = false; - // Corvax-Sponsors-End - - [DataField("whitelistJobs", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List? WhitelistJobs { get; } - - [DataField("blacklistJobs", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List? BlacklistJobs { get; } - - [DataField("speciesRestriction")] - public List? SpeciesRestrictions { get; } -} diff --git a/Content.Server/Corvax/Loadout/LoadoutSystem.cs b/Content.Server/Corvax/Loadout/LoadoutSystem.cs deleted file mode 100644 index 4f05045795b..00000000000 --- a/Content.Server/Corvax/Loadout/LoadoutSystem.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.Linq; -using Content.Corvax.Interfaces.Server; -using Content.Server.GameTicking; -using Content.Server.Hands.Systems; -using Content.Server.Storage.EntitySystems; -using Content.Shared.Clothing.Components; -using Content.Shared.Inventory; -using Robust.Shared.Prototypes; - -namespace Content.Server.Corvax.Loadout; - -// NOTE: Full implementation will be in future, now just sponsor items -public sealed class LoadoutSystem : EntitySystem -{ - private const string BackpackSlotId = "back"; - - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly InventorySystem _inventorySystem = default!; - [Dependency] private readonly HandsSystem _handsSystem = default!; - [Dependency] private readonly StorageSystem _storageSystem = default!; - private IServerSponsorsManager? _sponsorsManager; - - public override void Initialize() - { - IoCManager.Instance!.TryResolveType(out _sponsorsManager); // Corvax-Sponsors - SubscribeLocalEvent(OnPlayerSpawned); - } - - private void OnPlayerSpawned(PlayerSpawnCompleteEvent ev) - { - if (_sponsorsManager == null) - return; - - if (_sponsorsManager.TryGetPrototypes(ev.Player.UserId, out var prototypes)) - { - foreach (var loadoutId in prototypes) - { - // NOTE: Now is easy to not extract method because event give all info we need - if (_prototypeManager.TryIndex(loadoutId, out var loadout)) - { - var isSponsorOnly = loadout.SponsorOnly && - !prototypes.Contains(loadoutId); - var isWhitelisted = ev.JobId != null && - loadout.WhitelistJobs != null && - !loadout.WhitelistJobs.Contains(ev.JobId); - var isBlacklisted = ev.JobId != null && - loadout.BlacklistJobs != null && - loadout.BlacklistJobs.Contains(ev.JobId); - var isSpeciesRestricted = loadout.SpeciesRestrictions != null && - loadout.SpeciesRestrictions.Contains(ev.Profile.Species); - - if (isSponsorOnly || isWhitelisted || isBlacklisted || isSpeciesRestricted) - continue; - - var entity = Spawn(loadout.EntityId, Transform(ev.Mob).Coordinates); - - // Take in hand if not clothes - if (!TryComp(entity, out var clothing)) - { - _handsSystem.TryPickup(ev.Mob, entity); - continue; - } - - // Automatically search empty slot for clothes to equip - string? firstSlotName = null; - bool isEquiped = false; - if (!_inventorySystem.TryGetSlots(ev.Mob, out var slotDefinitions)) - return; - foreach (var slot in slotDefinitions) - { - if (!clothing.Slots.HasFlag(slot.SlotFlags)) - continue; - - if (firstSlotName == null) - firstSlotName = slot.Name; - - if (_inventorySystem.TryGetSlotEntity(ev.Mob, slot.Name, out var _)) - continue; - - if (_inventorySystem.TryEquip(ev.Mob, entity, slot.Name, true)) - { - isEquiped = true; - break; - } - } - - if (isEquiped || firstSlotName == null) - continue; - - // Force equip to first valid clothes slot - // Get occupied entity -> Insert to backpack -> Equip loadout entity - if (_inventorySystem.TryGetSlotEntity(ev.Mob, firstSlotName, out var slotEntity) && - _inventorySystem.TryGetSlotEntity(ev.Mob, BackpackSlotId, out var backEntity) && - _storageSystem.CanInsert(backEntity.Value, slotEntity.Value, out _)) - { - _storageSystem.Insert(backEntity.Value, slotEntity.Value, out _, playSound: false); - } - _inventorySystem.TryEquip(ev.Mob, entity, firstSlotName, true); - } - } - } - } -} diff --git a/Corvax/Content.Corvax.Interfaces.Server/IServerLoadoutManager.cs b/Corvax/Content.Corvax.Interfaces.Server/IServerLoadoutManager.cs new file mode 100644 index 00000000000..706ff51e2c7 --- /dev/null +++ b/Corvax/Content.Corvax.Interfaces.Server/IServerLoadoutManager.cs @@ -0,0 +1,10 @@ +using System.Diagnostics.CodeAnalysis; +using Content.Corvax.Interfaces.Shared; +using Robust.Shared.Network; + +namespace Content.Corvax.Interfaces.Server; + +public interface IServerLoadoutManager : ISharedSponsorsManager +{ + public bool TryGetPrototypes(NetUserId userId, [NotNullWhen(true)] out List? prototypes); +} diff --git a/Resources/Prototypes/Corvax/Catalog/Loadout/head.yml b/Resources/Prototypes/Corvax/Catalog/Loadout/head.yml deleted file mode 100644 index 07391ab5308..00000000000 --- a/Resources/Prototypes/Corvax/Catalog/Loadout/head.yml +++ /dev/null @@ -1,7 +0,0 @@ -- type: loadout - id: ClothingHeadHatFlowerCrownLoadout - entity: ClothingHeadHatFlowerCrown - -- type: loadout - id: ClothingHeadHatHairflowerLoadout - entity: ClothingHeadHatHairflower diff --git a/Secrets b/Secrets index 84a19e8b8d9..936cdd67f1e 160000 --- a/Secrets +++ b/Secrets @@ -1 +1 @@ -Subproject commit 84a19e8b8d9fcb93e02475c690bdb71f9c3454fc +Subproject commit 936cdd67f1e5c3ae43d559700a0b11ff2a1463fb