Remove IUse (#7074)

This commit is contained in:
Leon Friedrich
2022-03-13 01:33:23 +13:00
committed by GitHub
parent c908a843ab
commit b1e719c70d
42 changed files with 109 additions and 158 deletions

View File

@@ -11,6 +11,7 @@ using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Player;

View File

@@ -1,14 +1,5 @@
using Content.Server.Hands.Components;
using Content.Shared.Clothing;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Clothing.Components
{
@@ -20,53 +11,12 @@ namespace Content.Server.Clothing.Components
[RegisterComponent]
[NetworkedComponent]
[ComponentReference(typeof(SharedItemComponent))]
public sealed class ClothingComponent : ItemComponent, IUse
public sealed class ClothingComponent : ItemComponent
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[DataField("QuickEquip")]
private bool _quickEquipEnabled = true;
[DataField("HeatResistance")]
private int _heatResistance = 323;
[ViewVariables(VVAccess.ReadWrite)]
public int HeatResistance => _heatResistance;
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
if (!_quickEquipEnabled) return false;
var invSystem = EntitySystem.Get<InventorySystem>();
if (!_entities.TryGetComponent(eventArgs.User, out InventoryComponent? inv)
|| !_entities.TryGetComponent(eventArgs.User, out HandsComponent? hands) || !_prototype.TryIndex<InventoryTemplatePrototype>(inv.TemplateId, out var prototype)) return false;
foreach (var slotDef in prototype.Slots)
{
if(!invSystem.CanEquip(eventArgs.User, Owner, slotDef.Name, out _, slotDef, inv))
continue;
if (invSystem.TryGetSlotEntity(eventArgs.User, slotDef.Name, out var slotEntity, inv))
{
if(!invSystem.TryUnequip(eventArgs.User, slotDef.Name, true, inventory: inv))
continue;
if (!invSystem.TryEquip(eventArgs.User, Owner, slotDef.Name, true, inventory: inv))
continue;
hands.PutInHandOrDrop(slotEntity.Value);
}
else
{
if (!invSystem.TryEquip(eventArgs.User, Owner, slotDef.Name, true, inventory: inv))
continue;
}
return true;
}
return false;
}
}
}

View File

@@ -7,6 +7,7 @@ using Content.Shared.Crayon;
using Content.Shared.Database;
using Content.Shared.Decals;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;

View File

@@ -2,7 +2,7 @@ using System;
using Content.Server.Popups;
using Content.Shared.Audio;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Server.GameObjects;

View File

@@ -4,6 +4,7 @@ using Content.Server.Flash.Components;
using Content.Server.Throwing;
using Content.Shared.Explosion;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;

View File

@@ -1,6 +1,6 @@
using System;
using Content.Server.Explosion.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Trigger;
using Robust.Shared.GameObjects;

View File

@@ -8,6 +8,7 @@ using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Extinguisher;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;

View File

@@ -4,6 +4,7 @@ using Content.Server.Weapon.Melee;
using Content.Shared.Examine;
using Content.Shared.Flash;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Physics;
using Content.Shared.Popups;

View File

@@ -1,6 +1,6 @@
using Content.Server.Clothing.Components;
using Content.Server.Light.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Light.Component;
using Content.Shared.Verbs;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Stacks;
using Robust.Shared.Audio;
using Robust.Shared.Player;

View File

@@ -15,6 +15,7 @@ using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Nutrition.Components;
using Content.Shared.Throwing;

View File

@@ -21,6 +21,7 @@ using Robust.Shared.Player;
using Robust.Shared.Utility;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Content.Shared.Interaction.Events;
namespace Content.Server.Nutrition.EntitySystems
{

View File

@@ -1,5 +1,4 @@
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.PAI;
using Content.Shared.Verbs;
using Content.Shared.Instruments;
@@ -14,6 +13,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Content.Shared.Actions;
using Content.Shared.Interaction.Events;
namespace Content.Server.PAI
{

View File

@@ -15,6 +15,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Content.Shared.Interaction.Events;
namespace Content.Server.PDA
{

View File

@@ -5,6 +5,7 @@ using Content.Server.RCD.Components;
using Content.Shared.Coordinates;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps;
using Content.Shared.Popups;

View File

@@ -11,6 +11,7 @@ using Content.Shared.Physics;
using Content.Shared.Access.Components;
using Content.Server.Doors.Systems;
using Content.Server.Doors.Components;
using Content.Shared.Interaction.Events;
namespace Content.Server.Remotes
{

View File

@@ -3,6 +3,7 @@ using Content.Server.Sound.Components;
using Content.Server.Throwing;
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Content.Server.Storage.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;

View File

@@ -8,7 +8,7 @@ using Content.Server.Weapon.Melee;
using Content.Shared.ActionBlocker;
using Content.Shared.Audio;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Jittering;
using Content.Shared.Popups;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;

View File

@@ -1,6 +1,7 @@
using Content.Server.Tools.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Weapons.Melee;
using Robust.Shared.Audio;

View File

@@ -6,6 +6,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;

View File

@@ -3,6 +3,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Audio;

View File

@@ -5,6 +5,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged;

View File

@@ -2,6 +2,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Audio;

View File

@@ -4,6 +4,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;

View File

@@ -2,6 +2,7 @@ using System;
using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Barrels.Components;

View File

@@ -2,6 +2,7 @@ using Content.Server.Hands.Components;
using Content.Server.Weapon.Ranged.Ammunition.Components;
using Content.Server.Weapon.Ranged.Barrels.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Shared.Containers;

View File

@@ -12,6 +12,7 @@ using Content.Shared.Camera;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.PowerCell.Components;
using Content.Shared.Verbs;

View File

@@ -4,7 +4,7 @@ using Content.Server.Hands.Systems;
using Content.Server.Weapon.Melee;
using Content.Server.Wieldable.Components;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Verbs;