Fix water postshader (#28130)

This commit is contained in:
metalgearsloth
2024-05-26 06:23:34 +10:00
committed by GitHub
parent afb1acab10
commit 93f289c7dc
3 changed files with 42 additions and 42 deletions

View File

@@ -15,39 +15,37 @@ public abstract class SharedFloorOcclusionSystem : EntitySystem
SubscribeLocalEvent<FloorOccluderComponent, EndCollideEvent>(OnEndCollide);
}
private void OnStartCollide(EntityUid uid, FloorOccluderComponent component, ref StartCollideEvent args)
private void OnStartCollide(Entity<FloorOccluderComponent> entity, ref StartCollideEvent args)
{
var other = args.OtherEntity;
if (!TryComp<FloorOcclusionComponent>(other, out var occlusion) ||
occlusion.Colliding.Contains(uid))
occlusion.Colliding.Contains(entity.Owner))
{
return;
}
SetEnabled(other, occlusion, true);
occlusion.Colliding.Add(uid);
occlusion.Colliding.Add(entity.Owner);
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}
private void OnEndCollide(EntityUid uid, FloorOccluderComponent component, ref EndCollideEvent args)
private void OnEndCollide(Entity<FloorOccluderComponent> entity, ref EndCollideEvent args)
{
var other = args.OtherEntity;
if (!TryComp<FloorOcclusionComponent>(other, out var occlusion))
return;
occlusion.Colliding.Remove(uid);
if (occlusion.Colliding.Count == 0)
SetEnabled(other, occlusion, false);
}
protected virtual void SetEnabled(EntityUid uid, FloorOcclusionComponent component, bool enabled)
{
if (component.Enabled == enabled)
if (!occlusion.Colliding.Remove(entity.Owner))
return;
component.Enabled = enabled;
Dirty(uid, component);
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}
protected virtual void SetEnabled(Entity<FloorOcclusionComponent> entity)
{
}
}