public override void OnComponentUpdate(ComponentUpdateOp op) { if (!IsValidEntityId(op.EntityId, "OnComponentUpdate", out var entity)) { return; } if (entityManager.HasComponent <NotAuthoritative <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component> >(entity)) { var data = entityManager.GetComponentData <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component>(entity); var update = Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Serialization.GetAndApplyUpdate(op.Update.SchemaData.Value.GetFields(), ref data); List <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Update> updates; if (entityManager.HasComponent <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.ReceivedUpdates>(entity)) { updates = entityManager.GetComponentData <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.ReceivedUpdates>(entity).Updates; } else { var updatesComponent = new Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.ReceivedUpdates { handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World) }; ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, new List <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Update>()); updates = updatesComponent.Updates; entityManager.AddComponentData(entity, updatesComponent); } updates.Add(update); data.DirtyBit = false; entityManager.SetComponentData(entity, data); } }
public override void OnAddComponent(AddComponentOp op) { if (!IsValidEntityId(op.EntityId, "AddComponentOp", out var entity)) { return; } var data = Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Serialization.Deserialize(op.Data.SchemaData.Value.GetFields(), World); data.DirtyBit = false; entityManager.AddComponentData(entity, data); entityManager.AddComponentData(entity, new NotAuthoritative <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component>()); var update = new Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.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 <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Update> { update }; var updatesComponent = new Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.ReceivedUpdates { handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World) }; ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, updates); entityManager.AddComponentData(entity, updatesComponent); if (entityManager.HasComponent <ComponentRemoved <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component> >(entity)) { entityManager.RemoveComponent <ComponentRemoved <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component> >(entity); } else if (!entityManager.HasComponent <ComponentAdded <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component> >(entity)) { entityManager.AddComponentData(entity, new ComponentAdded <Generated.Improbable.Gdk.Tests.ExhaustiveRepeated.Component>()); } else { LogDispatcher.HandleLog(LogType.Error, new LogEvent(ReceivedDuplicateComponentAdded) .WithField(LoggingUtils.LoggerName, LoggerName) .WithField(LoggingUtils.EntityId, op.EntityId.Id) .WithField("Component", "Generated.Improbable.Gdk.Tests.ExhaustiveRepeated") ); } }