Example #1
0
    public override InteractResult OnActLeft(InteractionContext context)
    {
        if (context.HasBlock && !context.Block.Is <Impenetrable>())
        {
            World.DeleteBlock(context.BlockPosition.Value);
            var plant = EcoSim.PlantSim.GetPlant(context.BlockPosition.Value + Vector3i.Up);
            if (plant != null)
            {
                EcoSim.PlantSim.DestroyPlant(plant, DeathType.DivineIntervention);
            }

            RoomData.QueueRoomTest(context.BlockPosition.Value);
            return(InteractResult.Success);
        }
        else if (context.HasTarget)
        {
            if (context.Target != null)
            {
                if (context.Target is WorldObject obj)
                {
                    WorldObjectManager.DestroyPermanently(obj);
                }
                if (context.Target is PickupableBlock)
                {
                    World.DeleteBlock(context.BlockPosition.Value);
                }
                else if (context.Target is RubbleObject)
                {
                    (context.Target as RubbleObject).Destroy();
                }
                else if (context.Target is TreeEntity)
                {
                    (context.Target as TreeEntity).Destroy();
                }
                else if (context.Target is Animal)
                {
                    (context.Target as Animal).Destroy();
                }
            }
            return(InteractResult.Success);
        }
        else
        {
            return(InteractResult.NoOp);
        }
    }