Make BatteryBarrelComponent use item slots. (#5591)

This commit is contained in:
Leon Friedrich
2021-12-05 16:23:47 +13:00
committed by GitHub
parent f96b8a8b0f
commit e8b2d0a844
11 changed files with 184 additions and 334 deletions

View File

@@ -1,6 +1,7 @@
using System;
using Content.Client.Items.Components;
using Content.Client.Stylesheets;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Weapons.Ranged.Barrels.Components;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
@@ -8,6 +9,7 @@ using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using static Robust.Client.UserInterface.Controls.BoxContainer;
@@ -21,6 +23,9 @@ namespace Content.Client.Weapons.Ranged.Barrels.Components
private StatusControl? _statusControl;
[DataField("cellSlot", required: true)]
public ItemSlot CellSlot = default!;
/// <summary>
/// Count of bullets in the magazine.
/// </summary>
@@ -30,6 +35,18 @@ namespace Content.Client.Weapons.Ranged.Barrels.Components
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
protected override void Initialize()
{
base.Initialize();
EntitySystem.Get<ItemSlotsSystem>().AddItemSlot(OwnerUid, $"{Name}-powercell-container", CellSlot);
}
protected override void OnRemove()
{
base.OnRemove();
EntitySystem.Get<ItemSlotsSystem>().RemoveItemSlot(OwnerUid, CellSlot);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);