-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathPrepareGlobalInputEventsSystem.cs
More file actions
46 lines (41 loc) · 1.96 KB
/
Copy pathPrepareGlobalInputEventsSystem.cs
File metadata and controls
46 lines (41 loc) · 1.96 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
40
41
42
43
44
45
46
using Arch.Core;
using Arch.SystemGroups;
using Arch.SystemGroups.DefaultSystemGroups;
using DCL.Diagnostics;
using DCL.ECSComponents;
using ECS.Abstract;
using System.Collections.Generic;
namespace DCL.Interaction.PlayerOriginated.Systems
{
/// <summary>
/// Refills <see cref="GlobalInputEvents" /> from scratch each frame, for the scene worlds to drain in
/// their PreRendering group later in the same frame. Anything else that adds an entry — an automation
/// driver such as McpInputActionSystem — must therefore run after this system and within the same frame;
/// moving the clear, or this system's group, silently drops those entries.
/// </summary>
[UpdateInGroup(typeof(PresentationSystemGroup))]
[LogCategory(ReportCategory.INPUT)]
public partial class PrepareGlobalInputEventsSystem : BaseUnityLoopSystem
{
private readonly GlobalInputEvents globalInputEvents;
private readonly IReadOnlyDictionary<InputAction, UnityEngine.InputSystem.InputAction> sdkInputActionsMap;
internal PrepareGlobalInputEventsSystem(World world,
GlobalInputEvents globalInputEvents,
IReadOnlyDictionary<InputAction, UnityEngine.InputSystem.InputAction> sdkInputActionsMap) : base(world)
{
this.globalInputEvents = globalInputEvents;
this.sdkInputActionsMap = sdkInputActionsMap;
}
protected override void Update(float t)
{
globalInputEvents.Clear();
foreach (KeyValuePair<InputAction, UnityEngine.InputSystem.InputAction> pair in sdkInputActionsMap)
{
if (pair.Value.WasPressedThisFrame())
globalInputEvents.Add(new IGlobalInputEvents.Entry(pair.Key, PointerEventType.PetDown));
if (pair.Value.WasReleasedThisFrame())
globalInputEvents.Add(new IGlobalInputEvents.Entry(pair.Key, PointerEventType.PetUp));
}
}
}
}