public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref NetCodeTestGhostObjectSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; NativeArray <Rotation> chunkDataRotation = chunk.GetNativeArray(ghostRotationType); NativeArray <Translation> chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
public void SetAttackTarget(Entity val, GhostSerializerState serializerState) { AttackTarget = 0; if (serializerState.GhostStateFromEntity.Exists(val)) { var ghostState = serializerState.GhostStateFromEntity[val]; if (ghostState.despawnTick == 0) { AttackTarget = ghostState.ghostId; } } }
public void SetPlayerDatakilledBy(Entity val, GhostSerializerState serializerState) { PlayerDatakilledBy = 0; if (serializerState.GhostStateFromEntity.Exists(val)) { var ghostState = serializerState.GhostStateFromEntity[val]; if (ghostState.despawnTick == 0) { PlayerDatakilledBy = ghostState.ghostId; } } }
public void Set__GHOST_FIELD_NAME__(Entity val, GhostSerializerState serializerState) { __GHOST_FIELD_NAME__ = 0; if (serializerState.GhostStateFromEntity.Exists(val)) { var ghostState = serializerState.GhostStateFromEntity[val]; if (ghostState.despawnTick == 0) { __GHOST_FIELD_NAME__ = ghostState.ghostId; } } }
public void SetItemInputStateowner(Entity val, GhostSerializerState serializerState) { ItemInputStateowner = 0; if (serializerState.GhostStateFromEntity.Exists(val)) { var ghostState = serializerState.GhostStateFromEntity[val]; if (ghostState.despawnTick == 0) { ItemInputStateowner = ghostState.ghostId; } } }
public unsafe void CopyToSnapshot(ref GhostSerializerState serializerState, ref Snapshot snapshot, ref IComponentData component) { if (true) { #region __GHOST_COPY_TO_SNAPSHOT__ snapshot.__GHOST_FIELD_NAME__ = 0; snapshot.__GHOST_FIELD_NAME__SpawnTick = 0; if (serializerState.GhostFromEntity.HasComponent(component.__GHOST_FIELD_REFERENCE__)) { var ghostComponent = serializerState.GhostFromEntity[component.__GHOST_FIELD_REFERENCE__]; snapshot.__GHOST_FIELD_NAME__ = ghostComponent.ghostId; snapshot.__GHOST_FIELD_NAME__SpawnTick = ghostComponent.spawnTick; } #endregion } }
public void Set__GHOST_FIELD_NAME__(quaternion q, GhostSerializerState serializerState) { Set__GHOST_FIELD_NAME__(q); }
public void SetPlayerUnitUnitId(int val, GhostSerializerState serializerState) { PlayerUnitUnitId = (int)val; }
public void SetHealthValue(float val, GhostSerializerState serializerState) { HealthValue = (int)(val * 100); }
public void SetUnitSelectionStateIsSelected(bool val, GhostSerializerState serializerState) { UnitSelectionStateIsSelected = val?1u:0; }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref SphereSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataPlayerData = chunk.GetNativeArray(ghostPlayerDataType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetPlayerDataplayerId(chunkDataPlayerData[ent].playerId, serializerState); snapshot.SetPlayerDatamaxHealth(chunkDataPlayerData[ent].maxHealth, serializerState); snapshot.SetPlayerDatacurrentHealth(chunkDataPlayerData[ent].currentHealth, serializerState); snapshot.SetPlayerDatadeath(chunkDataPlayerData[ent].death, serializerState); snapshot.SetPlayerDataauto(chunkDataPlayerData[ent].auto, serializerState); snapshot.SetPlayerDataautoSpawn(chunkDataPlayerData[ent].autoSpawn, serializerState); snapshot.SetPlayerDatadest(chunkDataPlayerData[ent].dest, serializerState); snapshot.SetPlayerDatadest2(chunkDataPlayerData[ent].dest2, serializerState); snapshot.SetPlayerDatakilledBy(chunkDataPlayerData[ent].killedBy, serializerState); snapshot.SetPlayerDatakilledByID(chunkDataPlayerData[ent].killedByID, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
public void SetGhostTypeIndexValue(int val, GhostSerializerState serializerState) { GhostTypeIndexValue = (int)val; }
public void SetMovablePlayerComponentPlayerId(int val, GhostSerializerState serializerState) { MovablePlayerComponentPlayerId = (int)val; }
public void SetPlayerIdComponentDataPlayerId(int val, GhostSerializerState serializerState) { PlayerIdComponentDataPlayerId = (int)val; }
public unsafe void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex, DynamicComponentTypeHandle *ghostChunkComponentTypesPtr, int ghostChunkComponentTypesLength) { var prefabList = ghostPrefabBufferFromEntity[prefabEntity]; var entityList = chunk.GetNativeArray(entityType); var snapshotDataList = chunk.GetNativeArray(snapshotDataType); var snapshotDataBufferList = chunk.GetBufferAccessor(snapshotDataBufferType); var ghostTypeComponent = ghostTypeFromEntity[entityList[0]]; int ghostType; for (ghostType = 0; ghostType < prefabList.Length; ++ghostType) { if (ghostTypeFromEntity[prefabList[ghostType].Value] == ghostTypeComponent) { break; } } if (ghostType >= prefabList.Length) { throw new System.InvalidOperationException("Could not find ghost type in the collection"); } var spawnList = spawnListFromEntity[spawnListEntity]; var typeData = GhostTypeCollection[ghostType]; var snapshotSize = typeData.SnapshotSize; int changeMaskUints = GhostCollectionSystem.ChangeMaskArraySizeInUInts(typeData.ChangeMaskBits); var snapshotBaseOffset = GhostCollectionSystem.SnapshotSizeAligned(4 + changeMaskUints * 4); var serializerState = new GhostSerializerState { GhostFromEntity = ghostFromEntity }; for (int i = 0; i < entityList.Length; ++i) { var entity = entityList[i]; var ghostComponent = ghostFromEntity[entity]; ghostComponent.ghostType = ghostType; ghostFromEntity[entity] = ghostComponent; // Set initial snapshot data // Get the buffers, fill in snapshot size etc snapshotDataList[i] = new SnapshotData { SnapshotSize = snapshotSize, LatestIndex = 0 }; var snapshotDataBuffer = snapshotDataBufferList[i]; snapshotDataBuffer.ResizeUninitialized(snapshotSize * GhostSystemConstants.SnapshotHistorySize); var snapshotPtr = (byte *)snapshotDataBuffer.GetUnsafePtr(); UnsafeUtility.MemClear(snapshotPtr, snapshotSize * GhostSystemConstants.SnapshotHistorySize); *(uint *)snapshotPtr = spawnTick; var snapshotOffset = snapshotBaseOffset; int numBaseComponents = typeData.NumComponents - typeData.NumChildComponents; for (int comp = 0; comp < numBaseComponents; ++comp) { int compIdx = GhostComponentIndex[typeData.FirstComponent + comp].ComponentIndex; #if ENABLE_UNITY_COLLECTIONS_CHECKS if (compIdx >= ghostChunkComponentTypesLength) { throw new InvalidOperationException("Component index out of range"); } #endif if (chunk.Has(ghostChunkComponentTypesPtr[compIdx])) { var compSize = GhostComponentCollection[compIdx].ComponentSize; var compData = (byte *)chunk.GetDynamicComponentDataArrayReinterpret <byte>(ghostChunkComponentTypesPtr[compIdx], compSize).GetUnsafeReadOnlyPtr(); compData += i * compSize; GhostComponentCollection[compIdx].CopyToSnapshot.Ptr.Invoke((IntPtr)UnsafeUtility.AddressOf(ref serializerState), (IntPtr)snapshotPtr, snapshotOffset, snapshotSize, (IntPtr)compData, compSize, 1); } else { var componentSnapshotSize = GhostCollectionSystem.SnapshotSizeAligned(GhostComponentCollection[compIdx].SnapshotSize); UnsafeUtility.MemClear(snapshotPtr + snapshotOffset, componentSnapshotSize); } snapshotOffset += GhostCollectionSystem.SnapshotSizeAligned(GhostComponentCollection[compIdx].SnapshotSize); } if (typeData.NumChildComponents > 0) { var linkedEntityGroupAccessor = chunk.GetBufferAccessor(linkedEntityGroupType); for (int comp = numBaseComponents; comp < typeData.NumComponents; ++comp) { int compIdx = GhostComponentIndex[typeData.FirstComponent + comp].ComponentIndex; #if ENABLE_UNITY_COLLECTIONS_CHECKS if (compIdx >= ghostChunkComponentTypesLength) { throw new InvalidOperationException("Component index out of range"); } #endif var compSize = GhostComponentCollection[compIdx].ComponentSize; var linkedEntityGroup = linkedEntityGroupAccessor[i]; var childEnt = linkedEntityGroup[GhostComponentIndex[typeData.FirstComponent + comp].EntityIndex].Value; //We can skip here, becase the memory buffer offset is computed using the start-end entity indices if (!childEntityLookup.TryGetValue(childEnt, out var childChunk) || !childChunk.chunk.Has(ghostChunkComponentTypesPtr[compIdx])) { var componentSnapshotSize = GhostCollectionSystem.SnapshotSizeAligned(GhostComponentCollection[compIdx].SnapshotSize); UnsafeUtility.MemClear(snapshotPtr + snapshotOffset, componentSnapshotSize); } else { var compData = (byte *)childChunk.chunk.GetDynamicComponentDataArrayReinterpret <byte>(ghostChunkComponentTypesPtr[compIdx], compSize).GetUnsafeReadOnlyPtr(); compData += childChunk.index * compSize; GhostComponentCollection[compIdx].CopyToSnapshot.Ptr.Invoke((IntPtr)UnsafeUtility.AddressOf(ref serializerState), (IntPtr)snapshotPtr, snapshotOffset, snapshotSize, (IntPtr)compData, compSize, 1); } snapshotOffset += GhostCollectionSystem.SnapshotSizeAligned(GhostComponentCollection[compIdx].SnapshotSize); } } // Remove request component commandBuffer.RemoveComponent <PredictedGhostSpawnRequestComponent>(entity); // Add to list of predictive spawn component - maybe use a singleton for this so spawn systems can just access it too spawnList.Add(new PredictedGhostSpawn { entity = entity, ghostType = ghostType, spawnTick = spawnTick }); } }
public void Set__GHOST_FIELD_NAME__(__GHOST_FIELD_TYPE_NAME__ val, GhostSerializerState serializerState) { __GHOST_FIELD_NAME__ = (uint)val; }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref MissileSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataActiveComponent = chunk.GetNativeArray(ghostActiveComponentType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetActiveComponentIsActive(chunkDataActiveComponent[ent].IsActive, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref ShipSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataPlayerIdComponentData = chunk.GetNativeArray(ghostPlayerIdComponentDataType); var chunkDataShipStateComponentData = chunk.GetNativeArray(ghostShipStateComponentDataType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); var chunkDataVelocity = chunk.GetNativeArray(ghostVelocityType); snapshot.SetPlayerIdComponentDataPlayerId(chunkDataPlayerIdComponentData[ent].PlayerId, serializerState); snapshot.SetShipStateComponentDataState(chunkDataShipStateComponentData[ent].State, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); snapshot.SetVelocityValue(chunkDataVelocity[ent].Value, serializerState); }
public void SetActiveComponentIsActive(bool val, GhostSerializerState serializerState) { ActiveComponentIsActive = val?1u:0; }
public void SetTranslationValue(float3 val, GhostSerializerState serializerState) { SetTranslationValue(val); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref BCivilianSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataHealth = chunk.GetNativeArray(ghostHealthType); var chunkDataPlayerUnit = chunk.GetNativeArray(ghostPlayerUnitType); var chunkDataUnitSelectionState = chunk.GetNativeArray(ghostUnitSelectionStateType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); var chunkDataLinkedEntityGroup = chunk.GetBufferAccessor(ghostLinkedEntityGroupType); snapshot.SetHealthValue(chunkDataHealth[ent].Value, serializerState); snapshot.SetPlayerUnitPlayerId(chunkDataPlayerUnit[ent].PlayerId, serializerState); snapshot.SetPlayerUnitUnitId(chunkDataPlayerUnit[ent].UnitId, serializerState); snapshot.SetUnitSelectionStateIsSelected(chunkDataUnitSelectionState[ent].IsSelected, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); snapshot.SetChild0RotationValue(ghostChild0RotationType[chunkDataLinkedEntityGroup[ent][1].Value].Value, serializerState); snapshot.SetChild0TranslationValue(ghostChild0TranslationType[chunkDataLinkedEntityGroup[ent][1].Value].Value, serializerState); snapshot.SetChild1RotationValue(ghostChild1RotationType[chunkDataLinkedEntityGroup[ent][2].Value].Value, serializerState); snapshot.SetChild1TranslationValue(ghostChild1TranslationType[chunkDataLinkedEntityGroup[ent][2].Value].Value, serializerState); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref GameModeSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataGameModeData = chunk.GetNativeArray(ghostGameModeDataType); snapshot.SetGameModeDatagameTimerSeconds(chunkDataGameModeData[ent].gameTimerSeconds, serializerState); snapshot.SetGameModeDatagameTimerMessage(chunkDataGameModeData[ent].gameTimerMessage, serializerState); snapshot.SetGameModeDatateamName0(chunkDataGameModeData[ent].teamName0, serializerState); snapshot.SetGameModeDatateamName1(chunkDataGameModeData[ent].teamName1, serializerState); snapshot.SetGameModeDatateamScore0(chunkDataGameModeData[ent].teamScore0, serializerState); snapshot.SetGameModeDatateamScore1(chunkDataGameModeData[ent].teamScore1, serializerState); }
public void SetPaddleMoveableComponentPlayerId(int val, GhostSerializerState serializerState) { PaddleMoveableComponentPlayerId = (int)val; }
public void Set__GHOST_FIELD_NAME__(float val, GhostSerializerState serializerState) { __GHOST_FIELD_NAME__ = val; }
public void SetRotationValue(quaternion q, GhostSerializerState serializerState) { SetRotationValue(q); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref PaddleOtherSideSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataPaddleMoveableComponent = chunk.GetNativeArray(ghostPaddleMoveableComponentType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetPaddleMoveableComponentPlayerId(chunkDataPaddleMoveableComponent[ent].PlayerId, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref ProjectileSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataLifeTimeComponent = chunk.GetNativeArray(ghostLifeTimeComponentType); var chunkDataSpeedComponent = chunk.GetNativeArray(ghostSpeedComponentType); var chunkDataRotation = chunk.GetNativeArray(ghostRotationType); var chunkDataTranslation = chunk.GetNativeArray(ghostTranslationType); snapshot.SetLifeTimeComponentValue(chunkDataLifeTimeComponent[ent].Value, serializerState); snapshot.SetSpeedComponentValue(chunkDataSpeedComponent[ent].Value, serializerState); snapshot.SetRotationValue(chunkDataRotation[ent].Value, serializerState); snapshot.SetTranslationValue(chunkDataTranslation[ent].Value, serializerState); }
public void CopyToSnapshot(ArchetypeChunk chunk, int ent, uint tick, ref PlayerStateSnapshotData snapshot, GhostSerializerState serializerState) { snapshot.tick = tick; var chunkDataPlayerState = chunk.GetNativeArray(ghostPlayerStateType); snapshot.SetPlayerStateplayerId(chunkDataPlayerState[ent].playerId, serializerState); snapshot.SetPlayerStategameModeSystemInitialized(chunkDataPlayerState[ent].gameModeSystemInitialized, serializerState); }
public void Set__GHOST_FIELD_NAME__(float4 val, GhostSerializerState serializerState) { Set__GHOST_FIELD_NAME__(val); }
public void Set__GHOST_FIELD_NAME__(bool val, GhostSerializerState serializerState) { __GHOST_FIELD_NAME__ = val?1u:0; }