예제 #1
0
        private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsPlayerFree)
            {
                return;
            }

            bool wearing = JsonAssets.GetClothingId("Sixty-Nine Shirt") != -1 && Game1.player.shirtItem?.Value?.parentSheetIndex?.Value == JsonAssets.GetClothingId("Sixty-Nine Shirt");

            if (!wearing)
            {
                return;
            }

            //Monitor.Log("Wearing shirt... nice.");

            foreach (NPC npc in Game1.player.currentLocation.characters.Where(n => n.isVillager()))
            {
                if (Vector2.Distance(Game1.player.position, npc.position) < Config.MaxDistanceNice)
                {
                    if (!niceNPCs.Contains(npc.name))
                    {
                        npc.showTextAboveHead(Helper.Translation.Get("nice"));
                        niceNPCs.Add(npc.name);
                    }
                }
                else
                {
                    if (niceNPCs.Contains(npc.name))
                    {
                        niceNPCs.Remove(npc.name);
                    }
                }
            }
        }
예제 #2
0
        private void PopulateShop(string dir, int type)
        {
            try
            {
                var stock  = new List <int>();
                var random = new Random();

                var objFolder   = new DirectoryInfo(Path.Combine(Helper.DirectoryPath, dir));
                var firstFolder = objFolder.GetDirectories()[0].GetDirectories()[0].GetDirectories()[0];
                var lastFolder  = objFolder.GetDirectories()[objFolder.GetDirectories().Length - 1];
                lastFolder = lastFolder.GetDirectories()[0].GetDirectories()[lastFolder.GetDirectories()[0]
                                                                             .GetDirectories().Length - 1];

                Log.D($"CatShop first object: {firstFolder.Name}",
                      Config.debugMode);
                Log.D($"CatShop last object: {lastFolder.Name}",
                      Config.debugMode);

                var firstObject = 0;
                var lastObject  = 0;

                switch (type)
                {
                case 0:
                    firstObject = _jsonAssets.GetHatId(firstFolder.Name);
                    lastObject  = _jsonAssets.GetHatId(lastFolder.Name);
                    break;

                case 1:
                    firstObject = _jsonAssets.GetClothingId(firstFolder.Name);
                    lastObject  = _jsonAssets.GetClothingId(lastFolder.Name);
                    break;

                default:
                    Log.E("The CatShop hit a dead end. This feature wasn't finished!");
                    throw new NotImplementedException();
                }

                var goalQty = (lastObject - firstObject) / Const.CatShopQtyRatio;

                Log.D("CatShop Restock bounds:",
                      Config.debugMode);
                Log.D($"index: {firstObject}, end: {lastObject}, goalQty: {goalQty}",
                      Config.debugMode);

                while (stock.Count < goalQty)
                {
                    var id = random.Next(firstObject, lastObject);
                    if (!stock.Contains(id))
                    {
                        stock.Add(id);
                    }
                }

                foreach (var id in stock)
                {
                    switch (type)
                    {
                    case 0:
                        _catShopStock.Add(
                            new StardewValley.Objects.Hat(id), new[]
                            { Const.ClothingCost, 1 });
                        break;

                    case 1:
                        _catShopStock.Add(
                            new StardewValley.Objects.Clothing(id), new[]
                            { Const.ClothingCost, 1 });
                        break;

                    default:
                        Log.E("The CatShop hit a dead end. This feature wasn't finished!");
                        throw new NotImplementedException();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.E("Sailor Styles failed to populate the clothes shop."
                      + "Did you remove all the clothing folders, or did I do something wrong?");
                Log.E("Exception logged:\n" + ex);
            }
        }
예제 #3
0
        private static void PopulateCatShop(bool isHat)
        {
            try
            {
                IEnumerable <string> contentPacks = isHat
                                        ? ModConsts.HatPacks
                                        : ModConsts.ClothingPacks.Concat(Config.ExtraContentPacksToSellInTheShop);

                foreach (string contentPack in contentPacks)
                {
                    var    stock         = new Dictionary <string, bool>();
                    string contentPackId = !ModConsts.HatPacks.Contains(contentPack) && !ModConsts.ClothingPacks.Contains(contentPack)
                                                ? contentPack
                                                : GetIdFromContentPackName(name: contentPack, isHat: isHat);
                    List <string> contentNames = isHat
                                                ? JsonAssets.GetAllHatsFromContentPack(contentPackId)
                                                : JsonAssets.GetAllClothingFromContentPack(contentPackId);
                    if (contentNames == null || contentNames.Count < 1)
                    {
                        if (!ModConsts.HatPacks.Contains(contentPack) && !ModConsts.ClothingPacks.Contains(contentPack))
                        {
                            Log.D($"Did not add content from {contentPack} (as {contentPackId}): Not found.",
                                  Config.DebugMode);
                            continue;
                        }
                        throw new NullReferenceException($"Failed to add content from {contentPack}\n({contentPackId}).");
                    }
                    if (contentPack.EndsWith("Kimono"))
                    {
                        contentNames.RemoveAll(name => name.EndsWith("wer"));
                    }

                    int    goalQty           = Math.Max(1, contentNames.Count / ModConsts.CatShopQtyRatio);
                    string pairedContentPack = contentPack == "Stylish Rogue"
                                                ? GetIdFromContentPackName(name: "Tuxedo Top Hats", isHat: true)
                                                : null;
                    List <string> pairedContentNames = !string.IsNullOrEmpty(pairedContentPack)
                                                ? JsonAssets.GetAllHatsFromContentPack(pairedContentPack)
                                                : null;
                    List <string> shuffledContentNames = contentNames;
                    Utility.Shuffle(Game1.random, contentNames);
                    for (int i = 0; i < goalQty; ++i)
                    {
                        string name = contentNames[i];

                        // Add Tuxedo Top Hats before the tuxedo tops
                        if (contentPack.Equals("Stylish Rogue"))
                        {
                            const string tuxedoHatKey = "Chapeau ";
                            string       hatVariant   = name.Split(new[] { ' ' }, 2)[1];
                            string       hatName      = pairedContentNames.Contains(tuxedoHatKey + hatVariant)
                                                                ? tuxedoHatKey + hatVariant
                                                                : new string[] { "De Luxe", "Mystique", "Blonde" }.Contains(hatVariant)
                                                                        ? tuxedoHatKey + "Blanc"
                                                                        : null;
                            if (!string.IsNullOrEmpty(hatName))
                            {
                                stock[hatName] = true;
                            }
                        }

                        // Add the current hat or top to the shop stock
                        stock[name] = isHat;

                        // Add Sakura Kimono Lowers after the kimono tops
                        if (contentPack.EndsWith("Kimono"))
                        {
                            stock[name.Replace("Upp", "Low")] = false;
                        }
                    }

                    foreach (KeyValuePair <string, bool> nameAndHatFlag in stock)
                    {
                        if (nameAndHatFlag.Value)
                        {
                            CatShopStock[new StardewValley.Objects.Hat(JsonAssets.GetHatId(nameAndHatFlag.Key))]
                                = new[] { GetContentPackCost(contentPack), 1 }
                        }
                        ;
                        else
                        {
                            CatShopStock[new StardewValley.Objects.Clothing(JsonAssets.GetClothingId(nameAndHatFlag.Key))]
                                = new[] { GetContentPackCost(contentPack), 1 }
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                Log.E("Sailor Styles failed to populate the clothes shop."
                      + " Did you remove some clothing folders, or did I break something?");
                Log.E("Exception logged:\n" + ex);
            }
        }
예제 #4
0
        private void PopulateShop(bool isHat)
        {
            try
            {
                var random       = new Random();
                var stock        = new List <string>();
                var contentPacks = isHat
                                        ? Const.HatPacks
                                        : Const.ClothingPacks;

                foreach (var contentPack in contentPacks)
                {
                    var contentPackId = GetContentPackId(contentPack);
                    var contentNames  = isHat
                                                ? _ja.GetAllHatsFromContentPack(contentPackId)
                                                : _ja.GetAllClothingFromContentPack(contentPackId);
                    if (contentPack.EndsWith("Kimono"))
                    {
                        contentNames.RemoveAll(n => n.EndsWith("wer"));
                    }
                    if (contentNames == null || contentNames.Count < 1)
                    {
                        Log.E($"Failed to populate content from {contentPack}\n({contentPackId}).");
                        throw new NullReferenceException();
                    }

                    Log.D($"Stocking content from {contentPack}\n({contentPackId}).",
                          Config.DebugMode);

                    stock.Clear();
                    var currentQty = 0;
                    var goalQty    = Math.Max(1, contentNames.Count / Const.CatShopQtyRatio);
                    while (currentQty < goalQty)
                    {
                        var name = contentNames[random.Next(contentNames.Count - 1)];

                        if (stock.Contains(name))
                        {
                            continue;
                        }
                        ++currentQty;
                        stock.Add(name);

                        if (!contentPack.EndsWith("Kimono"))
                        {
                            continue;
                        }
                        ++currentQty;
                        stock.Add(name.Replace("Upp", "Low"));
                    }

                    foreach (var name in stock)
                    {
                        Log.D($"CatShop: Adding {name}",
                              Config.DebugMode);
                        if (isHat)
                        {
                            _catShopStock.Add(new StardewValley.Objects.Hat(_ja.GetHatId(name)), new[]
                                              { Const.PackCosts[contentPack], 1 });
                        }
                        else
                        {
                            _catShopStock.Add(new StardewValley.Objects.Clothing(_ja.GetClothingId(name)), new[]
                                              { Const.PackCosts[contentPack], 1 });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.E("Sailor Styles failed to populate the clothes shop."
                      + " Did you install the clothing folders, or did I break something?");
                Log.E("Exception logged:\n" + ex);
            }
        }