Speed Boots [Tier 3 Civ-Service] (#21438)

* Speed Boots

* validate

* monkey
This commit is contained in:
Nemanja
2023-11-07 20:25:43 -05:00
committed by GitHub
parent a6985e5b4b
commit 94368f1f00
24 changed files with 296 additions and 33 deletions

View File

@@ -2,24 +2,26 @@ using Content.Shared.Containers.ItemSlots;
using Content.Shared.PowerCell.Components;
using Content.Shared.Rejuvenate;
using Robust.Shared.Containers;
using Robust.Shared.Timing;
namespace Content.Shared.PowerCell;
public abstract class SharedPowerCellSystem : EntitySystem
{
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PowerCellSlotComponent, RejuvenateEvent>(OnRejuventate);
SubscribeLocalEvent<PowerCellSlotComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<PowerCellSlotComponent, EntInsertedIntoContainerMessage>(OnCellInserted);
SubscribeLocalEvent<PowerCellSlotComponent, EntRemovedFromContainerMessage>(OnCellRemoved);
SubscribeLocalEvent<PowerCellSlotComponent, ContainerIsInsertingAttemptEvent>(OnCellInsertAttempt);
}
private void OnRejuventate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args)
private void OnRejuvenate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args)
{
if (!_itemSlots.TryGetSlot(uid, component.CellSlotId, out var itemSlot) || !itemSlot.Item.HasValue)
return;
@@ -60,4 +62,35 @@ public abstract class SharedPowerCellSystem : EntitySystem
_appearance.SetData(uid, PowerCellSlotVisuals.Enabled, false);
RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false);
}
public void SetPowerCellDrawEnabled(EntityUid uid, bool enabled, PowerCellDrawComponent? component = null)
{
if (!Resolve(uid, ref component, false) || enabled == component.Drawing)
return;
component.Drawing = enabled;
component.NextUpdateTime = Timing.CurTime;
}
/// <summary>
/// Returns whether the entity has a slotted battery and <see cref="PowerCellDrawComponent.UseRate"/> charge.
/// </summary>
/// <param name="uid"></param>
/// <param name="battery"></param>
/// <param name="cell"></param>
/// <param name="user">Popup to this user with the relevant detail if specified.</param>
public abstract bool HasActivatableCharge(
EntityUid uid,
PowerCellDrawComponent? battery = null,
PowerCellSlotComponent? cell = null,
EntityUid? user = null);
/// <summary>
/// Whether the power cell has any power at all for the draw rate.
/// </summary>
public abstract bool HasDrawCharge(
EntityUid uid,
PowerCellDrawComponent? battery = null,
PowerCellSlotComponent? cell = null,
EntityUid? user = null);
}