* - Combine enum keys `ToggleableLightVisuals` and `ToggleVisuals` into `ToggleableVisuals` - Rename `ToggleableLightVisualsComponent` to `ToggleableVisualsComponent` and `ToggleableLightVisualsSystem` to `ToggleableVisualsSystem` - (The `SpriteLayer` field on the component is now required because the old default of `light` doesn't make sense anymore) - Make it so that `ToggleableVisualsComponent` works even when there's not a light attached to the entity - (Amazingly this seems to have only applied to Headphones, but I can only imagine there are many other things people would like to do with simple toggleable visuals) - Explicitly make `ItemTogglePointLightComponent`'s purpose to make `ToggleVisualsComponent` apply to `PointLightComponent`s on the same entity. - Add field `ToggleableVisualsColorModulatesLights`, which makes the `Color` appearance value of `ToggleableVisuals` modulate the color of lights on the same entity - Lots of prototype updates to uptake the above * fix bad merge * unbork robust * blindly letting rider reformat stuff * I guess I never cleaned up these imports at all
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Robust.Shared.Containers;
|
|
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Storage;
|
|
using Content.Shared.Storage.EntitySystems;
|
|
using Content.Shared.Toggleable;
|
|
|
|
namespace Content.Shared.ContainerHeld;
|
|
|
|
public sealed class ContainerHeldSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedItemSystem _item = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ContainerHeldComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
|
|
SubscribeLocalEvent<ContainerHeldComponent, EntRemovedFromContainerMessage>(OnContainerModified);
|
|
}
|
|
|
|
private void OnContainerModified(EntityUid uid, ContainerHeldComponent comp, ContainerModifiedMessage args)
|
|
{
|
|
if (!(HasComp<StorageComponent>(uid)
|
|
&& TryComp<AppearanceComponent>(uid, out var appearance)
|
|
&& TryComp<ItemComponent>(uid, out var item)))
|
|
{
|
|
return;
|
|
}
|
|
if (_storage.GetCumulativeItemAreas(uid) >= comp.Threshold)
|
|
{
|
|
_item.SetHeldPrefix(uid, "full", component: item);
|
|
_appearance.SetData(uid, ToggleableVisuals.Enabled, true, appearance);
|
|
}
|
|
else
|
|
{
|
|
_item.SetHeldPrefix(uid, "empty", component: item);
|
|
_appearance.SetData(uid, ToggleableVisuals.Enabled, false, appearance);
|
|
}
|
|
}
|
|
}
|