Created
September 11, 2020 08:56
-
-
Save joelpryde/0ffec028d5b5f0fed0626aff6ac828ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Unity.Entities; | |
using Unity.Jobs; | |
using Unity.Mathematics; | |
using Unity.Transforms; | |
using UnityEngine; | |
using Unity.Collections.LowLevel.Unsafe; | |
using System.Runtime.CompilerServices; | |
using Unity.Collections; | |
[CompilerGeneratedAttribute] | |
// This system updates all entities in the scene with both a RotationSpeed_ForEach and Rotation component. | |
// ReSharper disable once InconsistentNaming | |
public class RotationSpeedSystem_ForEach : SystemBase | |
{ | |
// OnUpdate runs on the main thread. | |
protected void OnUpdate_Patched() | |
{ | |
#line 15 "C:\Users\joelp\Documents\repos\dots\Samples\Assets\HelloCube\1. ForEach\RotationSpeedSystem_ForEach.cs" | |
float deltaTime = Time.DeltaTime; | |
#line 18 "C:\Users\joelp\Documents\repos\dots\Samples\Assets\HelloCube\1. ForEach\RotationSpeedSystem_ForEach.cs" | |
RotationSpeedSystem_ForEach_Execute(deltaTime); | |
} | |
struct RotationSpeedSystem_ForEach_Job : IJobChunk | |
{ | |
public RotationSpeedSystem_ForEach __this; | |
public float deltaTime; | |
public ComponentTypeHandle<Rotation> _rotationTypeHandle; | |
[ReadOnly] | |
public ComponentTypeHandle<RotationSpeed_ForEach> _rotationSpeedTypeHandle; | |
EntityQuery __query; | |
EntityQuery.GatherEntitiesResult __gatherEntitiesResult; | |
EntityQueryMask __mask; | |
void OriginalLambdaBody(ref Rotation rotation, in RotationSpeed_ForEach rotationSpeed) | |
{ | |
#line 23 "C:\Users\joelp\Documents\repos\dots\Samples\Assets\HelloCube\1. ForEach\RotationSpeedSystem_ForEach.cs" | |
rotation.Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * deltaTime)); | |
#line 26 "C:\Users\joelp\Documents\repos\dots\Samples\Assets\HelloCube\1. ForEach\RotationSpeedSystem_ForEach.cs" | |
var e = __this.EntityManager.CreateEntity(); | |
} | |
public unsafe void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) | |
{ | |
__mask = __this.EntityManager.GetEntityQueryMask(__query); | |
__query.GatherEntitiesToArray(out __gatherEntitiesResult); | |
var rotationAccessor = (Rotation*)chunk.GetNativeArray(_rotationTypeHandle).GetUnsafePtr(); | |
var rotationSpeedAccessor = (RotationSpeed_ForEach*)chunk.GetNativeArray(_rotationSpeedTypeHandle).GetUnsafeReadOnlyPtr(); | |
try | |
{ | |
int entityCount = __gatherEntitiesResult.EntityCount; | |
for (int i = 0; i != entityCount; i++) | |
{ | |
var entity = __gatherEntitiesResult.EntityBuffer[i]; | |
if (__mask.Matches(entity)) | |
{ | |
#line 56 "C:\Users\joelp\Documents\repos\dots\Samples\Temp\GeneratedCode\RotationSpeedSystem_ForEach.g.cs" | |
OriginalLambdaBody(ref UnsafeUtility.AsRef<Rotation>(rotationAccessor + i), *(rotationSpeedAccessor + i)); | |
} | |
} | |
} | |
finally | |
{ | |
__query.ReleaseGatheredEntities(ref __gatherEntitiesResult); | |
} | |
} | |
} | |
EntityQuery RotationSpeedSystem_ForEach_Query; | |
void RotationSpeedSystem_ForEach_Execute(float deltaTime) | |
{ | |
var job = new RotationSpeedSystem_ForEach_Job{__this = this, deltaTime = deltaTime, _rotationTypeHandle = GetComponentTypeHandle<Rotation>(), _rotationSpeedTypeHandle = GetComponentTypeHandle<RotationSpeed_ForEach>(true)}; | |
var chunkIterator_RotationSpeedSystem_ForEach = RotationSpeedSystem_ForEach_Query.GetArchetypeChunkIterator(); | |
JobChunkExtensions.RunWithoutJobs(ref job, ref chunkIterator_RotationSpeedSystem_ForEach); | |
} | |
protected override void OnCreateForCompiler() | |
{ | |
base.OnCreateForCompiler(); | |
RotationSpeedSystem_ForEach_Query = GetEntityQuery(new EntityQueryDesc{All = new ComponentType[]{ComponentType.ReadWrite<Rotation>(), ComponentType.ReadOnly<RotationSpeed_ForEach>()}, Any = new ComponentType[]{}, None = new ComponentType[]{}}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment