Power cell culling (#8814)
This commit is contained in:
@@ -12,25 +12,15 @@ namespace Content.Shared.PowerCell;
|
||||
public sealed class PowerCellComponent : Component
|
||||
{
|
||||
public const string SolutionName = "powerCell";
|
||||
public const int PowerCellVisualsLevels = 4;
|
||||
|
||||
[DataField("cellSize")]
|
||||
public PowerCellSize CellSize = PowerCellSize.Small;
|
||||
public const int PowerCellVisualsLevels = 2;
|
||||
|
||||
// Not networked to clients
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool IsRigged { get; set; }
|
||||
}
|
||||
|
||||
public enum PowerCellSize
|
||||
{
|
||||
Small = 0,
|
||||
Medium = 1,
|
||||
Large = 2
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum PowerCellVisuals
|
||||
public enum PowerCellVisuals : byte
|
||||
{
|
||||
ChargeLevel
|
||||
}
|
||||
|
||||
@@ -5,13 +5,6 @@ namespace Content.Shared.PowerCell.Components;
|
||||
[RegisterComponent]
|
||||
public sealed class PowerCellSlotComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// What size of cell fits into this component.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("slotSize")]
|
||||
public PowerCellSize SlotSize { get; set; } = PowerCellSize.Small;
|
||||
|
||||
/// <summary>
|
||||
/// The actual item-slot that contains the cell. Allows all the interaction logic to be handled by <see cref="ItemSlotsSystem"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,8 +18,6 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, ComponentInit>(OnCellSlotInit);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, ComponentRemove>(OnCellSlotRemove);
|
||||
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, ExaminedEvent>(OnSlotExamined);
|
||||
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, EntInsertedIntoContainerMessage>(OnCellInserted);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, EntRemovedFromContainerMessage>(OnCellRemoved);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, ContainerIsInsertingAttemptEvent>(OnCellInsertAttempt);
|
||||
@@ -33,7 +31,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
||||
if (args.Container.ID != component.CellSlot.ID)
|
||||
return;
|
||||
|
||||
if (!TryComp(args.EntityUid, out PowerCellComponent? cell) || cell.CellSize != component.SlotSize)
|
||||
if (!HasComp<PowerCellComponent>(args.EntityUid))
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
@@ -67,41 +65,10 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
||||
{
|
||||
component.CellSlot.Name = component.SlotName;
|
||||
}
|
||||
|
||||
if (component.StartEmpty)
|
||||
return;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(component.CellSlot.StartingItem))
|
||||
return;
|
||||
|
||||
// set default starting cell based on cell-type
|
||||
component.CellSlot.StartingItem = component.SlotSize switch
|
||||
{
|
||||
PowerCellSize.Small => "PowerCellSmallStandard",
|
||||
PowerCellSize.Medium => "PowerCellMediumStandard",
|
||||
PowerCellSize.Large => "PowerCellLargeStandard",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
private void OnCellSlotRemove(EntityUid uid, PowerCellSlotComponent component, ComponentRemove args)
|
||||
{
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, component.CellSlot);
|
||||
}
|
||||
|
||||
private void OnSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!args.IsInDetailsRange || string.IsNullOrWhiteSpace(component.DescFormatString))
|
||||
return;
|
||||
|
||||
var sizeText = Loc.GetString(component.SlotSize switch
|
||||
{
|
||||
PowerCellSize.Small => "power-cell-slot-component-description-size-small",
|
||||
PowerCellSize.Medium => "power-cell-slot-component-description-size-medium",
|
||||
PowerCellSize.Large => "power-cell-slot-component-description-size-large",
|
||||
_ => "???"
|
||||
});
|
||||
|
||||
args.PushMarkup(Loc.GetString(component.DescFormatString, ("size", sizeText)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user