|
|
|
@ -109,11 +109,18 @@ public partial class InputManager |
|
|
|
|
{ |
|
|
|
|
entity.GetMut<RawValue1D>() = current; |
|
|
|
|
if (current >= ActivationThreshold) { |
|
|
|
|
ref var active = ref entity.GetRefOrNull<Active>(); |
|
|
|
|
if (Unsafe.IsNullRef(ref active)) { |
|
|
|
|
// TODO: Find out why using GetRefOrNull here crashes. |
|
|
|
|
if (entity.Has<Active>()) { |
|
|
|
|
entity.GetMut<Active>().Duration += delta; |
|
|
|
|
} else { |
|
|
|
|
entity.Set(new Active()); |
|
|
|
|
entity.Add<Activated>(); |
|
|
|
|
} else active.Duration += delta; |
|
|
|
|
} |
|
|
|
|
// ref var active = ref entity.GetRefOrNull<Active>(); |
|
|
|
|
// if (Unsafe.IsNullRef(ref active)) { |
|
|
|
|
// entity.Set(new Active()); |
|
|
|
|
// entity.Add<Activated>(); |
|
|
|
|
// } else active.Duration += delta; |
|
|
|
|
} else if (current <= DeactivationThreshold) |
|
|
|
|
entity.Remove<Active>(); |
|
|
|
|
} |
|
|
|
@ -123,11 +130,17 @@ public partial class InputManager |
|
|
|
|
entity.GetMut<RawValue2D>() = current; |
|
|
|
|
var magnitude = current.Length(); |
|
|
|
|
if (magnitude >= ActivationThreshold) { |
|
|
|
|
ref var active = ref entity.GetRefOrNull<Active>(); |
|
|
|
|
if (Unsafe.IsNullRef(ref active)) { |
|
|
|
|
if (entity.Has<Active>()) { |
|
|
|
|
entity.GetMut<Active>().Duration += delta; |
|
|
|
|
} else { |
|
|
|
|
entity.Set(new Active()); |
|
|
|
|
entity.Add<Activated>(); |
|
|
|
|
} else active.Duration += delta; |
|
|
|
|
} |
|
|
|
|
// ref var active = ref entity.GetRefOrNull<Active>(); |
|
|
|
|
// if (Unsafe.IsNullRef(ref active)) { |
|
|
|
|
// entity.Set(new Active()); |
|
|
|
|
// entity.Add<Activated>(); |
|
|
|
|
// } else active.Duration += delta; |
|
|
|
|
} else if (magnitude <= DeactivationThreshold) |
|
|
|
|
entity.Remove<Active>(); |
|
|
|
|
} |
|
|
|
@ -138,12 +151,12 @@ public partial class InputManager |
|
|
|
|
// public static void OnActiveAdded(EntityRef entity, Active _) |
|
|
|
|
// => entity.Add<Activated>(); |
|
|
|
|
|
|
|
|
|
[Observer<Core.OnRemove>] |
|
|
|
|
public static void OnActiveRemoved<T>(Entity<T> entity, Active _) |
|
|
|
|
=> entity.Add<Deactivated>(); |
|
|
|
|
// [Observer<Core.OnRemove>] |
|
|
|
|
// public static void OnActiveRemoved<T>(Entity<T> entity, Active _) |
|
|
|
|
// => entity.Add<Deactivated>(); |
|
|
|
|
|
|
|
|
|
[System] |
|
|
|
|
[DependsOn<Pipeline.PostFrame>] |
|
|
|
|
public static void ClearDeActivated<T>(Entity<T> entity, Has<Or<Activated, Deactivated>> _) |
|
|
|
|
=> entity.Remove<Activated>().Remove<Deactivated>(); |
|
|
|
|
// [System] |
|
|
|
|
// [DependsOn<Pipeline.PostFrame>] |
|
|
|
|
// public static void ClearDeActivated<T>(Entity<T> entity, Has<Or<Activated, Deactivated>> _) |
|
|
|
|
// => entity.Remove<Activated>().Remove<Deactivated>(); |
|
|
|
|
} |
|
|
|
|