* init magic container system * charging and discharging * add energy regenerator * thaumaturgy glasses, scanning energy * add energy quartz prorotypes and sprites * light power controller * commit special for _des * simple normalizer crystal slot * YEEEEEEE BOIII, examined crystalls inside things * кристал теперь видно, когда он вставлен в стабилизатор * TryUseCharge приборами * hello deserty, how are you doing? * rename regenerator to EnergyDraw, allow draw from slot * normalizer жрет magic energy файналли * Update normalizer.yml * visual polishing * Update crystal.yml
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using Content.Shared._CP14.MagicEnergy.Components;
|
|
using Content.Shared.Containers.ItemSlots;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared._CP14.MagicEnergy;
|
|
|
|
public partial class SharedCP14MagicEnergyCrystalSlotSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<CP14MagicEnergyCrystalSlotComponent, EntInsertedIntoContainerMessage>(OnCrystalInserted);
|
|
SubscribeLocalEvent<CP14MagicEnergyCrystalSlotComponent, EntRemovedFromContainerMessage>(OnCrystalRemoved);
|
|
}
|
|
|
|
private void OnCrystalRemoved(Entity<CP14MagicEnergyCrystalSlotComponent> slot, ref EntRemovedFromContainerMessage args)
|
|
{
|
|
if (args.Container.ID != slot.Comp.SlotId)
|
|
return;
|
|
|
|
_appearance.SetData(slot, CP14MagicSlotVisuals.Inserted, false);
|
|
_appearance.SetData(slot, CP14MagicSlotVisuals.Powered, false);
|
|
RaiseLocalEvent(slot, new CP14SlotCrystalChangedEvent(true));
|
|
}
|
|
|
|
private void OnCrystalInserted(Entity<CP14MagicEnergyCrystalSlotComponent> slot, ref EntInsertedIntoContainerMessage args)
|
|
{
|
|
if (!slot.Comp.Initialized)
|
|
return;
|
|
|
|
if (args.Container.ID != slot.Comp.SlotId)
|
|
return;
|
|
|
|
_appearance.SetData(slot, CP14MagicSlotVisuals.Inserted, true);
|
|
RaiseLocalEvent(slot, new CP14SlotCrystalChangedEvent(false));
|
|
}
|
|
}
|