public uint Read(ref Player data, IInBitStream bitstream) { var propertyMask = (uint)0; return(propertyMask); }
public void GenericCommand(IInBitStream bitstream, ref GenericCommand data) { var name = bitstream.ReadShortString(); data.name = coherenceToUnityConverters.ToUnityFixedString64(name); data.paramInt1 = bitstream.ReadIntegerRange(15, -9999); data.paramInt2 = bitstream.ReadIntegerRange(15, -9999); data.paramInt3 = bitstream.ReadIntegerRange(15, -9999); data.paramInt4 = bitstream.ReadIntegerRange(15, -9999); var paramFloat1 = bitstream.ReadFixedPoint(24, 2400); data.paramFloat1 = coherenceToUnityConverters.ToUnityfloat(paramFloat1); var paramFloat2 = bitstream.ReadFixedPoint(24, 2400); data.paramFloat2 = coherenceToUnityConverters.ToUnityfloat(paramFloat2); var paramFloat3 = bitstream.ReadFixedPoint(24, 2400); data.paramFloat3 = coherenceToUnityConverters.ToUnityfloat(paramFloat3); var paramFloat4 = bitstream.ReadFixedPoint(24, 2400); data.paramFloat4 = coherenceToUnityConverters.ToUnityfloat(paramFloat4); data.paramBool1 = bitstream.ReadBool(); data.paramBool2 = bitstream.ReadBool(); data.paramBool3 = bitstream.ReadBool(); data.paramBool4 = bitstream.ReadBool(); data.paramEntity1 = bitstream.ReadEntity(); data.paramEntity2 = bitstream.ReadEntity(); data.paramEntity3 = bitstream.ReadEntity(); data.paramEntity4 = bitstream.ReadEntity(); var paramString = bitstream.ReadShortString(); data.paramString = coherenceToUnityConverters.ToUnityFixedString64(paramString); }
public void TransferAction(IInBitStream bitstream, ref TransferAction data) { data.participant = bitstream.ReadIntegerRange(15, -9999); data.accepted = bitstream.ReadBool(); }
public void WorldPositionQuery(IInBitStream bitstream, ref WorldPositionQuery data) { var position = bitstream.ReadVector3f(24, 2400); data.position = coherenceToUnityConverters.ToUnityfloat3(position); var radius = bitstream.ReadFixedPoint(24, 2400); data.radius = coherenceToUnityConverters.ToUnityfloat(radius); }
public void Persistence(IInBitStream bitstream, ref Persistence data) { var uuid = bitstream.ReadShortString(); data.uuid = coherenceToUnityConverters.ToUnityFixedString64(uuid); var expiry = bitstream.ReadShortString(); data.expiry = coherenceToUnityConverters.ToUnityFixedString64(expiry); }
public uint Read(ref GenericFieldVector3 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadVector3f(24, 2400); data.Value = coherenceToUnityConverters.ToUnityfloat3(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref LocalUser data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadIntegerRange(15, -9999); data.localIndex = coherenceField; propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldInt9 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadIntegerRange(15, -9999); data.number = coherenceField; propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldBool9 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadBool(); data.number = coherenceField; propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldString4 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadShortString(); data.name = coherenceToUnityConverters.ToUnityFixedString64(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref ArchetypeComponent data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadIntegerRange(15, -9999); data.index = coherenceField; propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldEntity9 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadEntity(); data.Value = coherenceField; propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldFloat9 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadFixedPoint(24, 2400); data.number = coherenceToUnityConverters.ToUnityfloat(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public uint Read(ref GenericFieldQuaternion0 data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadUnitRotation(); data.Value = coherenceToUnityConverters.ToUnityquaternion(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } return(propertyMask); }
public void WriteFromStream(IInBitStream inBitStream, int bitCount) { const int ChunkBitSize = AccumulatorSize; var restBitCount = bitCount % ChunkBitSize; var chunkCount = bitCount / ChunkBitSize; for (var i = 0; i < chunkCount; ++i) { var data = inBitStream.ReadRawBits(ChunkBitSize); WriteRawBits(data, ChunkBitSize); } if (restBitCount > 0) { var restData = inBitStream.ReadRawBits(restBitCount); WriteRawBits(restData, restBitCount); } }
public uint Read(ref Persistence data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadShortString(); data.uuid = coherenceToUnityConverters.ToUnityFixedString64(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadShortString(); data.expiry = coherenceToUnityConverters.ToUnityFixedString64(coherenceField); propertyMask |= 0b00000000000000000000000000000010; } return(propertyMask); }
public uint Read(ref WorldPositionQuery data, IInBitStream bitstream) { var propertyMask = (uint)0; if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadVector3f(24, 2400); data.position = coherenceToUnityConverters.ToUnityfloat3(coherenceField); propertyMask |= 0b00000000000000000000000000000001; } if (bitstream.ReadMask()) { var coherenceField = bitstream.ReadFixedPoint(24, 2400); data.radius = coherenceToUnityConverters.ToUnityfloat(coherenceField); propertyMask |= 0b00000000000000000000000000000010; } return(propertyMask); }
public void ArchetypeComponent(IInBitStream bitstream, ref ArchetypeComponent data) { data.index = bitstream.ReadIntegerRange(15, -9999); }
private void DeserializeLocalUser(EntityManager entityManager, Entity entity, bool componentOwnership, AbsoluteSimulationFrame simulationFrame, Coherence.Replication.Protocol.Definition.IInBitStream protocolStream, bool justCreated, IInBitStream bitStream) { // If we own the entity, don't overwrite with downstream data from server // TODO: Server should never send downstream to the simulating client if (componentOwnership) { // Read and discard data (the stream must always be read) var temp = new LocalUser(); unityReaders.Read(ref temp, protocolStream); return; } // Overwrite components that don't use interpolation var componentData = entityManager.GetComponentData <LocalUser>(entity); unityReaders.Read(ref componentData, protocolStream); entityManager.SetComponentData(entity, componentData); }
private void DeserializeWorldOrientation(EntityManager entityManager, Entity entity, bool componentOwnership, AbsoluteSimulationFrame simulationFrame, Coherence.Replication.Protocol.Definition.IInBitStream protocolStream, bool justCreated, IInBitStream bitStream) { // If we own the entity, don't overwrite with downstream data from server // TODO: Server should never send downstream to the simulating client if (componentOwnership) { // Read and discard data (the stream must always be read) var temp = new Rotation(); unityReaders.Read(ref temp, protocolStream); return; } // Ensure entities with interpolation also have Interpolation components and Sample components if (!entityManager.HasComponent <InterpolationComponent_Rotation>(entity)) { entityManager.AddComponent <InterpolationComponent_Rotation>(entity); entityManager.AddComponent <Sample_Rotation>(entity); } // Append buffer for components that use interpolation var tempComponentData = new Rotation(); unityReaders.Read(ref tempComponentData, protocolStream); if (justCreated) // Hack { entityManager.SetComponentData(entity, tempComponentData); } InterpolationSystem_Rotation.AppendBuffer(entity, tempComponentData, entityManager.World, (ulong)simulationFrame.Frame); }
public void ReadComponentDataUpdate(EntityManager entityManager, Entity entity, uint componentType, AbsoluteSimulationFrame simulationFrame, IInBitStream bitStream) { deserializeComponentUpdateGenerated.ReadComponentDataUpdate(entityManager, entity, componentType, simulationFrame, bitStream); }
public void CreateIfNeededAndReadComponentDataUpdate(EntityManager entityManager, Entity entity, uint componentType, AbsoluteSimulationFrame simulationFrame, IInBitStream bitStream) { #region Commands { var hasBuffer = entityManager.HasComponent <AuthorityTransfer>(entity); if (!hasBuffer) { entityManager.AddBuffer <AuthorityTransfer>(entity); } var hasRequestBuffer = entityManager.HasComponent <AuthorityTransferRequest>(entity); if (!hasRequestBuffer) { entityManager.AddBuffer <AuthorityTransferRequest>(entity); } } #endregion switch (componentType) { case TypeIds.InternalWorldPosition: { var justCreated = false; var hasComponentData = entityManager.HasComponent <Translation>(entity); var componentHasBeenRemoved = entityManager.HasComponent <WorldPosition_Sync>(entity) && entityManager.GetComponentData <WorldPosition_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new Translation()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalWorldOrientation: { var justCreated = false; var hasComponentData = entityManager.HasComponent <Rotation>(entity); var componentHasBeenRemoved = entityManager.HasComponent <WorldOrientation_Sync>(entity) && entityManager.GetComponentData <WorldOrientation_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new Rotation()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalLocalUser: { var justCreated = false; var hasComponentData = entityManager.HasComponent <LocalUser>(entity); var componentHasBeenRemoved = entityManager.HasComponent <LocalUser_Sync>(entity) && entityManager.GetComponentData <LocalUser_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new LocalUser()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalWorldPositionQuery: { var justCreated = false; var hasComponentData = entityManager.HasComponent <WorldPositionQuery>(entity); var componentHasBeenRemoved = entityManager.HasComponent <WorldPositionQuery_Sync>(entity) && entityManager.GetComponentData <WorldPositionQuery_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new WorldPositionQuery()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalArchetypeComponent: { var justCreated = false; var hasComponentData = entityManager.HasComponent <ArchetypeComponent>(entity); var componentHasBeenRemoved = entityManager.HasComponent <ArchetypeComponent_Sync>(entity) && entityManager.GetComponentData <ArchetypeComponent_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new ArchetypeComponent()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalPersistence: { var justCreated = false; var hasComponentData = entityManager.HasComponent <Persistence>(entity); var componentHasBeenRemoved = entityManager.HasComponent <Persistence_Sync>(entity) && entityManager.GetComponentData <Persistence_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new Persistence()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } case TypeIds.InternalPlayer: { var justCreated = false; var hasComponentData = entityManager.HasComponent <Player>(entity); var componentHasBeenRemoved = entityManager.HasComponent <Player_Sync>(entity) && entityManager.GetComponentData <Player_Sync>(entity).deletedAtTime > 0; if (!hasComponentData && !componentHasBeenRemoved) { entityManager.AddComponentData(entity, new Player()); justCreated = true; } ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, justCreated); break; } default: { Log.Warning("can not create component type"); break; } } }
public void ReadComponentDataUpdateEx(EntityManager entityManager, Entity entity, uint componentType, AbsoluteSimulationFrame simulationFrame, IInBitStream bitStream, bool justCreated) { var componentOwnership = Deserializator.ReadComponentOwnership(bitStream); // Read bit from stream... componentOwnership = entityManager.HasComponent <Simulated>(entity); // Then overwrite it with entity ownership. var inProtocolStream = new Coherence.FieldStream.Deserialize.Streams.InBitStream(bitStream); switch (componentType) { case TypeIds.InternalWorldPosition: DeserializeWorldPosition(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalWorldOrientation: DeserializeWorldOrientation(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalLocalUser: DeserializeLocalUser(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalWorldPositionQuery: DeserializeWorldPositionQuery(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalArchetypeComponent: DeserializeArchetypeComponent(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalPersistence: DeserializePersistence(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; case TypeIds.InternalPlayer: DeserializePlayer(entityManager, entity, componentOwnership, simulationFrame, inProtocolStream, justCreated, bitStream); break; default: Log.Warning("couldn't find component", "componentType", componentType); break; } }
public void ReadComponentDataUpdate(EntityManager entityManager, Entity entity, uint componentType, AbsoluteSimulationFrame simulationFrame, IInBitStream bitStream) { ReadComponentDataUpdateEx(entityManager, entity, componentType, simulationFrame, bitStream, false); }
private void DeserializePlayer(EntityManager entityManager, Entity entity, bool componentOwnership, AbsoluteSimulationFrame simulationFrame, Coherence.Replication.Protocol.Definition.IInBitStream protocolStream, bool justCreated, IInBitStream bitStream) { // No need to read empty components, just ensure that it's there if (!entityManager.HasComponent <Player>(entity)) { entityManager.AddComponent <Player>(entity); } }
public DebugInBitStream(ILog log, IInBitStream bitStream) { this.log = log; this.bitStream = bitStream; }
public void AuthorityTransfer(IInBitStream bitstream, ref AuthorityTransfer data) { data.participant = bitstream.ReadIntegerRange(15, -9999); }
public void LocalUser(IInBitStream bitstream, ref LocalUser data) { data.localIndex = bitstream.ReadIntegerRange(15, -9999); }
public void Player(IInBitStream bitstream, ref Player data) { }
public void Rotation(IInBitStream bitstream, ref Rotation data) { var value = bitstream.ReadUnitRotation(); data.Value = coherenceToUnityConverters.ToUnityquaternion(value); }