コード例 #1
0
    private void OnCoordsUpdated(Improbable.Coordinates newCoords)
    {
        transform.position = newCoords.ToUnityVector();

        if (isTank)
        {
            transform.rotation = Quaternion.AngleAxis(-Mathf.Atan2(transform.position.z, transform.position.x) * Mathf.Rad2Deg + 180, Vector3.up);
        }
    }
コード例 #2
0
    public static Entity CreateControllerTemplate(Improbable.Coordinates spawnPoint, Vector3f topLeft, Vector3f bottomRight, NFZTemplate[] templates, List <Improbable.Controller.DroneInfo> droneSlots)
    {
        List <Improbable.Controller.NoFlyZone> nfzs = new List <Improbable.Controller.NoFlyZone>();

        foreach (NFZTemplate template in templates)
        {
            nfzs.Add(NFZ_Templates.GetNoFlyZone(template));
        }

        return(CreateControllerTemplate(spawnPoint, topLeft, bottomRight, nfzs, droneSlots));
    }
コード例 #3
0
        public static Entity CreateArmchairEntityTemplate(Improbable.Coordinates spawnPosition, float rotation)
        {
            var entityTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(spawnPosition.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.ArmchairPrefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.Euler(0, rotation, 0).ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Grabbable.Data(new Option <CurrentGrabberInfo>()), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(entityTemplate);
        }
コード例 #4
0
    public static Entity CreateDroneTemplate(Improbable.Coordinates spawnPoint, Vector3f initialTarget, EntityId controller, float payloadWeight, float droneSpeed = SimulationSettings.MaxDroneSpeed)
    {
        var droneTemplate = EntityBuilder.Begin()
                            .AddPositionComponent(spawnPoint.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                            .AddMetadataComponent(entityType: SimulationSettings.DronePrefabName)
                            .SetPersistence(true)
                            .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                            .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                            .AddComponent(new DroneData.Data(initialTarget, Mathf.Min(SimulationSettings.MaxDroneSpeed, droneSpeed), new Vector3f(), TargetPending.REQUEST, DroneStatus.MOVE, 0, payloadWeight, new Vector3f(0, -1, 0), controller), CommonRequirementSets.PhysicsOnly)
                            .Build();

        return(droneTemplate);
    }
コード例 #5
0
    public static Entity CreateControllerTemplate(Improbable.Coordinates spawnPoint, Vector3f topLeft, Vector3f bottomRight, List <Improbable.Controller.NoFlyZone> nfzs, List <Improbable.Controller.DroneInfo> droneSlots)
    {
        var controllerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(spawnPoint.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.ControllerPrefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Controller.Data(SimulationSettings.MaxDroneCountPerController, new Map <EntityId, DeliveryInfo>((int)SimulationSettings.MaxDroneCountPerController), droneSlots, false, topLeft, bottomRight), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new GlobalLayer.Data(nfzs), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new BitmapComponent.Data(topLeft, bottomRight, 0, 0, 0, 0, new Improbable.Collections.Map <int, GridType>(), false), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ReactiveLayer.Data(), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new DeliveryHandler.Data(new List <QueueEntry>((int)SimulationSettings.MaxDeliveryRequestQueueSize), 0, 0, 0), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ControllerMetrics.Data(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), CommonRequirementSets.PhysicsOnly)
                                 .Build();

        return(controllerTemplate);
    }
コード例 #6
0
 public static bool ApproximatelyEqual(Improbable.Coordinates a, Improbable.Coordinates b)
 {
     return(ApproximatelyEqual(a.X, b.X) &&
            ApproximatelyEqual(a.Y, b.Y) &&
            ApproximatelyEqual(a.Z, b.Z));
 }