示例#1
0
 public static bool Building_doAction_Prefix(StardewValley.Buildings.Building __instance, Vector2 tileLocation, Farmer who, ref bool __result)
 {
     try
     {
         if (__instance.buildingType.Value != buildingType)
         {
             return(true); // run original logic
         }
         ModMonitor.Log($"{nameof(Building_doAction_Prefix)}: {__instance.buildingType.Value} right clicked.", LogLevel.Trace);
         if (!(tileLocation.X >= (float)(int)__instance.tileX && tileLocation.X < (float)((int)__instance.tileX + (int)__instance.tilesWide) && tileLocation.Y >= (float)(int)__instance.tileY && tileLocation.Y < (float)((int)__instance.tileY + (int)__instance.tilesHigh)))
         {
             return(true); // run original logic
         }
         if (!who.IsLocalPlayer || (int)__instance.daysOfConstructionLeft > 0 || who.isRidingHorse())
         {
             return(true); // run original logic
         }
         // Just open the forge menu
         Game1.activeClickableMenu = new ForgeMenu();
         __result = true;
         return(false); // don't run original logic
     }
     catch (Exception ex)
     {
         ModMonitor.Log($"Failed in {nameof(Building_doAction_Prefix)}:\n{ex}", LogLevel.Error);
         return(true); // run original logic
     }
 }
示例#2
0
        /*
         * public static Node CreateElement(Vector2 position, GameLocation location, StardewValley.Object obj)
         * {
         *  if (obj.name.Equals("ExtractorPipe"))
         *  {
         *      return new ExtractorPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("GoldExtractorPipe"))
         *  {
         *      return new GoldExtractorPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("IridiumExtractorPipe"))
         *  {
         *      return new IridiumExtractorPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("InserterPipe"))
         *  {
         *      return new InserterPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("PolymorphicPipe"))
         *  {
         *      return new PolymorphicPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("FilterPipe"))
         *  {
         *      return new FilterPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("IronPipe"))
         *  {
         *      return new IronPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("GoldPipe"))
         *  {
         *      return new GoldPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("IridiumPipe"))
         *  {
         *      return new IridiumPipeNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("Chest"))
         *  {
         *      return new ChestContainerNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("Mini-Fridge"))
         *  {
         *      return new ChestContainerNode(position, location, obj);
         *  }
         *  else if (obj.name.Equals("PPM"))
         *  {
         *      return new PPMNode(position, location, obj);
         *  }
         *  else
         *  {
         *      throw new Exception($"Node creation for {obj.Name} failed.");
         *  }
         * }
         */

        public static Node CreateElement(Vector2 position, GameLocation location, StardewValley.Buildings.Building building)
        {
            if (building.GetType().Equals(typeof(ShippingBin)))
            {
                return(new ShippingBinContainerNode(position, location, null, building));
            }
            else
            {
                throw new Exception($"Node creation for {building.nameOfIndoors} failed.");
            }
        }