Example #1
0
        private void OnEntityIdsReserved(WorldCommands.ReserveEntityIds.ReceivedResponse response)
        {
            if (response.StatusCode != StatusCode.Success)
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("ReserveEntityIds failed.").WithField("Reason", response.Message));

                return;
            }

            var location           = transformReader.Data.Location;
            var cubeEntityTemplate = CubeTemplate.CreateCubeEntityTemplate();

            cubeEntityTemplate.SetComponent(new Position.Snapshot
            {
                Coords = new Coordinates(location.X, location.Y + 2, location.Z)
            });
            cubeEntityTemplate.SetComponent(new TransformInternal.Snapshot
            {
                Location = new Location(location.X, location.Y + 2, location.Z),
                Rotation = new Quaternion(1, 0, 0, 0)
            });
            var expectedEntityId = response.FirstEntityId.Value;

            worldCommandRequestSender.SendCreateEntityCommand(
                new WorldCommands.CreateEntity.Request(cubeEntityTemplate, expectedEntityId), OnEntityCreated);
        }
Example #2
0
        private void OnEntityIdsReserved(WorldCommands.ReserveEntityIds.ReceivedResponse response)
        {
            if (!ReferenceEquals(this, response.Context))
            {
                // This response was not for a command from this behaviour.
                return;
            }

            if (response.StatusCode != StatusCode.Success)
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("ReserveEntityIds failed.")
                                        .WithField("Reason", response.Message));

                return;
            }

            var location           = transformReader.Data.Location;
            var cubeEntityTemplate = CubeTemplate.CreateCubeEntityTemplate();

            cubeEntityTemplate.SetComponent(new Position.Snapshot
            {
                Coords = new Coordinates(location.X, location.Y + 2, location.Z)
            });
            cubeEntityTemplate.SetComponent(new TransformInternal.Snapshot
            {
                Location = new Location(location.X, location.Y + 2, location.Z),
                Rotation = new Quaternion(1, 0, 0, 0)
            });
            var expectedEntityId = response.FirstEntityId.Value;

            worldCommandRequestSender.CreateEntity(cubeEntityTemplate, expectedEntityId, context: this);
        }
        private void OnEntityIdsReserved(WorldCommands.ReserveEntityIds.ReceivedResponse response)
        {
            if (!ReferenceEquals(this, response.Context))
            {
                // This response was not for a command from this behaviour.
                return;
            }

            if (response.StatusCode != StatusCode.Success)
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("ReserveEntityIds failed.")
                                        .WithField("Reason", response.Message));
                return;
            }

            var location           = transformReader.Data.Location;
            var unitEntityTemplate =
                BaseUnitTemplate.CreateBaseUnitEntityTemplate(UnitSide.A, new Coordinates(location.X, location.Y + 2, location.Z), UnitType.Soldier);
            var expectedEntityId = response.FirstEntityId.Value;

            worldCommandSender.SendCreateEntityCommand(
                new WorldCommands.CreateEntity.Request(unitEntityTemplate, expectedEntityId), OnEntityCreated);
        }
        private void OnEntityIdsReserved(WorldCommands.ReserveEntityIds.ReceivedResponse response)
        {
            if (response.StatusCode != StatusCode.Success)
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("ReserveEntityIds failed.").WithField("Reason", response.Message));

                return;
            }

            var location = gameObject.transform.position;

            location.y += 2;

            var cubeEntityTemplate = CubeTemplate.CreateCubeEntityTemplate();

            cubeEntityTemplate.SetComponent(new Position.Snapshot(location.ToCoordinates()));
            cubeEntityTemplate.SetComponent(TransformUtils.CreateTransformSnapshot(location, Quaternion.identity));

            var expectedEntityId = response.FirstEntityId.Value;

            worldCommandRequestSender.SendCreateEntityCommand(
                new WorldCommands.CreateEntity.Request(cubeEntityTemplate, expectedEntityId), OnEntityCreated);
        }
Example #5
0
 public void AddReserveEntityIdsResponse(WorldCommands.ReserveEntityIds.ReceivedResponse response)
 {
     worldCommandsReceivedStorage.AddResponse(response);
 }
Example #6
0
 public void AddResponse(WorldCommands.ReserveEntityIds.ReceivedResponse response)
 {
     reserveEntityIdsResponses.Add(response);
 }
Example #7
0
 public int Compare(WorldCommands.ReserveEntityIds.ReceivedResponse x,
                    WorldCommands.ReserveEntityIds.ReceivedResponse y)
 {
     return(x.RequestId.CompareTo(y.RequestId));
 }