コード例 #1
0
            public override void OnComponentUpdate(ComponentUpdateOp op)
            {
                var entity = TryGetEntityFromEntityId(op.EntityId);

                if (entityManager.HasComponent <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >(entity))
                {
                    var data = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveSingular.Component>(entity);
                    Improbable.Gdk.Tests.ExhaustiveSingular.Serialization.ApplyUpdate(op.Update.SchemaData.Value, ref data);
                    data.DirtyBit = false;
                    entityManager.SetComponentData(entity, data);
                }

                var update = Improbable.Gdk.Tests.ExhaustiveSingular.Serialization.DeserializeUpdate(op.Update.SchemaData.Value);

                List <Improbable.Gdk.Tests.ExhaustiveSingular.Update> updates;

                if (entityManager.HasComponent <Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates>(entity))
                {
                    updates = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates>(entity).Updates;
                }
                else
                {
                    var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates
                    {
                        handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World)
                    };
                    ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, new List <Improbable.Gdk.Tests.ExhaustiveSingular.Update>());
                    updates = updatesComponent.Updates;
                    entityManager.AddComponentData(entity, updatesComponent);
                }

                updates.Add(update);
            }
コード例 #2
0
            public override void OnComponentUpdate(ComponentUpdateOp op)
            {
                var entity = TryGetEntityFromEntityId(new EntityId(op.EntityId));

                Profiler.BeginSample("ExhaustiveSingular");
                if (entityManager.HasComponent <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >(entity))
                {
                    var data = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveSingular.Component>(entity);
                    Improbable.Gdk.Tests.ExhaustiveSingular.Serialization.ApplyUpdate(op.Update.SchemaData.Value, ref data);
                    data.MarkDataClean();
                    entityManager.SetComponentData(entity, data);
                }

                var update = Improbable.Gdk.Tests.ExhaustiveSingular.Serialization.DeserializeUpdate(op.Update.SchemaData.Value);

                List <Improbable.Gdk.Tests.ExhaustiveSingular.Update> updates;

                if (entityManager.HasComponent <Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates>(entity))
                {
                    updates = entityManager.GetComponentData <Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates>(entity).Updates;
                }
                else
                {
                    updates = Improbable.Gdk.Tests.ExhaustiveSingular.Update.Pool.Count > 0 ? Improbable.Gdk.Tests.ExhaustiveSingular.Update.Pool.Pop() : new List <Improbable.Gdk.Tests.ExhaustiveSingular.Update>();
                    var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates
                    {
                        handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World)
                    };
                    ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, updates);
                    entityManager.AddComponentData(entity, updatesComponent);
                }

                updates.Add(update);

                Profiler.EndSample();
            }
コード例 #3
0
            public override void OnAddComponent(AddComponentOp op)
            {
                var entity = TryGetEntityFromEntityId(new EntityId(op.EntityId));

                Profiler.BeginSample("ExhaustiveSingular");
                var data = Improbable.Gdk.Tests.ExhaustiveSingular.Serialization.Deserialize(op.Data.SchemaData.Value.GetFields(), World);

                data.MarkDataClean();
                entityManager.AddComponentData(entity, data);
                entityManager.AddComponent(entity, ComponentType.Create <NotAuthoritative <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >());

                var update = new Improbable.Gdk.Tests.ExhaustiveSingular.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,
                    Field18 = data.Field18,
                };

                var updates = new List <Improbable.Gdk.Tests.ExhaustiveSingular.Update>
                {
                    update
                };

                var updatesComponent = new Improbable.Gdk.Tests.ExhaustiveSingular.ReceivedUpdates
                {
                    handle = ReferenceTypeProviders.UpdatesProvider.Allocate(World)
                };

                ReferenceTypeProviders.UpdatesProvider.Set(updatesComponent.handle, updates);
                entityManager.AddComponentData(entity, updatesComponent);

                if (entityManager.HasComponent <ComponentRemoved <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >(entity))
                {
                    entityManager.RemoveComponent <ComponentRemoved <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >(entity);
                }
                else if (!entityManager.HasComponent <ComponentAdded <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >(entity))
                {
                    entityManager.AddComponent(entity, ComponentType.Create <ComponentAdded <Improbable.Gdk.Tests.ExhaustiveSingular.Component> >());
                }
                else
                {
                    LogDispatcher.HandleLog(LogType.Error, new LogEvent(ReceivedDuplicateComponentAdded)
                                            .WithField(LoggingUtils.LoggerName, LoggerName)
                                            .WithField(LoggingUtils.EntityId, op.EntityId)
                                            .WithField("Component", "Improbable.Gdk.Tests.ExhaustiveSingular")
                                            );
                }

                Profiler.EndSample();
            }