Exemplo n.º 1
0
 public override void Apply(Simulation Sim, WorldSceneNode WorldNode)
 {
     if (Sim.World.Check(WorldNode.HoverBlock))
     {
         Sim.AddTask(new Tasks.Mine(WorldNode.HoverBlock));
     }
 }
Exemplo n.º 2
0
        public override void ExecuteTask(Simulation Sim)
        {
            switch (State)
            {
                case States.Mining:
                    AssignedGnome.FacingDirection = CellLink.DirectionFromAToB(AssignedGnome.Location, Location);

                    Progress -= 0.1f;//Game.ElapsedSeconds;
                    if (Progress <= 0.0f)
                    {
                        MineMutation = new WorldMutations.RemoveBlockMutation(Location, AssignedGnome);
                        Sim.AddWorldMutation(MineMutation);
                        State = States.Finalizing;
                    }

                    return;
                case States.Finalizing:
                    if (MineMutation.Result == MutationResult.Failure)
                        State = States.Mining;
                    else
                    {
                        State = States.Done;
                        Sim.AddTask(new RemoveExcessResource(Location));
                    }
                    return;
                case States.Done:
                    throw new InvalidProgramException("Task should have been deemed completed.");
            }
        }
Exemplo n.º 3
0
        public override void Apply(Simulation Sim, WorldSceneNode WorldNode)
        {
            if (SelectedBlock == null) return;

            if (Sim.World.Check(WorldNode.AdjacentHoverBlock))
            {
                var cell = Sim.World.CellAt(WorldNode.AdjacentHoverBlock);
                if (cell.Block != null) return;
                cell.Block = Sim.Blocks.Templates["Scaffold"];
                cell.BlockOrientation = CellLink.Directions.North;

                if (SelectedBlock.Orientable)
                    cell.BlockOrientation = CellLink.DeriveDirectionFromNormal(WorldNode.HoverNormal);

                Sim.AddTask(new Tasks.Build(SelectedBlock, WorldNode.AdjacentHoverBlock));
            }
        }