internal SyncHandle(SynchronisableEntity syncEntity, object obj, ushort entityID) { Sync = syncEntity; Obj = obj; // This is cheaper than GetValue(), as it doesnt flush field data. State = SyncState.Live; EntityID = entityID; }
private void SpawnEntity(ushort entityID, ushort typeID, uint revision) { SynchronisableEntity entity = EntityGenerator.GetEntityFactory(typeID).ConstructNewEntity(revision); SyncHandle handle = new SyncHandle(entity, entity.GetValue(), entityID); newHandles.Add(handle); AddHandle(handle); }
internal void UnpackEventDatagram(PoolEventPayload payload) { ushort typeID = payload.EventData.ReadUShort(); SynchronisableEntity entity = EntityGenerator.GetEntityFactory(typeID).ConstructNewEntity(0); entity.ReadFromBuffer(payload.EventData, Context); RecievedEvents.Add(new SyncEvent(entity, entity.GetValue())); }
public SyncHandle AddEntity(object instance) { ushort entityID = GetNextEntityID(); RuntimeTypeHandle typeHandle = instance.GetType().TypeHandle; SynchronisableEntity entity = EntityGenerator.GetEntityFactory(typeHandle).ConstructForExisting(instance); SyncHandle handle = new SyncHandle(entity, instance, entityID); AddHandle(handle); return(handle); }
public void AddEvent(object instance, bool guaranteeReceipt = true, bool urgent = true) { SynchronisableEntity entity = EntityGenerator.GetEntityFactory(instance.GetType().TypeHandle).ConstructForExisting(instance); entity.TrackChanges(instance, Context); int size = entity.WriteToBufferSize() + sizeof(ushort); PoolEventPayload payload = PoolEventPayload.Generate(PoolID, size, guaranteeReceipt, urgent); payload.EventData.WriteUShort(entity.TypeID); entity.WriteToBuffer(payload.EventData); BroadcastPayload(payload); }
internal SyncEvent(SynchronisableEntity sync, object obj) { Obj = obj; Sync = sync; State = sync.ReferencesPending ? SyncState.PendingReferences : SyncState.Ready; }