mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
* initial sidestream port * ru locale * blyatison * упс * jannie qol (#6) * initial sidestream port * blyadison * cs1.4 (#4) * initial sidestream port * blyatison * antitryaska (#7) * initial sidestream port (still fucked though) * blyatison * o fugg (#8) speedmerge * o fugg * fugg :-DDD * attempt numero uno (#9) * fix desword sound (#10) * раз уж я тут сижу * whoops * shit --------- Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com>
64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared._White.RenderOrderSystem;
|
|
|
|
|
|
public abstract class SharedRenderOrderSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<RenderOrderComponent, ComponentStartup>(DrawOrderComponentStartup);
|
|
}
|
|
|
|
public void MoveToTop(EntityUid uid) => SetRenderOrder(uid, EntityManager.CurrentTick.Value, "default");
|
|
public void MoveToTop(EntityUid uid, string key) => SetRenderOrder(uid, EntityManager.CurrentTick.Value, key);
|
|
|
|
public void SetRenderOrder(EntityUid uid, uint value) => SetRenderOrder(uid, value, "default");
|
|
public void SetRenderOrder(EntityUid uid, uint value, string key)
|
|
{
|
|
var comp = EnsureComp<RenderOrderComponent>(uid);
|
|
|
|
if (comp.ValueOrder.Remove(key))
|
|
DebugTools.Assert(comp.Values.Remove(key), $"Had key \"{key}\" in comp.ValueOrder but not in comp.Values");
|
|
|
|
comp.Values[key] = value;
|
|
comp.ValueOrder.Add(key);
|
|
|
|
UpdateRenderOrder(uid, comp);
|
|
}
|
|
public void UnsetRenderOrder(EntityUid uid) => UnsetRenderOrder(uid, "default");
|
|
public void UnsetRenderOrder(EntityUid uid, string key)
|
|
{
|
|
if (!TryComp<RenderOrderComponent>(uid, out var comp))
|
|
return;
|
|
|
|
var dontcryiam = comp.Values.Remove(key);
|
|
var justafish = comp.ValueOrder.Remove(key);
|
|
DebugTools.Assert( dontcryiam == justafish, $"{(dontcryiam ? "Removed": "Did not remove")} key from comp.Values: but {(justafish ? "removed" : "did not remove")} same key from comp.ValueOrder.");
|
|
UpdateRenderOrder(uid, comp);
|
|
}
|
|
|
|
protected virtual void UpdateRenderOrder(EntityUid uid, RenderOrderComponent comp)
|
|
{
|
|
Dirty(uid, comp);
|
|
}
|
|
|
|
protected virtual void DrawOrderComponentStartup(EntityUid uid, RenderOrderComponent comp, ComponentStartup args)
|
|
{
|
|
UpdateRenderOrder(uid, comp);
|
|
}
|
|
}
|
|
|
|
|
|
[RegisterComponent]
|
|
[AutoGenerateComponentState(true), NetworkedComponent]
|
|
public sealed partial class RenderOrderComponent : Component
|
|
{
|
|
[AutoNetworkedField, ViewVariables(VVAccess.ReadOnly)]
|
|
public Dictionary<string, uint> Values = new();
|
|
|
|
[AutoNetworkedField, ViewVariables(VVAccess.ReadOnly)]
|
|
public HashSet<string> ValueOrder = new();
|
|
}
|