Add briefcase in hand & update setoutfit (#11634)

This commit is contained in:
Morb
2022-10-16 00:22:27 +03:00
committed by GitHub
parent 58f88887d8
commit 5af82ebe9b
4 changed files with 26 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
using Content.Server.Administration.UI;
using Content.Server.EUI;
using Content.Server.Hands.Components;
using Content.Server.Hands.Systems;
using Content.Server.Preferences.Managers;
using Content.Shared.Administration;
using Content.Shared.Inventory;
@@ -17,6 +19,9 @@ namespace Content.Server.Administration.Commands
[AdminCommand(AdminFlags.Admin)]
sealed class SetOutfitCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
public string Command => "setoutfit";
public string Description => Loc.GetString("set-outfit-command-description", ("requiredComponent", nameof(InventoryComponent)));
@@ -37,17 +42,15 @@ namespace Content.Server.Administration.Commands
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var target = new EntityUid(entityUid);
if (!target.IsValid() || !entityManager.EntityExists(target))
if (!target.IsValid() || !_entities.EntityExists(target))
{
shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
return;
}
if (!entityManager.HasComponent<InventoryComponent?>(target))
if (!_entities.HasComponent<InventoryComponent?>(target))
{
shell.WriteLine(Loc.GetString("shell-target-entity-does-not-have-message",("missing", "inventory")));
return;
@@ -67,7 +70,7 @@ namespace Content.Server.Administration.Commands
return;
}
if (!SetOutfit(target, args[1], entityManager))
if (!SetOutfit(target, args[1], _entities))
shell.WriteLine(Loc.GetString("set-outfit-command-invalid-outfit-id-error"));
}
@@ -90,7 +93,7 @@ namespace Content.Server.Administration.Commands
profile = prefs.SelectedCharacter as HumanoidCharacterProfile;
}
var invSystem = EntitySystem.Get<InventorySystem>();
var invSystem = entityManager.System<InventorySystem>();
if (invSystem.TryGetSlots(target, out var slotDefinitions, inventoryComponent))
{
foreach (var slot in slotDefinitions)
@@ -115,6 +118,17 @@ namespace Content.Server.Administration.Commands
}
}
if (entityManager.TryGetComponent(target, out HandsComponent? handsComponent))
{
var handsSystem = entityManager.System<HandsSystem>();
var coords = entityManager.GetComponent<TransformComponent>(target).Coordinates;
foreach (var (hand, prototype) in startingGear.Inhand)
{
var inhandEntity = entityManager.SpawnEntity(prototype, coords);
handsSystem.TryPickup(target, inhandEntity, hand, checkActionBlocker: false, handsComp: handsComponent);
}
}
return true;
}
}