Merge branch 'master' into 2021-12-03-remove-IEntity-komm-süsser-todd
# Conflicts: # Content.Client/Crayon/CrayonDecalVisualizer.cs # Content.Client/Tabletop/TabletopSystem.cs # Content.IntegrationTests/Tests/InventoryHelpersTest.cs # Content.Server/AI/EntitySystems/AiSystem.cs # Content.Server/AI/Utility/AiLogic/UtilityAI.cs # Content.Server/AME/AMENodeGroup.cs # Content.Server/Administration/AdminVerbSystem.cs # Content.Server/Body/Systems/RespiratorSystem.cs # Content.Server/Chemistry/Components/InjectorComponent.cs # Content.Server/Chemistry/TileReactions/CleanTileReaction.cs # Content.Server/Chemistry/TileReactions/SpillTileReaction.cs # Content.Server/Crayon/CrayonComponent.cs # Content.Server/Doors/Components/ServerDoorComponent.cs # Content.Server/Explosion/EntitySystems/TriggerSystem.cs # Content.Server/Fluids/Components/MopComponent.cs # Content.Server/Fluids/Components/SpillExtensions.cs # Content.Server/Fluids/EntitySystems/PuddleSystem.cs # Content.Server/Instruments/InstrumentSystem.cs # Content.Server/Nutrition/EntitySystems/DrinkSystem.cs # Content.Server/Nutrition/EntitySystems/FoodSystem.cs # Content.Server/PneumaticCannon/PneumaticCannonSystem.cs # Content.Server/Storage/Components/EntityStorageComponent.cs # Content.Server/Storage/Components/StorageFillComponent.cs # Content.Server/Stunnable/StunbatonSystem.cs # Content.Server/Throwing/ThrowHelper.cs # Content.Server/Weapon/Ranged/Barrels/BarrelSystem.cs # Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs # Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs # Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs # Content.Shared/Damage/Components/DamageableComponent.cs # Content.Shared/Damage/Systems/DamageableSystem.cs # Content.Shared/MobState/Components/MobStateComponent.cs # Content.Shared/Slippery/SharedSlipperySystem.cs
This commit is contained in:
@@ -3,9 +3,11 @@ using Content.Server.Weapon.Ranged.Barrels.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.Weapon.Ranged.Barrels
|
||||
{
|
||||
@@ -19,8 +21,8 @@ namespace Content.Server.Weapon.Ranged.Barrels
|
||||
|
||||
SubscribeLocalEvent<RevolverBarrelComponent, GetAlternativeVerbsEvent>(AddSpinVerb);
|
||||
|
||||
SubscribeLocalEvent<ServerBatteryBarrelComponent, GetAlternativeVerbsEvent>(AddEjectCellVerb);
|
||||
SubscribeLocalEvent<ServerBatteryBarrelComponent, GetInteractionVerbsEvent>(AddInsertCellVerb);
|
||||
SubscribeLocalEvent<ServerBatteryBarrelComponent, EntInsertedIntoContainerMessage>(OnCellSlotUpdated);
|
||||
SubscribeLocalEvent<ServerBatteryBarrelComponent, EntRemovedFromContainerMessage>(OnCellSlotUpdated);
|
||||
|
||||
SubscribeLocalEvent<BoltActionBarrelComponent, GetInteractionVerbsEvent>(AddToggleBoltVerb);
|
||||
|
||||
@@ -28,6 +30,12 @@ namespace Content.Server.Weapon.Ranged.Barrels
|
||||
SubscribeLocalEvent<ServerMagazineBarrelComponent, GetAlternativeVerbsEvent>(AddEjectMagazineVerb);
|
||||
}
|
||||
|
||||
private void OnCellSlotUpdated(EntityUid uid, ServerBatteryBarrelComponent component, ContainerModifiedMessage args)
|
||||
{
|
||||
if (args.Container.ID == component.CellSlot.ID)
|
||||
component.UpdateAppearance();
|
||||
}
|
||||
|
||||
private void AddSpinVerb(EntityUid uid, RevolverBarrelComponent component, GetAlternativeVerbsEvent args)
|
||||
{
|
||||
if (args.Hands == null || !args.CanAccess || !args.CanInteract)
|
||||
@@ -62,44 +70,6 @@ namespace Content.Server.Weapon.Ranged.Barrels
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system?
|
||||
// Really, why isn't this just PowerCellSlotComponent?
|
||||
private void AddEjectCellVerb(EntityUid uid, ServerBatteryBarrelComponent component, GetAlternativeVerbsEvent args)
|
||||
{
|
||||
if (args.Hands == null ||
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
!component.PowerCellRemovable ||
|
||||
component.PowerCell == null ||
|
||||
!_actionBlockerSystem.CanPickup(args.User))
|
||||
return;
|
||||
|
||||
Verb verb = new()
|
||||
{
|
||||
Text = EntityManager.GetComponent<MetaDataComponent>(component.PowerCell.Owner).EntityName,
|
||||
Category = VerbCategory.Eject,
|
||||
Act = () => component.TryEjectCell(args.User)
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void AddInsertCellVerb(EntityUid uid, ServerBatteryBarrelComponent component, GetInteractionVerbsEvent args)
|
||||
{
|
||||
if (args.Using is not {Valid: true} @using ||
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
component.PowerCell != null ||
|
||||
!EntityManager.HasComponent<BatteryComponent>(@using) ||
|
||||
!_actionBlockerSystem.CanDrop(args.User))
|
||||
return;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Text = EntityManager.GetComponent<MetaDataComponent>(@using).EntityName;
|
||||
verb.Category = VerbCategory.Insert;
|
||||
verb.Act = () => component.TryInsertPowerCell(@using);
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void AddEjectMagazineVerb(EntityUid uid, ServerMagazineBarrelComponent component, GetAlternativeVerbsEvent args)
|
||||
{
|
||||
if (args.Hands == null ||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
#pragma warning disable 618
|
||||
public sealed class BoltActionBarrelComponent : ServerRangedBarrelComponent, IMapInit, IExamine
|
||||
public sealed class BoltActionBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IMapInit, IExamine
|
||||
#pragma warning restore 618
|
||||
{
|
||||
// Originally I had this logic shared with PumpBarrel and used a couple of variables to control things
|
||||
@@ -270,7 +270,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
if (BoltOpen)
|
||||
{
|
||||
@@ -284,7 +284,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
return TryInsertBullet(eventArgs.User, eventArgs.Using);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IMapInit, ISerializationHooks
|
||||
public sealed class PumpBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IMapInit, ISerializationHooks
|
||||
{
|
||||
public override string Name => "PumpBarrel";
|
||||
|
||||
@@ -224,13 +224,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
Cycle(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
return TryInsertBullet(eventArgs);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, ISerializationHooks
|
||||
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
EjectAllSlots();
|
||||
Dirty();
|
||||
@@ -259,7 +259,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
return TryInsertBullet(eventArgs.User, eventArgs.Using);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Projectiles.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Weapons.Ranged.Barrels.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -27,6 +23,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
public override string Name => "BatteryBarrel";
|
||||
|
||||
[DataField("cellSlot", required: true)]
|
||||
public ItemSlot CellSlot = new();
|
||||
|
||||
// The minimum change we need before we can fire
|
||||
[DataField("lowerChargeLimit")]
|
||||
[ViewVariables] private float _lowerChargeLimit = 10;
|
||||
@@ -36,23 +35,14 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[DataField("ammoPrototype")]
|
||||
[ViewVariables] private string? _ammoPrototype;
|
||||
|
||||
[ViewVariables] public EntityUid? PowerCellEntity => _powerCellContainer.ContainedEntity;
|
||||
public BatteryComponent? PowerCell => _powerCellContainer.ContainedEntity == null
|
||||
? null
|
||||
: _entities.GetComponentOrNull<BatteryComponent>(_powerCellContainer.ContainedEntity.Value);
|
||||
|
||||
private ContainerSlot _powerCellContainer = default!;
|
||||
public BatteryComponent? PowerCell => _entities.GetComponentOrNull<BatteryComponent>(CellSlot.Item);
|
||||
private ContainerSlot _ammoContainer = default!;
|
||||
[DataField("powerCellPrototype")]
|
||||
private string? _powerCellPrototype;
|
||||
[DataField("powerCellRemovable")]
|
||||
[ViewVariables] public bool PowerCellRemovable;
|
||||
|
||||
public override int ShotsLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_powerCellContainer.ContainedEntity is not {Valid: true} powerCell)
|
||||
if (CellSlot.Item is not {} powerCell)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -65,7 +55,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_powerCellContainer.ContainedEntity is not {Valid: true} powerCell)
|
||||
if (CellSlot.Item is not {} powerCell)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -76,12 +66,6 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
private AppearanceComponent? _appearanceComponent;
|
||||
|
||||
// Sounds
|
||||
[DataField("soundPowerCellInsert", required: true)]
|
||||
private SoundSpecifier _soundPowerCellInsert = default!;
|
||||
[DataField("soundPowerCellEject", required: true)]
|
||||
private SoundSpecifier _soundPowerCellEject = default!;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
(int, int)? count = (ShotsLeft, Capacity);
|
||||
@@ -94,12 +78,8 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_powerCellContainer = Owner.EnsureContainer<ContainerSlot>($"{Name}-powercell-container", out var existing);
|
||||
if (!existing && _powerCellPrototype != null)
|
||||
{
|
||||
var powerCellEntity = _entities.SpawnEntity(_powerCellPrototype, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
_powerCellContainer.Insert(powerCellEntity);
|
||||
}
|
||||
|
||||
EntitySystem.Get<ItemSlotsSystem>().AddItemSlot(Owner, $"{Name}-powercell-container", CellSlot);
|
||||
|
||||
if (_ammoPrototype != null)
|
||||
{
|
||||
@@ -113,6 +93,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
Dirty();
|
||||
}
|
||||
|
||||
protected override void OnRemove()
|
||||
{
|
||||
base.OnRemove();
|
||||
EntitySystem.Get<ItemSlotsSystem>().RemoveItemSlot(Owner, CellSlot);
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
@@ -121,7 +107,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
public void UpdateAppearance()
|
||||
{
|
||||
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, _powerCellContainer.ContainedEntity != null);
|
||||
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, CellSlot.HasItem);
|
||||
_appearanceComponent?.SetData(AmmoVisuals.AmmoCount, ShotsLeft);
|
||||
_appearanceComponent?.SetData(AmmoVisuals.AmmoMax, Capacity);
|
||||
Dirty();
|
||||
@@ -143,7 +129,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
|
||||
public override EntityUid? TakeProjectile(EntityCoordinates spawnAt)
|
||||
{
|
||||
var powerCellEntity = _powerCellContainer.ContainedEntity;
|
||||
var powerCellEntity = CellSlot.Item;
|
||||
|
||||
if (powerCellEntity == null)
|
||||
{
|
||||
@@ -198,76 +184,5 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
UpdateAppearance();
|
||||
return entity.Value;
|
||||
}
|
||||
|
||||
public bool TryInsertPowerCell(EntityUid entity)
|
||||
{
|
||||
if (_powerCellContainer.ContainedEntity != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_entities.HasComponent<BatteryComponent>(entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellInsert.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
||||
|
||||
_powerCellContainer.Insert(entity);
|
||||
|
||||
Dirty();
|
||||
UpdateAppearance();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
if (!PowerCellRemovable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return PowerCellEntity != default && TryEjectCell(eventArgs.User);
|
||||
}
|
||||
|
||||
public bool TryEjectCell(EntityUid user)
|
||||
{
|
||||
if (PowerCell == null || !PowerCellRemovable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_entities.TryGetComponent(user, out HandsComponent? hands))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var cell = PowerCell;
|
||||
if (!_powerCellContainer.Remove(cell.Owner))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Dirty();
|
||||
UpdateAppearance();
|
||||
|
||||
if (!hands.PutInHand(_entities.GetComponent<ItemComponent>(cell.Owner)))
|
||||
{
|
||||
_entities.GetComponent<TransformComponent>(cell.Owner).Coordinates = _entities.GetComponent<TransformComponent>(user).Coordinates;
|
||||
}
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!_entities.HasComponent<BatteryComponent>(eventArgs.Using))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return TryInsertPowerCell(eventArgs.Using);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
#pragma warning disable 618
|
||||
public sealed class ServerMagazineBarrelComponent : ServerRangedBarrelComponent, IExamine
|
||||
public sealed class ServerMagazineBarrelComponent : ServerRangedBarrelComponent, IUse, IInteractUsing, IExamine
|
||||
#pragma warning restore 618
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
@@ -248,7 +248,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
_appearanceComponent?.SetData(AmmoVisuals.AmmoMax, Capacity);
|
||||
}
|
||||
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
// Behavior:
|
||||
// If bolt open just close it
|
||||
@@ -391,7 +391,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public override async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (CanInsertMagazine(eventArgs.User, eventArgs.Using, quiet: false))
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
/// Only difference between them is how they retrieve a projectile to shoot (battery, magazine, etc.)
|
||||
/// </summary>
|
||||
#pragma warning disable 618
|
||||
public abstract class ServerRangedBarrelComponent : SharedRangedBarrelComponent, IUse, IInteractUsing, IExamine, ISerializationHooks
|
||||
public abstract class ServerRangedBarrelComponent : SharedRangedBarrelComponent, IExamine, ISerializationHooks
|
||||
#pragma warning restore 618
|
||||
{
|
||||
// There's still some of py01 and PJB's work left over, especially in underlying shooting logic,
|
||||
@@ -133,9 +133,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAdd()
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.OnAdd();
|
||||
base.Initialize();
|
||||
|
||||
Owner.EnsureComponentWarn(out ServerRangedWeaponComponent rangedWeaponComponent);
|
||||
|
||||
@@ -167,10 +167,6 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
||||
return angle;
|
||||
}
|
||||
|
||||
public abstract bool UseEntity(UseEntityEventArgs eventArgs);
|
||||
|
||||
public abstract Task<bool> InteractUsing(InteractUsingEventArgs eventArgs);
|
||||
|
||||
public void ChangeFireSelector(FireRateSelector rateSelector)
|
||||
{
|
||||
if ((rateSelector & AllRateSelectors) != 0)
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Content.Server.Weapon.Ranged
|
||||
{
|
||||
//Wound them
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(user, ClumsyDamage);
|
||||
EntitySystem.Get<StunSystem>().TryParalyze(user, TimeSpan.FromSeconds(3f));
|
||||
EntitySystem.Get<StunSystem>().TryParalyze(user, TimeSpan.FromSeconds(3f), true);
|
||||
|
||||
// Apply salt to the wound ("Honk!")
|
||||
SoundSystem.Play(
|
||||
|
||||
Reference in New Issue
Block a user