Exemplo n.º 1
0
            private void OnCmdRequest(CommandRequestOp op)
            {
                if (!IsValidEntityId(op.EntityId, "CommandRequestOp", out var entity))
                {
                    return;
                }

                var deserializedRequest = global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Deserialize(op.Request.SchemaData.Value.GetObject());

                List <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedRequest> requests;

                if (entityManager.HasComponent <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandRequests.Cmd>(entity))
                {
                    requests = entityManager.GetComponentData <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandRequests.Cmd>(entity).Requests;
                }
                else
                {
                    var data = new Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandRequests.Cmd
                    {
                        CommandListHandle = Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.ReferenceTypeProviders.CmdRequestsProvider.Allocate(World)
                    };
                    requests = data.Requests = new List <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedRequest>();
                    entityManager.AddComponentData(entity, data);
                }

                requests.Add(new Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedRequest(op.RequestId.Id,
                                                                                                                                             op.CallerWorkerId,
                                                                                                                                             op.CallerAttributeSet,
                                                                                                                                             deserializedRequest));
            }
Exemplo n.º 2
0
            public override void OnCommandRequest(CommandRequestOp op)
            {
                if (!IsValidEntityId(op.EntityId, "CommandRequestOp", out var entity))
                {
                    return;
                }

                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                switch (commandIndex)
                {
                case 1:
                    OnCmdRequest(op);
                    break;

                default:
                    LogDispatcher.HandleLog(LogType.Error, new LogEvent(CommandIndexNotFound)
                                            .WithField(LoggingUtils.LoggerName, LoggerName)
                                            .WithField(LoggingUtils.EntityId, op.EntityId.Id)
                                            .WithField("CommandIndex", commandIndex)
                                            .WithField("Component", "Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands")
                                            );
                    break;
                }
            }
            public override void OnCommandRequest(CommandRequestOp op)
            {
                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                switch (commandIndex)
                {
                default:
                    throw new UnknownCommandIndexException(commandIndex, "ExhaustiveOptional");
                }
            }
            public override void OnCommandRequest(CommandRequestOp op)
            {
                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                switch (commandIndex)
                {
                default:
                    throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFieldsWithEvents");
                }
            }
Exemplo n.º 5
0
        internal void OnCommandRequest(CommandRequestOp op)
        {
            if (!componentSpecificDispatchers.TryGetValue(op.Request.ComponentId, out var specificDispatcher))
            {
                throw new UnknownComponentIdException(
                          string.Format(Errors.UnknownComponentIdError, op.GetType(), op.Request.ComponentId));
            }

            specificDispatcher.OnCommandRequest(op);
        }
Exemplo n.º 6
0
        public static WrappedOp <CommandRequestOp> CreateCommandRequestOp(uint componentId, uint commandIndex, long requestId)
        {
            var schemaRequest = new SchemaCommandRequest(componentId, commandIndex);
            var op            = new CommandRequestOp
            {
                Request   = new CommandRequest(schemaRequest),
                RequestId = new RequestId <IncomingCommandRequest>(requestId)
            };

            return(new WrappedOp <CommandRequestOp>(op));
        }
Exemplo n.º 7
0
        private void OnCommandRequest(CommandRequestOp op)
        {
            if (!componentSpecificDispatchers.TryGetValue(op.Request.ComponentId, out var specificDispatcher))
            {
                worker.LogDispatcher.HandleLog(LogType.Error,
                                               new LogEvent(UnknownComponentIdError).WithField("Op Type", op.GetType())
                                               .WithField("ComponentId", op.Request.ComponentId));
                return;
            }

            specificDispatcher.OnCommandRequest(op);
        }
            public void AddRequestToDiff(CommandRequestOp op, ViewDiff diff)
            {
                var deserializedRequest = global::Improbable.Restricted.DisconnectRequest.Serialization.Deserialize(op.Request.SchemaData.Value.GetObject());

                var request = new Disconnect.ReceivedRequest(
                    new EntityId(op.EntityId),
                    op.RequestId,
                    op.CallerWorkerId,
                    op.CallerAttributeSet,
                    deserializedRequest);

                diff.AddCommandRequest(request, ComponentId, 1);
            }
            public void AddRequestToDiff(CommandRequestOp op, ViewDiff diff)
            {
                var deserializedRequest = global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Deserialize(op.Request.SchemaData.Value.GetObject());

                var request = new Cmd.ReceivedRequest(
                    new EntityId(op.EntityId),
                    op.RequestId,
                    op.CallerWorkerId,
                    op.CallerAttributeSet,
                    deserializedRequest);

                diff.AddCommandRequest(request, ComponentId, 1);
            }
Exemplo n.º 10
0
            public override void OnCommandRequest(CommandRequestOp op)
            {
                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                Profiler.BeginSample("ComponentWithNoFieldsWithCommands");
                switch (commandIndex)
                {
                case 1:
                    OnCmdRequest(op);
                    break;

                default:
                    throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFieldsWithCommands");
                }

                Profiler.EndSample();
            }
            public void OnCommandRequestSecondCommand(CommandRequestOp <global::Improbable.Gdk.Tests.BlittableTypes.BlittableComponent.Commands.SecondCommand> op)
            {
                Unity.Entities.Entity entity;
                if (!view.TryGetEntity(op.EntityId.Id, out entity))
                {
                    LogDispatcher.HandleLog(LogType.Error, new LogEvent("Entity not found during OnCommandRequest.")
                                            .WithField(LoggingUtils.LoggerName, LoggerName)
                                            .WithField(LoggingUtils.EntityId, op.EntityId.Id)
                                            .WithField(MutableView.Component, "SpatialOSBlittableComponent"));
                    return;
                }

                var requestPayload      = op.Request.Get().Value;
                var unityRequestPayload = global::Generated.Improbable.Gdk.Tests.BlittableTypes.SecondCommandRequest.ToNative(requestPayload);
                var request             = new SecondCommand.Request(op.RequestId.Id, this, op.CallerWorkerId, op.CallerAttributeSet, unityRequestPayload);

                view.AddCommandRequest(entity, request, SecondCommandRequestPool);
            }
            public override void OnCommandRequest(CommandRequestOp op)
            {
                if (!IsValidEntityId(op.EntityId, "CommandRequestOp", out var entity))
                {
                    return;
                }

                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                switch (commandIndex)
                {
                default:
                    LogDispatcher.HandleLog(LogType.Error, new LogEvent(CommandIndexNotFound)
                                            .WithField(LoggingUtils.LoggerName, LoggerName)
                                            .WithField(LoggingUtils.EntityId, op.EntityId.Id)
                                            .WithField("CommandIndex", commandIndex)
                                            .WithField("Component", "SpatialOSExhaustiveSingular")
                                            );
                    break;
                }
            }
Exemplo n.º 13
0
    private static Entity CreatePlayerTemplate(CommandRequestOp <Automaton.Spawner.Commands.SpawnPlayer> op, Coordinates position)
    {
        var callerWorkerRequirementSet = new WorkerRequirementSet(new Improbable.Collections.List <WorkerAttributeSet> {
            new WorkerAttributeSet(op.CallerAttributeSet)
        });
        var gameWorkerAttr = new WorkerAttributeSet(new Improbable.Collections.List <string> {
            "GameWorker"
        });
        var clientWorkerAttr = new WorkerAttributeSet(new Improbable.Collections.List <string>()
        {
            "TPSClient"
        });

        var gameWorkerRequirementSet = new WorkerRequirementSet(new Improbable.Collections.List <WorkerAttributeSet> {
            gameWorkerAttr
        });

        var allRequirementSet = new WorkerRequirementSet(new Improbable.Collections.List <WorkerAttributeSet>
        {
            clientWorkerAttr,
            gameWorkerAttr
        });
        var writeAcl = new Map <uint, WorkerRequirementSet>
        {
            { Position.ComponentId, callerWorkerRequirementSet },
            { EntityAcl.ComponentId, gameWorkerRequirementSet },
            { Movement.ComponentId, callerWorkerRequirementSet },
            { Automaton.Player.Player.ComponentId, callerWorkerRequirementSet },
            { Score.ComponentId, gameWorkerRequirementSet }
        };
        Entity entity = new Entity();

        entity.Add(new EntityAcl.Data(/* read */ allRequirementSet, /* write */ writeAcl));
        entity.Add(new Metadata.Data("SpatialOsPlayer"));
        entity.Add(new Position.Data(position));
        entity.Add(new Movement.Data(false, new Quaternion(1, 0, 0, 0), false));
        entity.Add(new Automaton.Player.Player.Data());
        entity.Add(new Score.Data(0, 0));
        return(entity);
    }
Exemplo n.º 14
0
 private void HandleCommandRequest(CommandRequestOp op)
 {
     commandRequestCallbacks.InvokeAll(op);
 }
Exemplo n.º 15
0
 static void OnGenerateResourceRequest(CommandRequestOp <Harvestable.Commands.GenerateResource, ResourceGenerationRequest> op)
 {
     generateResourceRequestOps.Enqueue(op);
 }
 static void OnExtractResourceRequest(CommandRequestOp <Harvestable.Commands.ExtractResource, ResourceExtractionRequest> op)
 {
     extractResourceRequestOps.Enqueue(op);
 }
Exemplo n.º 17
0
            public override void OnCommandRequest(CommandRequestOp op)
            {
                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                throw new UnknownCommandIndexException(commandIndex, "NestedComponent");
            }
 public override void OnCommandRequest(CommandRequestOp op)
 {
     HasCommandRequestReceived = true;
 }
Exemplo n.º 19
0
 static void OnChatRequest(CommandRequestOp <Communication.Commands.Chat, ChatMessage> op) => chatMessageOps.Enqueue(op);
Exemplo n.º 20
0
 internal static void OnCreatePlayerRequest(CommandRequestOp <PlayerSpawner.Commands.CreatePlayer, CreatePlayerRequest> op)
 {
     commandRequestOps.Enqueue(op);
 }
Exemplo n.º 21
0
 public abstract void OnCommandRequest(CommandRequestOp op);
Exemplo n.º 22
0
 public static void OnPopulateGridCell(CommandRequestOp <AsteroidSpawner.Commands.PopulateGridCell, PopulateGridCellRequest> op)
 {
     commandRequestOps.Enqueue(op);
 }
Exemplo n.º 23
0
            public override void OnCommandRequest(CommandRequestOp op)
            {
                var commandIndex = op.Request.SchemaData.Value.GetCommandIndex();

                throw new UnknownCommandIndexException(commandIndex, "ExhaustiveBlittableSingular");
            }