public override void ExecuteReplication(Connection connection) { var componentDataArray = ReplicationComponentGroup.GetComponentArray <SpatialOSNonBlittableComponent>(); var spatialEntityIdData = ReplicationComponentGroup.GetComponentDataArray <SpatialEntityId>(); for (var i = 0; i < componentDataArray.Length; i++) { var componentData = componentDataArray[i]; var entityId = spatialEntityIdData[i].EntityId; var hasPendingEvents = false; var firstEventEvents = EntityIdToFirstEventEvents[entityId]; hasPendingEvents |= firstEventEvents.Count() > 0; var secondEventEvents = EntityIdToSecondEventEvents[entityId]; hasPendingEvents |= secondEventEvents.Count() > 0; if (componentData.DirtyBit || hasPendingEvents) { var update = new global::Improbable.Gdk.Tests.NonblittableTypes.NonBlittableComponent.Update(); update.SetBoolField(componentData.BoolField); update.SetIntField(componentData.IntField); update.SetLongField(componentData.LongField); update.SetFloatField(componentData.FloatField); update.SetDoubleField(componentData.DoubleField); update.SetStringField(componentData.StringField); update.SetOptionalField(componentData.OptionalField.HasValue ? new global::Improbable.Collections.Option <int>(componentData.OptionalField.Value) : new global::Improbable.Collections.Option <int>()); update.SetListField(new global::Improbable.Collections.List <int>(componentData.ListField)); update.SetMapField(new global::Improbable.Collections.Map <int, string>(componentData.MapField.ToDictionary(entry => entry.Key, entry => entry.Value))); foreach (var nativeEvent in firstEventEvents) { var spatialEvent = global::Generated.Improbable.Gdk.Tests.NonblittableTypes.FirstEventPayload.ToSpatial(nativeEvent); update.firstEvent.Add(spatialEvent); } foreach (var nativeEvent in secondEventEvents) { var spatialEvent = global::Generated.Improbable.Gdk.Tests.NonblittableTypes.SecondEventPayload.ToSpatial(nativeEvent); update.secondEvent.Add(spatialEvent); } SendComponentUpdate(connection, entityId, update); componentData.DirtyBit = false; view.SetComponentObject(entityId, componentData); firstEventEvents.Clear(); secondEventEvents.Clear(); } } }
public static void SendComponentUpdate(Connection connection, long entityId, global::Improbable.Gdk.Tests.NonblittableTypes.NonBlittableComponent.Update update) { connection.SendComponentUpdate(new global::Improbable.EntityId(entityId), update); }