コード例 #1
0
        public OrderGeneratorResult TryActivate(Scene3D scene)
        {
            var transform = new Transform(_position, Quaternion.CreateFromAxisAngle(Vector3.UnitZ, _angle));

            // TODO: The collider should be created earlier and updated in UpdatePosition/UpdateDrag
            // TODO: This should work for all collider types.
            if (Collider.Create(_buildingDefinition, transform) is BoxCollider collider)
            {
                // TODO: Optimise using a quadtree
                foreach (var obj in scene.GameObjects.Items)
                {
                    if (!(obj.Collider is BoxCollider otherCollider))
                    {
                        continue;
                    }

                    if (collider.Intersects(otherCollider))
                    {
                        return(OrderGeneratorResult.Failure("Intersects an another building."));
                    }
                }
            }

            var order = Order.CreateBuildObject(scene.GetPlayerIndex(scene.LocalPlayer), _definitionIndex, _position, _angle);

            // TODO: Check that the target area has been explored
            // TODO: Check that we still have enough money
            // TODO: Check that the builder can reach target position
            // TODO: Check that the terrain is even enough at the target position

            // TODO: Also send an order to builder to start building.
            return(OrderGeneratorResult.SuccessAndExit(new[] { order }));
        }
コード例 #2
0
        public OrderGeneratorResult TryActivate(Scene3D scene)
        {
            var playerId  = scene.GetPlayerIndex(scene.LocalPlayer);
            var objectIds = scene.GameObjects.GetObjectIds(scene.LocalPlayer.SelectedUnits);
            var order     = Order.CreateSetRallyPointOrder(playerId, objectIds, _position);

            // TODO: Also send an order to builder to start building.
            return(OrderGeneratorResult.SuccessAndExit(new[] { order }));
        }
コード例 #3
0
        public OrderGeneratorResult TryActivate(Scene3D scene)
        {
            var transform = new Transform(_position, Quaternion.CreateFromAxisAngle(Vector3.UnitZ, _angle));

            var order = Order.CreateBuildObject(scene.GetPlayerIndex(scene.LocalPlayer), _definitionIndex, _position, _angle);

            // TODO: Check that we still have enough money

            return(OrderGeneratorResult.SuccessAndExit(new[] { order }));
        }