public override void OnComponentUpdate(ComponentUpdateOp op) { var entity = TryGetEntityFromEntityId(op.EntityId); if (entityManager.HasComponent <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >(entity)) { var data = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity); Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.ApplyUpdate(op.Update.SchemaData.Value, ref data); data.DirtyBit = false; entityManager.SetComponentData(entity, data); } var update = Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.DeserializeUpdate(op.Update.SchemaData.Value); List <Improbable.Gdk.Tests.ExhaustiveMapKey.Update> updates; if (entityManager.HasComponent <Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity)) { updates = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity).Updates; } else { var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates { handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World) }; ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, new List <Improbable.Gdk.Tests.ExhaustiveMapKey.Update>()); updates = updatesComponent.Updates; entityManager.AddComponentData(entity, updatesComponent); } updates.Add(update); }
public override void OnComponentUpdate(ComponentUpdateOp op) { var entity = TryGetEntityFromEntityId(new EntityId(op.EntityId)); Profiler.BeginSample("ExhaustiveMapKey"); if (entityManager.HasComponent <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >(entity)) { var data = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity); Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.ApplyUpdate(op.Update.SchemaData.Value, ref data); data.MarkDataClean(); entityManager.SetComponentData(entity, data); } var update = Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.DeserializeUpdate(op.Update.SchemaData.Value); List <Improbable.Gdk.Tests.ExhaustiveMapKey.Update> updates; if (entityManager.HasComponent <Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity)) { updates = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity).Updates; } else { updates = Improbable.Gdk.Tests.ExhaustiveMapKey.Update.Pool.Count > 0 ? Improbable.Gdk.Tests.ExhaustiveMapKey.Update.Pool.Pop() : new List <Improbable.Gdk.Tests.ExhaustiveMapKey.Update>(); var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates { handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World) }; ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, updates); entityManager.AddComponentData(entity, updatesComponent); } updates.Add(update); Profiler.EndSample(); }
public override void OnAddComponent(AddComponentOp op) { var entity = TryGetEntityFromEntityId(op.EntityId); Profiler.BeginSample("ExhaustiveMapKey"); var data = Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.Deserialize(op.Data.SchemaData.Value.GetFields(), World); data.DirtyBit = false; entityManager.AddComponentData(entity, data); entityManager.AddComponent(entity, ComponentType.Create <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >()); var update = new Improbable.Gdk.Tests.ExhaustiveMapKey.Update { Field1 = data.Field1, Field2 = data.Field2, Field3 = data.Field3, Field4 = data.Field4, Field5 = data.Field5, Field6 = data.Field6, Field7 = data.Field7, Field8 = data.Field8, Field9 = data.Field9, Field10 = data.Field10, Field11 = data.Field11, Field12 = data.Field12, Field13 = data.Field13, Field14 = data.Field14, Field15 = data.Field15, Field16 = data.Field16, Field17 = data.Field17, }; var updates = new List <Improbable.Gdk.Tests.ExhaustiveMapKey.Update> { update }; var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates { handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World) }; ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, updates); entityManager.AddComponentData(entity, updatesComponent); if (entityManager.HasComponent <ComponentRemoved <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >(entity)) { entityManager.RemoveComponent <ComponentRemoved <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >(entity); } else if (!entityManager.HasComponent <ComponentAdded <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >(entity)) { entityManager.AddComponent(entity, ComponentType.Create <ComponentAdded <Improbable.Gdk.Tests.ExhaustiveMapKey.Component> >()); } else { LogDispatcher.HandleLog(LogType.Error, new LogEvent(ReceivedDuplicateComponentAdded) .WithField(LoggingUtils.LoggerName, LoggerName) .WithField(LoggingUtils.EntityId, op.EntityId.Id) .WithField("Component", "Improbable.Gdk.Tests.ExhaustiveMapKey") ); } Profiler.EndSample(); }