mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Port from [Goob](https://github.com/Goob-Station/Goob-Station/pull/989) --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Aviu00, Spatison - add: Added material silo --------- Signed-off-by: Spatison <137375981+Spatison@users.noreply.github.com> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 9897094a3c873ddca79ece3a5cdbb7d30252edfd)
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using Content.Shared.Materials;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Materials;
|
|
|
|
public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
|
{
|
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly TransformSystem _transform = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MaterialStorageComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
|
}
|
|
|
|
private void OnAppearanceChange(EntityUid uid, MaterialStorageComponent component, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null)
|
|
return;
|
|
|
|
if (!args.Sprite.LayerMapTryGet(MaterialStorageVisualLayers.Inserting, out var layer))
|
|
return;
|
|
|
|
if (!_appearance.TryGetData<bool>(uid, MaterialStorageVisuals.Inserting, out var inserting, args.Component))
|
|
return;
|
|
|
|
if (inserting && TryComp<InsertingMaterialStorageComponent>(uid, out var insertingComp))
|
|
{
|
|
args.Sprite.LayerSetAnimationTime(layer, 0f);
|
|
|
|
args.Sprite.LayerSetVisible(layer, true);
|
|
if (insertingComp.MaterialColor != null)
|
|
args.Sprite.LayerSetColor(layer, insertingComp.MaterialColor.Value);
|
|
}
|
|
else
|
|
{
|
|
args.Sprite.LayerSetVisible(layer, false);
|
|
}
|
|
}
|
|
|
|
public override bool TryInsertMaterialEntity(EntityUid user,
|
|
EntityUid toInsert,
|
|
EntityUid receiver,
|
|
MaterialStorageComponent? storage = null,
|
|
MaterialSiloUtilizerComponent? utilizer = null,
|
|
MaterialComponent? material = null,
|
|
PhysicalCompositionComponent? composition = null)
|
|
{
|
|
if (!base.TryInsertMaterialEntity(user, toInsert, receiver, storage, utilizer, material, composition))
|
|
return false;
|
|
_transform.DetachParentToNull(toInsert, Transform(toInsert));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public enum MaterialStorageVisualLayers : byte
|
|
{
|
|
Inserting
|
|
}
|