public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref RepCubeSnapshotData snapshot) { snapshot.tick = tick; var chunkDataRepCubeComponentData = chunk.GetNativeArray(ghostRepCubeComponentDataType); snapshot.SetRepCubeComponentDatanetworkId(chunkDataRepCubeComponentData[ent].networkId); snapshot.SetRepCubeComponentDataposition(chunkDataRepCubeComponentData[ent].position); snapshot.SetRepCubeComponentDatacolor(chunkDataRepCubeComponentData[ent].color); }
public void Execute(ArchetypeChunk batchInChunk, int batchIndex) { if (!batchInChunk.DidChange(LocalToWorldTypeHandle, LastSystemVersion)) { return; } var chunkLocalToWorld = batchInChunk.GetNativeArray(LocalToWorldTypeHandle); var chunkWorldToLocal = batchInChunk.GetNativeArray(WorldToLocalTypeHandle); for (int i = 0; i < batchInChunk.Count; i++) { var localToWorld = chunkLocalToWorld[i].Value; chunkWorldToLocal[i] = new WorldToLocal { Value = math.inverse(localToWorld) }; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // If current was written after copying it to prev we need to interpolate, otherwise they must be identical if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(curRotationType), chunk.GetChangeVersion(prevRotationType))) { var prevRot = chunk.GetNativeArray(prevRotationType); var curRot = chunk.GetNativeArray(curRotationType); var rot = chunk.GetNativeArray(rotationType); for (var ent = 0; ent < rot.Length; ++ent) { var a = math.slerp(prevRot[ent].Value, curRot[ent].Value, curWeight); rot[ent] = new Rotation { Value = a }; } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int entityOffset) { var testDataArray = chunk.GetNativeArray(ecsTestType); testDataArray[0] = new EcsTestData { value = entityOffset }; }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // For all chunks where trans has changed since start of simulation // Copy trans to currentTrans if (ChangeVersionUtility.DidChange(chunk.GetComponentVersion(rotationType), simStartComponentVersion)) { // Transform was interpolated by the rendering system var curRot = chunk.GetNativeArray(curRotationType); var rot = chunk.GetNativeArray(rotationType); // FIXME: use a memcopy since size and layout must be identical for (int ent = 0; ent < curRot.Length; ++ent) { curRot[ent] = new CurrentSimulatedRotation { Value = rot[ent].Value }; } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <Velocity> chunkVelocities = chunk.GetNativeArray(velocityType); for (int i = 0; i < chunk.Count; i++) { chunkVelocities[i] = Calculate(firstEntityIndex + i); } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var entities = chunk.GetNativeArray(EntityType); for (var i = 0; i < entities.Length; ++i) { EntityIndexMap.TryAdd(entities[i], firstEntityIndex + i); } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var Entities = chunk.GetNativeArray(EntityType); for (int i = 0; i < chunk.Count; ++i) { ecb.RemoveComponent(chunkIndex, Entities[i], typeof(C_Holding)); } }
public void Execute(ArchetypeChunk chunk, int chunkIndex) { var oneshots = chunk.GetNativeArray(oneshotHandle); var entities = chunk.GetNativeArray(entityHandle); var lastAudioFrame = audioFrame.Value - 1; int samplesPerFrame = samplesPerSubframe * settingsCdfe[worldBlackboardEntity].audioSubframesPerFrame; for (int i = 0; i < oneshots.Length; i++) { var os = oneshots[i]; int playedFrames = lastAudioFrame - os.m_spawnedAudioFrame; double resampleRate = os.clip.Value.sampleRate / (double)sampleRate; if (os.isInitialized && os.clip.Value.samplesLeftOrMono.Length < resampleRate * playedFrames * samplesPerFrame) { dcb.Add(entities[i], chunkIndex); } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var entities = chunk.GetNativeArray(ChunkEntityType); for (var i = 0; i < chunk.Count; ++i) { DestroyHierarchy(CmdBuffer, entities[i], firstEntityIndex + i, ChildrenFromEntity); } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var chunkAnimators = chunk.GetNativeArray(AnimationType); for (var i = 0; i < chunk.Count; i++) { var animComp = chunkAnimators[i]; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var arr_ent = chunk.GetNativeArray(entType); for (int i = 0; i < chunk.Count; ++i) { cmdBuf.DestroyEntity(chunkIndex, arr_ent[i]); } }
public void Execute(int chunkIndex) { ArchetypeChunk chunk = chunks[chunkIndex]; //Get native arrays of component datas in chunk NativeArray <Position> positions = chunk.GetNativeArray(PositionType); NativeArray <MoveSpeed> speeds = chunk.GetNativeArray(SpeedType); //Debug.Log(chunk.Count); for (int i = 0; i < chunk.Count; i++) { positions[i] = new Position { Value = positions[i].Value + new float3(Vector3.right) * speeds[i].Value * deltaTime } } ; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var chunkTranslations = chunk.GetNativeArray(TranslationType); Debug.Log(chunk.Count); Debug.Log(chunkTranslations.Length); Debug.Log(chunkIndex); Debug.Log(firstEntityIndex); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <CoordinatesComponent> coordinatesArray = chunk.GetNativeArray(Coordinates); NativeArray <BlockTypesComponent> blockTypesArray = chunk.GetNativeArray(BlockTypes); SeedComponent seed = chunk.GetChunkComponentData(Seed); for (int i = 0; i < chunk.Count; i++) { int3 coordinates = coordinatesArray[i].Coordinates; ReadonlyVector3Int heights = TerrainGenerator.CalculateHeights_NoiseSampler(seed.Seed, coordinates.x, coordinates.z); blockTypesArray[i] = new BlockTypesComponent() { BlockType = TerrainGenerator.DetermineType_NoiseSampler(seed.Seed, coordinates.x, coordinates.y, coordinates.z, in heights) }; } } }
void ProcessLtw(ArchetypeChunk chunk, int firstEntityIndex) { var oneshots = chunk.GetNativeArray(oneshotHandle); var ltws = chunk.GetNativeArray(ltwHandle); AudioSourceEmitterCone cone = default; for (int i = 0; i < chunk.Count; i++) { var ltw = ltws[i]; emitters[firstEntityIndex + i] = new OneshotEmitter { source = oneshots[i], transform = new RigidTransform(quaternion.LookRotationSafe(ltw.Forward, ltw.Up), ltw.Position), cone = cone, useCone = false }; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var chunkRotations = chunk.GetNativeArray(RotationType); var chunkRotationSpeeds = chunk.GetNativeArray(RotationSpeedType); for (var i = 0; i < chunk.Count; i++) { var rotation = chunkRotations[i]; var rotationSpeed = chunkRotationSpeeds[i]; // Rotate something about its up vector at the speed given by RotationSpeed_IJobChunk. chunkRotations[i] = new Rotation { Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * DeltaTime)) }; } }
void ProcessTranslationRotationCone(ArchetypeChunk chunk, int firstEntityIndex) { var loopeds = chunk.GetNativeArray(loopedHandle); var translations = chunk.GetNativeArray(translationHandle); var rotations = chunk.GetNativeArray(rotationHandle); var cones = chunk.GetNativeArray(coneHandle); for (int i = 0; i < chunk.Count; i++) { emitters[firstEntityIndex + i] = new LoopedEmitter { source = loopeds[i], transform = new RigidTransform(rotations[i].Value, translations[i].Value), cone = cones[i], useCone = true }; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <Translation> chunkTranslations = chunk.GetNativeArray(translationType); for (int i = 0; i < chunk.Count; i++) { translations[firstEntityIndex + i] = chunkTranslations[i].Value.xz; } }
void ProcessLtwCone(ArchetypeChunk chunk, int firstEntityIndex) { var loopeds = chunk.GetNativeArray(loopedHandle); var ltws = chunk.GetNativeArray(ltwHandle); var cones = chunk.GetNativeArray(coneHandle); for (int i = 0; i < chunk.Count; i++) { var ltw = ltws[i]; emitters[firstEntityIndex + i] = new LoopedEmitter { source = loopeds[i], transform = new RigidTransform(quaternion.LookRotationSafe(ltw.Forward, ltw.Up), ltw.Position), cone = cones[i], useCone = true }; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var stateTypeRo = StateType; bool *ro = &stateTypeRo.m_IsReadOnly; * ro = true; var chunkStates = chunk.GetNativeArray(stateTypeRo);//delay version change var chunkCount = chunk.Count; var chunkTypeIds = (int *)chunk.Archetype.Archetype->Types; var chunkTypeCount = chunk.Archetype.Archetype->TypesCount; var alignedCount = (Info.RegisteredCount + 3) & -4; //align count to 4 int *chunkTypeMatch = stackalloc int[alignedCount + 1]; //one extra space for untracked fill UnsafeUtility.MemClear(chunkTypeMatch, alignedCount * sizeof(int)); //set all 0 fro match var pChunkTracks = (ComponentExist *)NativeArrayUnsafeUtility.GetUnsafePtr(chunkStates); var map = Info.TypeOffset2TrackIndex; bool hasMatch = false; //find all tracked types for (int i = 0; i < chunkTypeCount; i++) { var trackId = map[chunkTypeIds[i] & TypeManager.ClearFlagsMask]; var match = trackId > UnTracked; hasMatch = hasMatch | match; chunkTypeMatch[math.select(alignedCount, trackId, match)] = 1;//set 1 for match } bool anyExistChange = false; if (!hasMatch) { //No tracked component on this chunk, update as none-exist for (int i = 0; i < chunkCount; i++) { var track = pChunkTracks + i; for (int trackID = 0; trackID < alignedCount; trackID += 4) { var quadID = trackID >> K_TrackID2QuadIDShift; ref var quadState = ref *(track->QuadTracks + quadID); var intState = (int)quadState; //var quad = intTrack >> math.int4(0, 2, 4, 6); //not implemented var int4State = math.int4(intState, intState >> 2, intState >> 4, intState >> 6); int4State &= K_KeepLowestMask; var wasExist4 = int4State >= (int)ExistState.ExistedLastSync; anyExistChange |= math.any(wasExist4); // if (math.any(wasExist4 != math.bool4(false))) // Debug.Log($"No Match TID[{trackID}], QID[{quadID}], WasExist={wasExist4}, isExist={math.bool4(false)}, PrevState:{int4State}"); int4State = math.select(math.int4((int)ExistState.None), math.int4((int)ExistState.RemovedLastSync), wasExist4); quadState = (byte)(int4State.x | int4State.y << 2 | int4State.z << 4 | int4State.w << 6); } } return; }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var droneIds = chunk.GetNativeArray(DroneId); var stats = chunk.GetNativeArray(Statuses); var points = chunk.GetNativeArray(CurrentPoint); for (var i = 0; i < chunk.Count; ++i) { if (stats[i].Value != Status.RequestingWaypoints) { continue; } var p = points[i]; p.index = -1; points[i] = p; Completed.Enqueue(droneIds[i].Value); } }
public unsafe Runtime PrepareToExecuteOnEntitiesIn(ref ArchetypeChunk chunk) { var ptr = (Entity *)chunk.GetNativeArray(_type).GetUnsafeReadOnlyPtr(); return(new Runtime() { arrayPtr = ptr }); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var renderSubjects = chunk.GetNativeArray <SpriteRenderSubject>(RenderSubject_Type); for (int i = 0; i < chunk.Count; i++) { uvIndexBuffer[renderSubjects[i].bufferIndex] = renderSubjects[i].uvIndex; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var curPos = chunk.GetNativeArray(curPositionType); var pos = chunk.GetNativeArray(positionType); var entity = chunk.GetNativeArray(entityType); // FIXME: use a memcopy since size and layout must be identical for (int ent = 0; ent < curPos.Length; ++ent) { var cp = pos[ent]; curPos[ent] = new CurrentSimulatedPosition { Value = cp.Value }; commandBuffer.AddComponent(chunkIndex, entity[ent], new PreviousSimulatedPosition { Value = cp.Value }); } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var scrollBarArray = chunk.GetNativeArray(ScrollBarType); var entityArray = chunk.GetNativeArray(EntityType); for (int i = 0; i < chunk.Count; i++) { var scrollBar = scrollBarArray[i]; if (TargetToEvent.TryGetValue(entityArray[i], out var eventEntity)) { var pointerBuff = PointerBufferFromEntity[eventEntity]; for (int j = 0; j < pointerBuff.Length; j++) { scrollBarArray[i] = HandleInputEvent(entityArray[i], scrollBar, pointerBuff[j]); } } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // If current was written after copying it to prev we need to interpolate, otherwise they must be identical if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(curPositionType), chunk.GetChangeVersion(prevPositionType))) { var prevPos = chunk.GetNativeArray(prevPositionType); var curPos = chunk.GetNativeArray(curPositionType); var pos = chunk.GetNativeArray(positionType); for (var ent = 0; ent < pos.Length; ++ent) { var p = curPos[ent].Value * curWeight + prevPos[ent].Value * prevWeight; pos[ent] = new Translation { Value = p }; } } }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref PilotSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataCameraRigChild = chunk.GetNativeArray(ghostCameraRigChildType); var chunkDataPilotData = chunk.GetNativeArray(ghostPilotDataType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetCameraRigChildheadPose(chunkDataCameraRigChild[ent].headPose, serializerState); snapshot.SetCameraRigChildheadRot(chunkDataCameraRigChild[ent].headRot, serializerState); snapshot.SetCameraRigChildleftHandPose(chunkDataCameraRigChild[ent].leftHandPose, serializerState); snapshot.SetCameraRigChildleftHandRot(chunkDataCameraRigChild[ent].leftHandRot, serializerState); snapshot.SetCameraRigChildrightHandPose(chunkDataCameraRigChild[ent].rightHandPose, serializerState); snapshot.SetCameraRigChildrightHandRot(chunkDataCameraRigChild[ent].rightHandRot, serializerState); snapshot.SetPilotDataPlayerId(chunkDataPilotData[ent].PlayerId, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
float4x4 *GetLocalToWorldSourceBuffer(ArchetypeChunk chunk) { var chunkCustomLocalToWorld = chunk.GetNativeArray(CustomLocalToWorldType); var chunkLocalToWorld = chunk.GetNativeArray(LocalToWorldType); if (chunkCustomLocalToWorld.Length > 0) { return((float4x4 *)chunkCustomLocalToWorld.GetUnsafeReadOnlyPtr()); } else if (chunkLocalToWorld.Length > 0) { return((float4x4 *)chunkLocalToWorld.GetUnsafeReadOnlyPtr()); } else { return(null); } }
public void Execute(ArchetypeChunk batch, int batchIndex, int indexOfFirstEntityInQuery) { var testDataArray = batch.GetNativeArray(EcsTestTypeHandle); testDataArray[0] = new EcsTestData { value = indexOfFirstEntityInQuery }; }