Files
crystall-punk-14/Content.Shared/Movement/Systems/SharedFloorOcclusionSystem.cs
Ed cc80518d2f World minor changes (#519)
* x2 weather time

* remove alchemy test and battle royale maps, add simple island map

* island map + ocean parallax

* map floor occluder sys

* undercliff test

* update sand and ocean sprite

* Revert "undercliff test"

This reverts commit c484fe630a.

* more experiments

* Revert "more experiments"

This reverts commit a7f30fd608.

* Update default.yml

* Update debug.yml
2024-10-29 11:48:52 +03:00

54 lines
1.5 KiB
C#

using Content.Shared.Movement.Components;
using Robust.Shared.Physics.Events;
namespace Content.Shared.Movement.Systems;
/// <summary>
/// Applies an occlusion shader for any relevant entities.
/// </summary>
public abstract partial class SharedFloorOcclusionSystem : EntitySystem //CP14 partial
{
public override void Initialize()
{
base.Initialize();
CP14InitializeMapOccluder(); //CP14
SubscribeLocalEvent<FloorOccluderComponent, StartCollideEvent>(OnStartCollide);
SubscribeLocalEvent<FloorOccluderComponent, EndCollideEvent>(OnEndCollide);
}
private void OnStartCollide(Entity<FloorOccluderComponent> entity, ref StartCollideEvent args)
{
var other = args.OtherEntity;
if (!TryComp<FloorOcclusionComponent>(other, out var occlusion) ||
occlusion.Colliding.Contains(entity.Owner))
{
return;
}
occlusion.Colliding.Add(entity.Owner);
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}
private void OnEndCollide(Entity<FloorOccluderComponent> entity, ref EndCollideEvent args)
{
var other = args.OtherEntity;
if (!TryComp<FloorOcclusionComponent>(other, out var occlusion))
return;
if (!occlusion.Colliding.Remove(entity.Owner))
return;
Dirty(other, occlusion);
SetEnabled((other, occlusion));
}
protected virtual void SetEnabled(Entity<FloorOcclusionComponent> entity)
{
}
}