Example #1
0
        public override InteractResult OnActLeft(InteractionContext context)
        {
            if (context.HasBlock && this.ShouldHighlight(context.Block !.GetType()))
            {
                return((InteractResult)AtomicActions.ChangeBlockNow(this.CreateMultiblockContext(context, () => new TampRoad()), typeof(DirtRoadBlock)));
            }

            if (context.Target is WorldObject)
            {
                return(this.BasicToolOnWorldObjectCheck(context));
            }

            return(base.OnActLeft(context));
        }
 public override void BlockInteraction(Vector3i pos, Quaternion rot, VehicleComponent vehicle, Inventory inv = null)
 {
     if (this.enabled)                                                   // Plow only if it's on.
     {
         AtomicActions.ChangeBlockNow(newType: typeof(TilledDirtBlock),  // Create a pack, fill it with plow actions and try to perform.
                                      context: new MultiblockActionContext()
         {
             Player   = vehicle.Driver,
             ToolUsed = this,
             GameActionConstructor = () => new PlowField(),
             ActionDescription     = Localizer.DoStr("plow a block"),
             Area = area.MoveAndRotate(pos, rot)                                 // Rotate area of effect and shift it to current position (and exclude repetitions from the result).
                    .Where(position => World.GetBlock(position).Is <Tillable>()) // Exclude untillable blocks.
         });
     }
 }
Example #3
0
    public override InteractResult OnActLeft(InteractionContext context)
    {
        // Try plow the block (and maybe its surroundings).
        if (context.HasBlock && context.Block !.Is <Tillable>())
        {
            return((InteractResult)AtomicActions.ChangeBlockNow(this.CreateMultiblockContext(context, () => new PlowField()), typeof(TilledDirtBlock)));
        }

        // Try interact with a world object.
        if (context.Target is WorldObject)
        {
            return(this.BasicToolOnWorldObjectCheck(context));
        }

        // Fallback.
        return(base.OnActLeft(context));
    }