mirror of
https://github.com/hanzoai/ProjectTinySamples.git
synced 2026-09-24 00:01:34 +00:00
25 lines
703 B
C#
25 lines
703 B
C#
using Unity.Entities;
|
|
|
|
namespace TinyPhysics.Systems
|
|
{
|
|
/// <summary>
|
|
/// Open door when player is nearby
|
|
/// </summary>
|
|
[UpdateAfter(typeof(ProximitySystem))]
|
|
public class ElevatorProximitySystem : SystemBase
|
|
{
|
|
protected override void OnUpdate()
|
|
{
|
|
Entities.ForEach((ref Proximity proximity, ref Elevator elevator) =>
|
|
{
|
|
if (proximity.distanceHit.Entity != Entity.Null)
|
|
{
|
|
elevator.ElevatorState = ElevatorState.GoingDown;
|
|
}
|
|
else
|
|
elevator.ElevatorState = ElevatorState.GoingUp;
|
|
}).ScheduleParallel();
|
|
}
|
|
}
|
|
}
|