Ejemplo n.º 1
0
        public static void Draw_Post(Torch __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            try
            {
                if (!Game1.eventUp || (Game1.currentLocation != null && Game1.currentLocation.currentEvent != null && Game1.currentLocation.currentEvent.showGroundObjects) || Game1.currentLocation.IsFarm)
                {
                    float draw_layer = Math.Max(0f, (((y + 1) * 64) - 24) / 10000f) + (x * 1E-05f);

                    // draw the upper half of the cookout kit even if isOn == false
                    if (__instance.IsCookoutKit() && !__instance.IsOn)
                    {
                        Rectangle r = StardewObject.getSourceRectForBigCraftable(__instance.ParentSheetIndex + 1);
                        r.Height -= 16;
                        Vector2 scaleFactor = __instance.getScale();
                        scaleFactor *= 4f;
                        Vector2 position    = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, (y * 64) - 64 + 12));
                        var     destination = new Rectangle((int)(position.X - (scaleFactor.X / 2f)) + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(position.Y - (scaleFactor.Y / 2f)) + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(64f + scaleFactor.X), (int)(64f + (scaleFactor.Y / 2f)));
                        spriteBatch.Draw(Game1.bigCraftableSpriteSheet, destination, new Rectangle?(r), Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, draw_layer + 0.0028f);
                    }
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
Ejemplo n.º 2
0
 public static void UpdateWhenCurrentLocation_Post(Torch __instance, GameLocation environment, float ___smokePuffTimer)
 {
     try
     {
         // remove the smoke from cookout kits that are off
         if (__instance.IsCookoutKit() && !__instance.IsOn)
         {
             // the condition for smoke to spawn in the overridden method
             if (___smokePuffTimer == 1000f)
             {
                 // make sure it really is the smoke that was just spawned and then remove it
                 if (environment.temporarySprites.Any() && environment.temporarySprites.Last().initialPosition == (__instance.TileLocation * 64f) + new Vector2(32f, -32f))
                 {
                     environment.temporarySprites.RemoveAt(environment.temporarySprites.Count - 1);
                 }
             }
         }
     }
     catch (Exception e)
     {
         mod.ErrorLog("There was an exception in a patch", e);
     }
 }
Ejemplo n.º 3
0
        public static bool CheckForAction_Pre(Torch __instance, Farmer who, bool justCheckingForActivity)
        {
            try
            {
                if (justCheckingForActivity)
                {
                    return(true);
                }

                // check for ignition
                if (__instance.IsCookoutKit() && !__instance.IsOn && who != null)
                {
                    int coalCount         = mod.Config.CoalNeeded;
                    int baseKindlingCount = mod.Config.FiberNeeded;
                    int baseWoodCount     = mod.Config.WoodNeeded;

                    float driftwoodMult = mod.Config.DriftwoodMultiplier;
                    float hardwoodMult  = mod.Config.HardwoodMultiplier;

                    bool hasCoal = who.hasItemInInventory(CoalID, coalCount);

                    bool hasKindling         = false;
                    int  kindlingID          = -1;
                    int  actualKindlingCount = -1;

                    if (hasCoal)
                    {
                        if (!hasKindling)
                        {
                            // soggy newspaper
                            hasKindling = CheckForResource(who, 172, baseKindlingCount, mod.Config.NewspaperMultiplier, ref kindlingID, ref actualKindlingCount);
                        }

                        if (!hasKindling)
                        {
                            // fiber
                            hasKindling = CheckForResource(who, FiberID, baseKindlingCount, 1, ref kindlingID, ref actualKindlingCount);
                        }

                        if (!hasKindling)
                        {
                            // wool
                            hasKindling = CheckForResource(who, 440, baseKindlingCount, mod.Config.WoolMultiplier, ref kindlingID, ref actualKindlingCount);
                        }

                        if (!hasKindling)
                        {
                            // cloth
                            hasKindling = CheckForResource(who, 428, baseKindlingCount, mod.Config.ClothMultiplier, ref kindlingID, ref actualKindlingCount);
                        }
                    }

                    bool hasWood         = false;
                    int  chosenWoodID    = -1;
                    int  actualWoodCount = -1;

                    if (hasCoal && hasKindling)
                    {
                        if (!hasWood)
                        {
                            // driftwood
                            hasWood = CheckForResource(who, DriftwoodID, baseKindlingCount, mod.Config.DriftwoodMultiplier, ref chosenWoodID, ref actualWoodCount);
                        }

                        if (!hasWood)
                        {
                            // wood
                            hasWood = CheckForResource(who, WoodID, baseKindlingCount, 1, ref chosenWoodID, ref actualWoodCount);
                        }

                        if (!hasWood)
                        {
                            // hardwood
                            hasWood = CheckForResource(who, HardwoodID, baseKindlingCount, mod.Config.HardwoodMultiplier, ref chosenWoodID, ref actualWoodCount);
                        }
                    }

                    if (hasCoal && hasKindling && hasWood)
                    {
                        who.removeItemsFromInventory(CoalID, coalCount);
                        who.removeItemsFromInventory(kindlingID, actualKindlingCount);
                        who.removeItemsFromInventory(chosenWoodID, actualWoodCount);

                        __instance.IsOn = true;

                        if (__instance.bigCraftable.Value)
                        {
                            Game1.playSound("fireball");

                            __instance.initializeLightSource(__instance.TileLocation, false);
                            AmbientLocationSounds.addSound(__instance.TileLocation, 1);
                        }
                    }
                    else
                    {
                        var coal  = new StardewObject(CoalID, 0);
                        var fiber = new StardewObject(FiberID, 0);
                        var wood  = new StardewObject(WoodID, 0);

                        Game1.showRedMessage($"{coalCount} {coal.DisplayName}, {baseKindlingCount} {fiber.DisplayName}, {baseWoodCount} {wood.DisplayName}");
                    }

                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }