forked from Unity-Technologies/ECS-Network-Racing-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLobbyCameraSwitcherSystem.cs
More file actions
39 lines (36 loc) · 1.22 KB
/
Copy pathLobbyCameraSwitcherSystem.cs
File metadata and controls
39 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Unity.Burst;
using Unity.Entities.Racing.Common;
using Unity.Mathematics;
using static Unity.Entities.SystemAPI;
namespace Unity.Entities.Racing.Gameplay
{
/// <summary>
/// Creates camera transition for Lobby
/// </summary>
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
public partial struct LobbyCameraSwitcherSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<LocalUser>();
state.RequireForUpdate<CarInput>();
}
public void OnUpdate(ref SystemState state)
{
foreach (var (carInput, player)
in Query<RefRO<CarInput>, RefRO<Player>>().WithAll<LocalUser>())
{
if (player.ValueRO.State != PlayerState.Lobby)
{
return;
}
var hasAnyInput = math.abs(carInput.ValueRO.Horizontal) > 0 || math.abs(carInput.ValueRO.Vertical) > 0;
if (hasAnyInput && CameraSwitcher.Instance != null)
{
CameraSwitcher.Instance.ShowBackCamera();
state.Enabled = false;
}
}
}
}
}