예제 #1
0
        /// <summary>Pull items from the connected pipes.</summary>
        /// <param name="pipes">The connected IO pipes.</param>
        /// <returns>Returns whether the machine started processing an item.</returns>
        public override bool Pull(IPipe[] pipes)
        {
            Cask cask = this.Machine;

            if (pipes.TryGetIngredient(match => (match.Sample as SObject)?.quality < 4 && this.AgingRates.ContainsKey(match.Sample.parentSheetIndex), 1, out Requirement consumable))
            {
                SObject input = (SObject)consumable.Take();

                cask.heldObject        = input;
                cask.agingRate         = this.AgingRates[input.parentSheetIndex];
                cask.daysToMature      = 56;
                cask.minutesUntilReady = 999999;
                switch (input.quality)
                {
                case SObject.medQuality:
                    cask.daysToMature = 42;
                    break;

                case SObject.highQuality:
                    cask.daysToMature = 28;
                    break;

                case SObject.bestQuality:
                    cask.daysToMature      = 0;
                    cask.minutesUntilReady = 1;
                    break;
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
 public override bool checkIfComplete(NPC n = null, int number1 = -1, int number2 = -1, Item item = null, string monsterName = null)
 {
     if (this.completed || item == null || (!(item is StardewValley.Object) || n == null) || (!n.isVillager() || !n.name.Equals(this.target) || (item as StardewValley.Object).ParentSheetIndex != this.item && (item as StardewValley.Object).Category != this.item))
     {
         return(false);
     }
     if (item.Stack >= this.number)
     {
         Game1.player.ActiveObject.Stack -= this.number - 1;
         n.CurrentDialogue.Push(new Dialogue(this.targetMessage, n));
         Game1.drawDialogue(n);
         Game1.player.reduceActiveItemByOne();
         if (this.dailyQuest)
         {
             Game1.player.changeFriendship(150, n);
             if (this.deliveryItem == null)
             {
                 this.deliveryItem = new StardewValley.Object(Vector2.Zero, this.item, 1);
             }
             this.moneyReward = this.deliveryItem.price * 3;
         }
         else
         {
             Game1.player.changeFriendship((int)byte.MaxValue, n);
         }
         this.questComplete();
         return(true);
     }
     n.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:ItemDeliveryQuest.cs.13615", (object)this.number), n));
     Game1.drawDialogue(n);
     return(false);
 }
예제 #3
0
 public Item tryToDepositThisItem(Item item, ClickableTextureComponent slot, Texture2D noteTexture)
 {
     if (!this.depositsAllowed)
     {
         Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:JunimoNote_MustBeAtCC", new object[0]));
         return(item);
     }
     if (!(item is StardewValley.Object))
     {
         return(item);
     }
     StardewValley.Object @object = item as StardewValley.Object;
     for (int i = 0; i < this.ingredients.Count; i++)
     {
         if (!this.ingredients[i].completed && this.ingredients[i].index == item.parentSheetIndex && item.Stack >= this.ingredients[i].stack && @object.quality >= this.ingredients[i].quality && slot.item == null)
         {
             item.Stack         -= this.ingredients[i].stack;
             this.ingredients[i] = new BundleIngredientDescription(this.ingredients[i].index, this.ingredients[i].stack, this.ingredients[i].quality, true);
             this.ingredientDepositAnimation(slot, noteTexture, false);
             slot.item = new StardewValley.Object(this.ingredients[i].index, this.ingredients[i].stack, false, -1, this.ingredients[i].quality);
             Game1.playSound("newArtifact");
             (Game1.getLocationFromName("CommunityCenter") as CommunityCenter).bundles[this.bundleIndex][i] = true;
             slot.sourceRect.X = 512;
             slot.sourceRect.Y = 244;
             break;
         }
     }
     if (item.Stack > 0)
     {
         return(item);
     }
     return(null);
 }
예제 #4
0
                public SVObject Retrieve(IntPoint?tileLocation)
                {
                    SVObject result;

                    if (tileLocation is null)
                    {
                        result = Color.HasValue ? new ColoredObject(ParentSheetIndex, 1, Color.Value) : new SVObject(ParentSheetIndex, 1);
                    }
                    else
                    {
                        if (!BigCraftable && ParentSheetIndex == CrabPotID)
                        {
                            result = new CrabPot(new Vector2(tileLocation.Value.X, tileLocation.Value.Y));
                        }
                        else
                        {
                            result = new SVObject(new Vector2(tileLocation.Value.X, tileLocation.Value.Y), ParentSheetIndex, 1);
                        }
                    }

                    result.Name = Name;
                    result.bigCraftable.Value  = BigCraftable;
                    result.showNextIndex.Value = ShowNextIndex;
                    if (result is ColoredObject colored)
                    {
                        colored.ColorSameIndexAsParentSheetIndex = ColorSameIndexAsParentSheetIndex;
                    }
                    return(result);
                }
예제 #5
0
 public static bool ScytheForage(StardewValley.Object o, StardewValley.Tool t, StardewValley.GameLocation loc)
 {
     if (o.isSpawnedObject && !o.questItem && o.isForage(loc))
     {
         var    who     = t.getLastFarmerToUse();
         var    vector  = o.TileLocation;
         int    quality = o.quality;
         Random random  = new Random((int)StardewValley.Game1.uniqueIDForThisGame / 2 + (int)StardewValley.Game1.stats.DaysPlayed + (int)vector.X + (int)vector.Y * 777);
         if (who.professions.Contains(16))
         {
             quality = 4;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 30))
         {
             quality = 2;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 15))
         {
             quality = 1;
         }
         who.gainExperience(2, 7);
         StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
         StardewValley.Game1.stats.ItemsForaged += 1;
         if (who.professions.Contains(13) && random.NextDouble() < 0.2)
         {
             StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
             who.gainExperience(2, 7);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #6
0
        /// <summary>Provide input to the machine.</summary>
        /// <param name="input">The available items.</param>
        /// <returns>Returns whether the machine started processing an item.</returns>
        public override bool SetInput(IStorage input)
        {
            Cask cask = this.Machine;

            if (input.TryGetIngredient(match => (match.Sample as SObject)?.Quality < 4 && this.AgingRates.ContainsKey(match.Sample.ParentSheetIndex), 1, out IConsumable consumable))
            {
                SObject ingredient = (SObject)consumable.Take();

                cask.heldObject.Value   = ingredient;
                cask.agingRate.Value    = this.AgingRates[ingredient.ParentSheetIndex];
                cask.daysToMature.Value = 56;
                cask.MinutesUntilReady  = 999999;
                switch (ingredient.Quality)
                {
                case SObject.medQuality:
                    cask.daysToMature.Value = 42;
                    break;

                case SObject.highQuality:
                    cask.daysToMature.Value = 28;
                    break;

                case SObject.bestQuality:
                    cask.daysToMature.Value = 0;
                    cask.MinutesUntilReady  = 1;
                    break;
                }

                return(true);
            }

            return(false);
        }
예제 #7
0
 public override StardewValley.Object attach(StardewValley.Object o)
 {
     StardewValley.Object arg_1B_0 = this.attachments[0];
     this.attachments[0] = o;
     Game1.playSound("button1");
     return(arg_1B_0);
 }
예제 #8
0
파일: Mill.cs 프로젝트: avere001/sprinklers
 public override void dayUpdate(int dayOfMonth)
 {
     this.hasLoadedToday = false;
     for (int i = this.input.items.Count - 1; i >= 0; i--)
     {
         if (this.input.items[i] != null)
         {
             Item item             = null;
             int  parentSheetIndex = this.input.items[i].parentSheetIndex;
             if (parentSheetIndex <= 246)
             {
                 if (parentSheetIndex == 245 || parentSheetIndex == 246)
                 {
                     item = this.input.items[i];
                 }
             }
             else if (parentSheetIndex != 262)
             {
                 if (parentSheetIndex == 284)
                 {
                     item = new StardewValley.Object(245, 3 * this.input.items[i].Stack, false, -1, 0);
                 }
             }
             else
             {
                 item = new StardewValley.Object(246, this.input.items[i].Stack, false, -1, 0);
             }
             if (item != null && Utility.canItemBeAddedToThisInventoryList(item, this.output.items, 36))
             {
                 this.input.items[i] = Utility.addItemToThisInventoryList(item, this.output.items, 36);
             }
         }
     }
     base.dayUpdate(dayOfMonth);
 }
        /// <summary>
        /// Get a producer rule for a given producer name and input.
        /// </summary>
        /// <param name="producerName">Name of the producer</param>
        /// <param name="input">Input object of a rule</param>
        /// <returns>The producer config</returns>
        public static ProducerRule GetProducerItem(string producerName, Object input)
        {
            ProducerRule value;

            if (input == null)
            {
                RulesRepository.TryGetValue(new Tuple <string, object>(producerName, null), out value);
            }
            else
            {
                RulesRepository.TryGetValue(new Tuple <string, object>(producerName, input.ParentSheetIndex), out value);
                if (value == null)
                {
                    foreach (string tag in input.GetContextTagList())
                    {
                        if (RulesRepository.TryGetValue(new Tuple <string, object>(producerName, tag), out value))
                        {
                            break;
                        }
                    }
                }
                if (value == null)
                {
                    RulesRepository.TryGetValue(new Tuple <string, object>(producerName, input.Category), out value);
                }
            }

            return(value);
        }
예제 #10
0
        public Object Unwrap(Object customObject)
        {
            if (customObject == null)
            {
                return(null);
            }

            customObject.heldObject = Unwrap(customObject.heldObject);

            var customType = TryGetType(customObject);

            if (customObject.GetType() != customType)
            {
                return(customObject);
            }

            IConstructor <Object> basicCtor;

            switch (customObject)
            {
            case Furniture furniture:
                basicCtor = GetBasicCtor <Furniture>();
                break;

            default:
                basicCtor = GetBasicCtor <Object>();
                break;
            }

            var basicObject = basicCtor.Invoke();

            Cloner.Instance.CopyData(customObject, basicObject);
            return(basicObject);
        }
예제 #11
0
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer who, Tool tool, Item item, GameLocation location)
        {
            if (this.Config.CutDebris && tileObj?.Name == "Stone")
            {
                return(this.UseToolOnTile(tool, tile));
            }

            if (tileFeature is HoeDirt dirt)
            {
                if (this.Config.ClearDirt && dirt.crop == null)
                {
                    return(this.UseToolOnTile(tool, tile));
                }

                if (this.Config.CutDeadCrops && dirt.crop.dead)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
            }

            if (this.Config.ClearBouldersAndMeteor)
            {
                ResourceClump rc = this.ResourceClumpCoveringTile(location, tile);
                if (rc != null && this.ResourceUpgradeNeeded.ContainsKey(rc.parentSheetIndex) && tool.upgradeLevel >= this.ResourceUpgradeNeeded[rc.parentSheetIndex])
                {
                    this.UseToolOnTile(tool, tile);
                }
            }
            return(false);
        }
예제 #12
0
 public StardewValley.Object CreateItemstack(int id, int count)
 {
     StardewValley.Object i = (StardewValley.Object)StardewValley.Objects.ObjectFactory.getItemFromDescription(0, id, count);
     i.IsSpawnedObject  = true;
     i.ParentSheetIndex = id;
     return(i);
 }
        public static void SetInputPrefix(object __instance, object input, out KeyValuePair <SObject, SObject> __state)
        {
            __state = new KeyValuePair <SObject, SObject>(null, null);
            Type IStorageType  = __instance.GetType().Assembly.GetType("Pathoschild.Stardew.Automate.IStorage");
            Type ITrackedStack = __instance.GetType().Assembly.GetType("Pathoschild.Stardew.Automate.ITrackedStack");
            Type IConsumable   = __instance.GetType().Assembly.GetType("Pathoschild.Stardew.Automate.IConsumable");


            MethodInfo Instance_IsValidCrop = __instance.GetType().GetMethod("IsValidCrop");

            Func <dynamic, bool> func = x => (bool)Instance_IsValidCrop.Invoke(__instance, new object[] { x });

            Type[] TryGetIngredientParams = new Type[] { func.GetType(), typeof(int), IConsumable.MakeByRefType() };

            MethodInfo IStorage_TryGetIngredient = input.GetType().GetMethod("TryGetIngredient", TryGetIngredientParams);

            object[] TryGetIngredientArgs = new object[] { func, 1, null };

            bool ret = (bool)IStorage_TryGetIngredient.Invoke(input, TryGetIngredientArgs);

            if (ret)
            {
                //Save the State
                SObject Machine = (SObject)(MachineType.GetProperty("Machine", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance));
                SObject crop    = (SObject)IConsumable.GetProperty("Sample").GetValue(TryGetIngredientArgs[2]);

                __state = new KeyValuePair <SObject, SObject>(Machine, crop);
            }
        }
예제 #14
0
 public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
 {
     base.DoFunction(location, x, y, power, who);
     who.Stamina -= 4f;
     this.currentParentTileIndex = 6;
     this.indexOfMenuItemView    = 6;
     if (this.animal != null && this.animal.currentProduce > 0 && (this.animal.age >= (int)this.animal.ageWhenMature && this.animal.toolUsedForHarvest.Equals(this.name)))
     {
         Farmer farmer = who;
         StardewValley.Object @object = new StardewValley.Object(Vector2.Zero, this.animal.currentProduce, (string)null, false, true, false, false);
         @object.quality = this.animal.produceQuality;
         int num = 0;
         if (farmer.addItemToInventoryBool((Item)@object, num != 0))
         {
             Game1.playSound("coin");
             this.animal.currentProduce = -1;
             if (this.animal.showDifferentTextureWhenReadyForHarvest)
             {
                 this.animal.sprite.Texture = Game1.content.Load <Texture2D>("Animals\\Sheared" + this.animal.type);
             }
             who.gainExperience(0, 5);
         }
     }
     this.animal = (FarmAnimal)null;
     if (Game1.activeClickableMenu == null)
     {
         who.CanMove = true;
     }
     else
     {
         who.Halt();
     }
     who.usingTool      = false;
     who.canReleaseTool = true;
 }
예제 #15
0
        public SObject Copy(SObject obj)
        {
            Furniture toCopy = obj as Furniture;

            Furniture furniture = new Furniture(toCopy.ParentSheetIndex, toCopy.TileLocation);

            furniture.defaultBoundingBox.Value = toCopy.defaultBoundingBox.Value;
            furniture.boundingBox.Value        = toCopy.boundingBox.Value;
            furniture.rotations.Value          = toCopy.rotations.Value;
            furniture.currentRotation.Value    = 0;
            furniture.Quality = toCopy.Quality;


            furniture.updateDrawPosition();

            if (toCopy.rotations.Value == 2)
            {
                furniture.currentRotation.Value = toCopy.currentRotation.Value;
            }

            for (int i = 0; i < toCopy.currentRotation.Value; i++)
            {
                furniture.rotate();
            }

            furniture.initializeLightSource(toCopy.TileLocation);
            return(furniture);
        }
예제 #16
0
 private static void OnCraftingMenuClosed(object sender, EventArgsClickableMenuClosed eventArgsClickableMenuClosed)
 {
     MenuEvents.MenuClosed -= OnCraftingMenuClosed;
     GameEvents.UpdateTick -= OnCrafted;
     CraftingMenu           = null;
     PreviousCraftedObject  = null;
 }
예제 #17
0
        //Harvest Coops
        private void HarvestProducts()
        {
            Farm    pFarm  = Game1.getFarm();
            SFarmer Player = Game1.player;

            foreach (Building building in pFarm.buildings)
            {
                if (building is Coop)
                {
                    List <Vector2> coops = new List <Vector2>();

                    foreach (KeyValuePair <Vector2, SObject> pair in building.indoors.Objects)
                    {
                        SObject @object = pair.Value;
                        if (@object.isAnimalProduct() || @object.parentSheetIndex == 107)
                        {
                            if (this.AddToPlayer(@object, Player))
                            {
                                coops.Add(pair.Key);
                                Player.gainExperience(0, 5);
                            }
                        }
                    }
                    foreach (Vector2 iLocation in coops)
                    {
                        building.indoors.removeObject(iLocation, false);
                    }
                }
            }
        }
예제 #18
0
 public override void performActionOnConstruction(GameLocation location)
 {
     base.performActionOnConstruction(location);
     StardewValley.Object @object = new StardewValley.Object(new Vector2(6f, 3f), 99, false);
     @object.fragility = 2;
     this.indoors.objects.Add(new Vector2(6f, 3f), @object);
     this.daysOfConstructionLeft = 3;
 }
예제 #19
0
 /*********
 ** Private methods
 *********/
 /// <summary>The method to call before <see cref="SObject.getDescription"/>.</summary>
 private static void After_GetDescription(SObject __instance, ref string __result)
 {
     if (__instance.ParentSheetIndex == 130)
     {
         var chest = __instance as Chest;
         __result += "\n" + $"Contains {chest?.items?.Count ?? 0} items.";
     }
 }
예제 #20
0
 /*********
 ** Private methods
 *********/
 /// <summary>The method to call before <see cref="SObject.getDescription"/>.</summary>
 private static void After_GetDescription(SObject __instance, ref string __result)
 {
     if (ChestHelper.IsSupported(__instance))
     {
         var chest = __instance as Chest;
         __result += "\n" + $"Contains {chest?.items?.Count ?? 0} items.";
     }
 }
예제 #21
0
        public SObject Copy(SObject obj)
        {
            SObject copy = (SObject)obj.getOne();

            copy.heldObject.Value        = obj.heldObject.Value;
            copy.minutesUntilReady.Value = obj.minutesUntilReady.Value;
            copy.quality.Value           = obj.quality.Value;
            return(copy);
        }
예제 #22
0
 public SObject[] GetDrops(int seed, int count, double chanceModifier)
 {
     SObject[] drops = new SObject[count];
     for (int c = 0; c < count; c++)
     {
         drops[c] = this.GetDrop(seed, chanceModifier);
     }
     return(drops);
 }
        public static void GetFor(ref object __result, SObject obj)
        {
            string machineFullName = __result?.GetType().FullName;

            if (SupportedVanillaMachines.Contains(machineFullName) && (ProducerController.HasProducerRule(obj.Name) || ProducerController.GetProducerConfig(obj.Name) != null))
            {
                __result = new VanillaProducerMachine((IMachine)__result);
            }
        }
예제 #24
0
 public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
 {
     base.DoFunction(location, x, y, power, who);
     who.Stamina -= 4f;
     Shears.playSnip(who);
     this.currentParentTileIndex = 7;
     this.indexOfMenuItemView    = 7;
     if (this.animal != null && this.animal.currentProduce > 0 && (this.animal.age >= (int)this.animal.ageWhenMature && this.animal.toolUsedForHarvest.Equals(this.name)))
     {
         Farmer farmer = who;
         StardewValley.Object @object = new StardewValley.Object(Vector2.Zero, this.animal.currentProduce, (string)null, false, true, false, false);
         @object.quality = this.animal.produceQuality;
         int num = 0;
         if (farmer.addItemToInventoryBool((Item)@object, num != 0))
         {
             this.animal.currentProduce = -1;
             Game1.playSound("coin");
             this.animal.friendshipTowardFarmer = Math.Min(1000, this.animal.friendshipTowardFarmer + 5);
             if (this.animal.showDifferentTextureWhenReadyForHarvest)
             {
                 this.animal.sprite.Texture = Game1.content.Load <Texture2D>("Animals\\Sheared" + this.animal.type);
             }
             who.gainExperience(0, 5);
         }
     }
     else
     {
         string dialogue = "";
         if (this.animal != null && !this.animal.toolUsedForHarvest.Equals(this.name))
         {
             dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:Shears.cs.14245", (object)this.animal.displayName);
         }
         if (this.animal != null && this.animal.isBaby() && this.animal.toolUsedForHarvest.Equals(this.name))
         {
             dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:Shears.cs.14246", (object)this.animal.displayName);
         }
         if (this.animal != null && this.animal.age >= (int)this.animal.ageWhenMature && this.animal.toolUsedForHarvest.Equals(this.name))
         {
             dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:Shears.cs.14247", (object)this.animal.displayName);
         }
         if (dialogue.Length > 0)
         {
             Game1.drawObjectDialogue(dialogue);
         }
     }
     this.animal = (FarmAnimal)null;
     if (Game1.activeClickableMenu == null)
     {
         who.CanMove = true;
     }
     else
     {
         who.Halt();
     }
     who.usingTool      = false;
     who.canReleaseTool = true;
 }
예제 #25
0
 /*********
 ** Private methods
 *********/
 /// <summary>Get the internal drop list entries.</summary>
 /// <param name="drops">The possible drops.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 private IEnumerable <Tuple <ItemDropData, SObject, SpriteInfo> > GetEntries(IEnumerable <ItemDropData> drops, GameHelper gameHelper)
 {
     foreach (ItemDropData drop in drops)
     {
         SObject    item   = this.GameHelper.GetObjectBySpriteIndex(drop.ItemID);
         SpriteInfo sprite = gameHelper.GetSprite(item);
         yield return(Tuple.Create(drop, item, sprite));
     }
 }
예제 #26
0
        public override bool performToolAction(Tool t, int damage, Vector2 tileLocation, GameLocation location = null)
        {
            if (t == null || !(t is Axe))
            {
                return(false);
            }
            Game1.playSound("axchop");
            int num = t.getLastFarmerToUse().toolPower + 1;

            this.health -= (float)num;
            Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(4, 9), false, -1, false, -1);
            if (this.shakeTimer <= 0f)
            {
                this.shakeTimer = 100f;
            }
            if (this.health <= 0f)
            {
                t.getLastFarmerToUse().gainExperience(5, 50 * ((t.getLastFarmerToUse().luckLevel + 1) / 2));
                Random random;
                if (Game1.IsMultiplayer)
                {
                    Game1.recentMultiplayerRandom = new Random((int)tileLocation.X * 1000 + (int)tileLocation.Y);
                    random = Game1.recentMultiplayerRandom;
                }
                else
                {
                    random = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + (int)tileLocation.X * 7 + (int)tileLocation.Y * 11);
                }
                int num2 = random.Next(15, 22);
                if (Game1.IsMultiplayer)
                {
                    Game1.createMultipleObjectDebris(this.parentSheetIndex, (int)tileLocation.X + 1, (int)tileLocation.Y + 1, num2, t.getLastFarmerToUse().uniqueMultiplayerID);
                }
                else
                {
                    Game1.createRadialDebris(Game1.currentLocation, this.parentSheetIndex, (int)tileLocation.X, (int)tileLocation.Y, num2, false, -1, true, -1);
                }
                StardewValley.Object @object = new StardewValley.Object(Vector2.Zero, this.parentSheetIndex, 1);
                Game1.setRichPresence("giantcrop", @object.Name);
                Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(4, 9), false, -1, false, -1);
                Game1.playSound("stumpCrack");
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, tileLocation * (float)Game1.tileSize, Color.White, 8, false, 100f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(1f, 0f)) * (float)Game1.tileSize, Color.White, 8, false, 110f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(1f, 1f)) * (float)Game1.tileSize, Color.White, 8, true, 80f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(0f, 1f)) * (float)Game1.tileSize, Color.White, 8, false, 90f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, tileLocation * (float)Game1.tileSize + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), Color.White, 8, false, 70f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, tileLocation * (float)Game1.tileSize, Color.White, 8, false, 100f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(2f, 0f)) * (float)Game1.tileSize, Color.White, 8, false, 110f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(2f, 1f)) * (float)Game1.tileSize, Color.White, 8, true, 80f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(2f, 2f)) * (float)Game1.tileSize, Color.White, 8, false, 90f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, tileLocation * (float)Game1.tileSize + new Vector2((float)(Game1.tileSize * 3 / 2), (float)(Game1.tileSize * 3 / 2)), Color.White, 8, false, 70f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(0f, 2f)) * (float)Game1.tileSize, Color.White, 8, false, 110f, 0, -1, -1f, -1, 0));
                Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, (tileLocation + new Vector2(1f, 2f)) * (float)Game1.tileSize, Color.White, 8, true, 80f, 0, -1, -1f, -1, 0));
                return(true);
            }
            return(false);
        }
예제 #27
0
        /// <summary>
        /// Gets a dimension offset depending on the size of the object passed in.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static Vector2 GetDimensionOffsetFromItem(StardewValley.Object obj)
        {
            if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), obj.GetType()))
            {
                return(new Vector2(64f, 64f));
            }

            return(new Vector2(64f, 64f));
        }
        public SObject Copy(SObject obj)
        {
            SObject copy = (SObject)obj.getOne();

            copy.heldObject.Value  = obj.heldObject.Value;
            copy.MinutesUntilReady = obj.MinutesUntilReady;
            copy.Quality           = obj.Quality;
            return(copy);
        }
        public static void GetFor(ref object __result, Object obj)
        {
            string machineFullName = __result?.GetType().FullName;

            if (machineFullName == "CCRMAutomate.Automate.ClonerMachine" && (ProducerController.HasProducerRule(obj.Name) || ProducerController.GetProducerConfig(obj.Name) != null))
            {
                __result = new CustomClonerMachine((IMachine)__result);
            }
        }
예제 #30
0
        /// <summary>Draw the value (or return <c>null</c> to render the <see cref="GenericField.Value"/> using the default format).</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        /// <param name="font">The recommended font.</param>
        /// <param name="position">The position at which to draw.</param>
        /// <param name="wrapWidth">The maximum width before which content should be wrapped.</param>
        /// <returns>Returns the drawn dimensions, or <c>null</c> to draw the <see cref="GenericField.Value"/> using the default format.</returns>
        public override Vector2?DrawValue(SpriteBatch spriteBatch, SpriteFont font, Vector2 position, float wrapWidth)
        {
            if (!this.Drops.Any())
            {
                return(spriteBatch.DrawTextBlock(font, this.DefaultText, position, wrapWidth));
            }

            float height = 0;

            // draw preface
            if (!string.IsNullOrWhiteSpace(this.Preface))
            {
                Vector2 prefaceSize = spriteBatch.DrawTextBlock(font, this.Preface, position, wrapWidth);
                height += (int)prefaceSize.Y;
            }

            // list drops
            Vector2 iconSize = new Vector2(font.MeasureString("ABC").Y);

            foreach (var entry in this.Drops)
            {
                // get data
                ItemDropData drop           = entry.Item1;
                SObject      item           = entry.Item2;
                SpriteInfo   sprite         = entry.Item3;
                bool         isGuaranteed   = drop.Probability > .99f;
                bool         shouldFade     = this.FadeNonGuaranteed && !isGuaranteed;
                bool         shouldCrossOut = this.CrossOutNonGuaranteed && !isGuaranteed;

                // draw icon
                spriteBatch.DrawSpriteWithin(sprite, position.X, position.Y + height, iconSize, shouldFade ? Color.White * 0.5f : Color.White);

                // draw text
                string text = isGuaranteed ? item.DisplayName : I18n.Generic_PercentChanceOf(percent: (int)(Math.Round(drop.Probability, 4) * 100), label: item.DisplayName);
                if (drop.MinDrop != drop.MaxDrop)
                {
                    text += $" ({I18n.Generic_Range(min: drop.MinDrop, max: drop.MaxDrop)})";
                }
                else if (drop.MinDrop > 1)
                {
                    text += $" ({drop.MinDrop})";
                }
                Vector2 textSize = spriteBatch.DrawTextBlock(font, text, position + new Vector2(iconSize.X + 5, height + 5), wrapWidth, shouldFade ? Color.Gray : Color.Black);

                // cross out item if it definitely won't drop
                if (shouldCrossOut)
                {
                    spriteBatch.DrawLine(position.X + iconSize.X + 5, position.Y + height + iconSize.Y / 2, new Vector2(textSize.X, 1), this.FadeNonGuaranteed ? Color.Gray : Color.Black);
                }

                height += textSize.Y + 5;
            }

            // return size
            return(new Vector2(wrapWidth, height));
        }