private void UpdateWeatherOnNewDay() { if (!Context.IsMainPlayer) { return; } if (Game1.dayOfMonth == 0) //do not run on day 0. { return; } int loopCount = 0; //Set Temperature for today and tommorow. Get today's conditions. // If tomorrow is set, move it to today, and autoregen tomorrow. // *201711 Due to changes in the object, it auto attempts to update today from tomorrow. if (!Conditions.IsTodayTempSet) { if (!Conditions.IsTomorrowTempSet) { Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice)); if (Game1.weatherForTomorrow == Game1.weather_snow) { while (!WeatherConditions.IsValidWeatherForSnow(Conditions.GetTodayTemps()) && loopCount <= 1000) { Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice)); loopCount++; } } } else { Conditions.SetTodayTempsFromTomorrow(); } Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice)); } if (WeatherOpt.Verbose) { Monitor.Log($"Updated the temperature for tommorow and today. Setting weather for today... ", LogLevel.Trace); } //if today is a festival or wedding, do not go further. if (Conditions.GetCurrentConditions().HasAnyFlags(CurrentWeather.Festival | CurrentWeather.Wedding)) { if (WeatherOpt.Verbose) { Monitor.Log("It is a wedding or festival today. Not attempting to run special weather or fog."); } return; } //variable rain conditions WeatherProcessing.DynamicRainOnNewDay(Conditions, Dice); if (!Conditions.IsVariableRain) { WeatherProcessing.CheckForStaticRainChanges(Conditions, Dice, GameClimate.ChanceForNonNormalRain); } if (WeatherProcessing.TestForSpecialWeather(Conditions, GameClimate.GetClimateForDate(SDate.Now()))) { if (WeatherOpt.Verbose) { Monitor.Log("Special weather created!"); } Conditions.UpdateClimateTracker(); } }
private static bool IsQuestAcceptedInPeriod(string valueToCheck, CustomQuest managedQuest) { if (!Context.IsWorldReady) { return(false); } var parts = valueToCheck.Split(' '); var acceptDate = GetQuestStats(managedQuest).LastAccepted; SDate now = SDate.Now(); Monitor.VerboseLog( $"Checking quest accept date `{acceptDate}` matches current `{now}` by `{valueToCheck}`"); if (parts.Length < 1 || acceptDate == null || (parts.Contains("today") && acceptDate != now)) { return(false); } bool flag = true; foreach (string part in parts) { string[] period = part.Split('='); string type = period.ElementAtOrDefault(0); string value = period.ElementAtOrDefault(1); switch (type) { case "y": case "year": flag &= acceptDate.Year == ( int.TryParse(value, out var year) ? year : now.Year ); break; case "s": case "season": flag &= acceptDate.Season == (value ?? now.Season); break; case "wd": case "weekday": flag &= acceptDate.DayOfWeek == ( Enum.TryParse <DayOfWeek>(value, out var dayOfWeek) ? dayOfWeek : now.DayOfWeek ); break; case "d": case "day": flag &= acceptDate.Day == ( int.TryParse(value, out var day) ? day : now.Day ); break; default: flag &= false; break; } } return(flag); }
private static int MinutesSinceStart() { return(Game1.timeOfDay + SDate.Now().DaysSinceStart * 10000); }
public static int DaysUntilNextTreat(Character character, TreatItem treatItem) { SDate lastDayFeedTreat = character.GetLastDayFeedTreat(); if (lastDayFeedTreat == null) { return(0); } return(lastDayFeedTreat.DaysSinceStart + treatItem.MinimumDaysBetweenTreats - SDate.Now().DaysSinceStart); }
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public override IEnumerable <ICustomField> GetData(Metadata metadata) { NPC npc = this.Target; switch (this.TargetType) { case TargetType.Villager: // special NPCs like Gunther if (metadata.Constants.AsocialVillagers.Contains(npc.Name)) { // no data } // children else if (npc is Child child) { // birthday SDate birthday = SDate.Now().AddDays(-child.daysOld); yield return(new GenericField(this.Text.Get(L10n.Npc.Birthday), this.Text.Stringify(birthday, withYear: true))); // age { ChildAge stage = (ChildAge)child.Age; int daysOld = child.daysOld; int daysToNext = this.GetDaysToNextChildGrowth(stage, daysOld); bool isGrown = daysToNext == -1; int daysAtNext = daysOld + (isGrown ? 0 : daysToNext); string ageLabel = this.Translate(L10n.NpcChild.Age); string ageName = this.Translate(L10n.For(stage)); string ageDesc = isGrown ? this.Translate(L10n.NpcChild.AgeDescriptionGrown, new { label = ageName }) : this.Translate(L10n.NpcChild.AgeDescriptionPartial, new { label = ageName, count = daysToNext, nextLabel = this.Text.Get(L10n.For(stage + 1)) }); yield return(new PercentageBarField(ageLabel, child.daysOld, daysAtNext, Color.Green, Color.Gray, ageDesc)); } // friendship if (Game1.player.friendshipData.ContainsKey(child.Name)) { FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, child, Game1.player.friendshipData[child.Name], metadata); yield return(new CharacterFriendshipField(this.Translate(L10n.Npc.Friendship), friendship, this.Text)); yield return(new GenericField(this.Translate(L10n.Npc.TalkedToday), this.Stringify(Game1.player.friendshipData[child.Name].TalkedToToday))); } } // villagers else { // birthday if (npc.Birthday_Season != null) { SDate birthday = new SDate(npc.Birthday_Day, npc.Birthday_Season); yield return(new GenericField(this.Text.Get(L10n.Npc.Birthday), this.Text.Stringify(birthday))); } // friendship if (Game1.player.friendshipData.ContainsKey(npc.Name)) { FriendshipModel friendship = DataParser.GetFriendshipForVillager(Game1.player, npc, Game1.player.friendshipData[npc.Name], metadata); yield return(new GenericField(this.Translate(L10n.Npc.CanRomance), friendship.IsSpouse ? this.Translate(L10n.Npc.CanRomanceMarried) : this.Stringify(friendship.CanDate))); yield return(new CharacterFriendshipField(this.Translate(L10n.Npc.Friendship), friendship, this.Text)); yield return(new GenericField(this.Translate(L10n.Npc.TalkedToday), this.Stringify(friendship.TalkedToday))); yield return(new GenericField(this.Translate(L10n.Npc.GiftedToday), this.Stringify(friendship.GiftsToday > 0))); if (!friendship.IsSpouse) { yield return(new GenericField(this.Translate(L10n.Npc.GiftedThisWeek), this.Translate(L10n.Generic.Ratio, new { value = friendship.GiftsThisWeek, max = NPC.maxGiftsPerWeek }))); } } else { yield return(new GenericField(this.Translate(L10n.Npc.Friendship), this.Translate(L10n.Npc.FriendshipNotMet))); } // gift tastes var giftTastes = this.GetGiftTastes(npc, metadata); yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LovesGifts), giftTastes, GiftTaste.Love)); yield return(new CharacterGiftTastesField(this.Translate(L10n.Npc.LikesGifts), giftTastes, GiftTaste.Like)); } break; case TargetType.Pet: Pet pet = (Pet)npc; yield return(new CharacterFriendshipField(this.Translate(L10n.Pet.Love), DataParser.GetFriendshipForPet(Game1.player, pet), this.Text)); yield return(new GenericField(this.Translate(L10n.Pet.PettedToday), this.Stringify(this.Reflection.GetField <bool>(pet, "wasPetToday").GetValue()))); break; case TargetType.Monster: // basic info Monster monster = (Monster)npc; yield return(new GenericField(this.Translate(L10n.Monster.Invincible), this.Translate(L10n.Generic.Seconds, new { count = this.Reflection.GetField <int>(monster, "invincibleCountdown").GetValue() }), hasValue: monster.isInvincible())); yield return(new PercentageBarField(this.Translate(L10n.Monster.Health), monster.Health, monster.MaxHealth, Color.Green, Color.Gray, this.Translate(L10n.Generic.PercentRatio, new { percent = Math.Round((monster.Health / (monster.MaxHealth * 1f) * 100)), value = monster.Health, max = monster.MaxHealth }))); yield return(new ItemDropListField(this.Translate(L10n.Monster.Drops), this.GetMonsterDrops(monster), this.Text, defaultText: this.Translate(L10n.Monster.DropsNothing))); yield return(new GenericField(this.Translate(L10n.Monster.Experience), this.Stringify(monster.ExperienceGained))); yield return(new GenericField(this.Translate(L10n.Monster.Defence), this.Stringify(monster.resilience))); yield return(new GenericField(this.Translate(L10n.Monster.Attack), this.Stringify(monster.DamageToFarmer))); // Adventure Guild quest AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.Name); if (adventureGuildQuest != null) { int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum(); yield return(new GenericField(this.Translate(L10n.Monster.AdventureGuild), $"{this.Translate(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete : L10n.Monster.AdventureGuildIncomplete)} ({this.Translate(L10n.Monster.AdventureGuildProgress, new { count = kills, requiredCount = adventureGuildQuest.RequiredKills })})")); } break; } }
private void ShowMoonInfo(string arg1, string[] arg2) { Monitor.Log($"Moon phase according to end of night: {OurMoon.GetLunarPhaseForDay(SDate.Now())}, with coords: { Sprites.Icons.GetNightMoonSprite(OurMoon.GetLunarPhaseForDay(SDate.Now()))}. According to normal phrasing: Phase is {OurMoon.DescribeMoonPhase()}, with rise {OurMoon.GetMoonRiseTime()} and set {OurMoon.GetMoonSetTime()}", LogLevel.Info); }
/// <summary>Get a relative date value like 'tomorrow' or 'in 5 days'.</summary> /// <param name="date">The date to represent.</param> protected string GetRelativeDateStr(SDate date) { return(this.GetRelativeDateStr(date.DaysSinceStart - SDate.Now().DaysSinceStart)); }
protected override bool Update() { return(this.SetValue(SDate.Now().Season)); }
protected override bool Update() { return(this.SetValue(SDate.Now().Year.ToString())); }
public static void LoadContentPacks(object sender, EventArgs e) { foreach (IContentPack contentPack in MailFrameworkModEntry.ModHelper.ContentPacks.GetOwned()) { if (File.Exists(Path.Combine(contentPack.DirectoryPath, "mail.json"))) { MailFrameworkModEntry.ModMonitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); List <MailItem> mailItems = contentPack.ReadJsonFile <List <MailItem> >("mail.json"); foreach (MailItem mailItem in mailItems) { bool Condition(Letter l) => (!Game1.player.mailReceived.Contains(l.Id) || mailItem.Repeatable) && (mailItem.Recipe == null || !Game1.player.cookingRecipes.ContainsKey(mailItem.Recipe)) && (mailItem.Date == null || SDate.Now() >= new SDate(Convert.ToInt32(mailItem.Date.Split(' ')[0]), mailItem.Date.Split(' ')[1], Convert.ToInt32(mailItem.Date.Split(' ')[2].Replace("Y", "")))) && (mailItem.Days == null || mailItem.Days.Contains(SDate.Now().Day)) && (mailItem.Seasons == null || mailItem.Seasons.Contains(SDate.Now().Season)) && (mailItem.Weather == null || (Game1.isRaining && "rainy".Equals(mailItem.Weather)) || (!Game1.isRaining && "sunny".Equals(mailItem.Weather))) && (mailItem.FriendshipConditions == null || mailItem.FriendshipConditions.TrueForAll(f => Game1.player.getFriendshipHeartLevelForNPC(f.NpcName) >= f.FriendshipLevel)) && (mailItem.SkillConditions == null || mailItem.SkillConditions.TrueForAll(s => Game1.player.getEffectiveSkillLevel((int)s.SkillName) >= s.SkillLevel)); if (mailItem.Attachments != null && mailItem.Attachments.Count > 0) { List <Item> attachments = new List <Item>(); Dictionary <int, string> objects = null; Dictionary <int, string> bigObjects = null; mailItem.Attachments.ForEach(i => { switch (i.Type) { case ItemType.Object: if (i.Name != null) { if (objects == null) { objects = MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent); } KeyValuePair <int, string> pair = objects.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/")); if (pair.Value != null) { i.Index = pair.Key; } else { MailFrameworkModEntry.ModMonitor.Log($"No object found with the name {i.Name}.", LogLevel.Warn); } } if (i.Index.HasValue && i.Stack.HasValue) { attachments.Add(new StardewValley.Object(Vector2.Zero, i.Index.Value, i.Stack.Value)); } else { MailFrameworkModEntry.ModMonitor.Log($"An index and a stack value is required to attach an object for letter {mailItem.Id}.", LogLevel.Warn); } break; case ItemType.BigObject: if (i.Name != null) { if (bigObjects == null) { bigObjects = MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >("Data\\BigCraftablesInformation", ContentSource.GameContent); } KeyValuePair <int, string> pair = bigObjects.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/")); if (pair.Value != null) { i.Index = pair.Key; } else { MailFrameworkModEntry.ModMonitor.Log($"No big object found with the name {i.Name}.", LogLevel.Warn); } } if (i.Index.HasValue) { attachments.Add(new StardewValley.Object(Vector2.Zero, i.Index.Value)); } else { MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach a big object for letter {mailItem.Id}.", LogLevel.Warn); } break; case ItemType.Tool: switch (i.Name) { case "Axe": attachments.Add(new Axe()); break; case "Hoe": attachments.Add(new Hoe()); break; case "Watering Can": attachments.Add(new WateringCan()); break; case "Scythe": attachments.Add(new MeleeWeapon(47)); break; case "Pickaxe": attachments.Add(new Pickaxe()); break; default: MailFrameworkModEntry.ModMonitor.Log($"Tool with name {i.Name} not found for letter {mailItem.Id}.", LogLevel.Warn); break; } break; } }); MailDao.SaveLetter( new Letter( mailItem.Id , mailItem.Text , attachments , Condition , (l) => Game1.player.mailReceived.Add(l.Id) , mailItem.WhichBG ) { TextColor = mailItem.TextColor }); } else { MailDao.SaveLetter( new Letter( mailItem.Id , mailItem.Text , mailItem.Recipe , Condition , (l) => Game1.player.mailReceived.Add(l.Id) , mailItem.WhichBG ) { TextColor = mailItem.TextColor }); } } } else { MailFrameworkModEntry.ModMonitor.Log($"Ignoring content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}\nIt does not have an mail.json file.", LogLevel.Warn); } } }
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public override IEnumerable <ICustomField> GetData(Metadata metadata) { var text = this.Text; // get info Building building = this.Target; bool built = !building.isUnderConstruction(); int? upgradeLevel = this.GetUpgradeLevel(building); // construction / upgrade if (!built || building.daysUntilUpgrade.Value > 0) { int daysLeft = building.isUnderConstruction() ? building.daysOfConstructionLeft.Value : building.daysUntilUpgrade.Value; SDate readyDate = SDate.Now().AddDays(daysLeft); yield return(new GenericField(this.GameHelper, L10n.Building.Construction(), L10n.Building.ConstructionSummary(date: readyDate))); } // owner Farmer owner = this.GetOwner(); if (owner != null) { yield return(new LinkField(this.GameHelper, L10n.Building.Owner(), owner.Name, () => new FarmerSubject(this.GameHelper, owner, text))); } else if (building.indoors.Value is Cabin) { yield return(new GenericField(this.GameHelper, L10n.Building.Owner(), L10n.Building.OwnerNone())); } // stable horse if (built && building is Stable stable) { Horse horse = Utility.findHorse(stable.HorseId); if (horse != null) { yield return(new LinkField(this.GameHelper, L10n.Building.Horse(), horse.Name, () => new CharacterSubject(this.GameHelper, horse, TargetType.Horse, this.Metadata, text, this.Reflection))); yield return(new GenericField(this.GameHelper, L10n.Building.HorseLocation(), L10n.Building.HorseLocationSummary(location: horse.currentLocation.Name, x: horse.getTileX(), y: horse.getTileY()))); } } // animals if (built && building.indoors.Value is AnimalHouse animalHouse) { // animal counts yield return(new GenericField(this.GameHelper, L10n.Building.Animals(), L10n.Building.AnimalsSummary(count: animalHouse.animalsThatLiveHere.Count, max: animalHouse.animalLimit.Value))); // feed trough if ((building is Barn || building is Coop) && upgradeLevel >= 2) { yield return(new GenericField(this.GameHelper, L10n.Building.FeedTrough(), L10n.Building.FeedTroughAutomated())); } else { this.GetFeedMetrics(animalHouse, out int totalFeedSpaces, out int filledFeedSpaces); yield return(new GenericField(this.GameHelper, L10n.Building.FeedTrough(), L10n.Building.FeedTroughSummary(filled: filledFeedSpaces, max: totalFeedSpaces))); } } // slimes if (built && building.indoors.Value is SlimeHutch slimeHutch) { // slime count int slimeCount = slimeHutch.characters.OfType <GreenSlime>().Count(); yield return(new GenericField(this.GameHelper, L10n.Building.Slimes(), L10n.Building.SlimesSummary(count: slimeCount, max: 20))); // water trough yield return(new GenericField(this.GameHelper, L10n.Building.WaterTrough(), L10n.Building.WaterTroughSummary(filled: slimeHutch.waterSpots.Count(p => p), max: slimeHutch.waterSpots.Count))); } // upgrade level if (built) { var upgradeLevelSummary = this.GetUpgradeLevelSummary(building, upgradeLevel).ToArray(); if (upgradeLevelSummary.Any()) { yield return(new CheckboxListField(this.GameHelper, L10n.Building.Upgrades(), upgradeLevelSummary)); } } // specific buildings if (built) { switch (building) { // Junimo hut case JunimoHut hut: yield return(new GenericField(this.GameHelper, L10n.Building.JunimoHarvestingEnabled(), text.Stringify(!hut.noHarvest.Value))); yield return(new ItemIconListField(this.GameHelper, L10n.Building.OutputReady(), hut.output.Value?.items, showStackSize: true)); break; // mill case Mill mill: yield return(new ItemIconListField(this.GameHelper, L10n.Building.OutputProcessing(), mill.input.Value?.items, showStackSize: true)); yield return(new ItemIconListField(this.GameHelper, L10n.Building.OutputReady(), mill.output.Value?.items, showStackSize: true)); break; // silo case Building _ when building.buildingType.Value == "Silo": { // hay summary Farm farm = Game1.getFarm(); int siloCount = Utility.numSilos(); int hayCount = farm.piecesOfHay.Value; int maxHay = Math.Max(farm.piecesOfHay.Value, siloCount * 240); yield return(new GenericField( this.GameHelper, L10n.Building.StoredHay(), siloCount == 1 ? L10n.Building.StoredHaySummaryOneSilo(hayCount: hayCount, maxHay: maxHay) : L10n.Building.StoredHaySummaryMultipleSilos(hayCount: hayCount, maxHay: maxHay, siloCount: siloCount) )); } break; } } }
/// <summary>Get the data to display for this subject.</summary> public override IEnumerable <ICustomField> GetData() { // get info Building building = this.Target; bool built = !building.isUnderConstruction(); int? upgradeLevel = this.GetUpgradeLevel(building); // construction / upgrade if (!built || building.daysUntilUpgrade.Value > 0) { int daysLeft = building.isUnderConstruction() ? building.daysOfConstructionLeft.Value : building.daysUntilUpgrade.Value; SDate readyDate = SDate.Now().AddDays(daysLeft); yield return(new GenericField(I18n.Building_Construction(), I18n.Building_Construction_Summary(date: this.Stringify(readyDate)))); } // owner Farmer owner = this.GetOwner(); if (owner != null) { yield return(new LinkField(I18n.Building_Owner(), owner.Name, () => this.Codex.GetByEntity(owner))); } else if (building.indoors.Value is Cabin) { yield return(new GenericField(I18n.Building_Owner(), I18n.Building_Owner_None())); } // stable horse if (built && building is Stable stable) { Horse horse = Utility.findHorse(stable.HorseId); if (horse != null) { yield return(new LinkField(I18n.Building_Horse(), horse.Name, () => this.Codex.GetByEntity(horse))); yield return(new GenericField(I18n.Building_HorseLocation(), I18n.Building_HorseLocation_Summary(location: horse.currentLocation.Name, x: horse.getTileX(), y: horse.getTileY()))); } } // animals if (built && building.indoors.Value is AnimalHouse animalHouse) { // animal counts yield return(new GenericField(I18n.Building_Animals(), I18n.Building_Animals_Summary(count: animalHouse.animalsThatLiveHere.Count, max: animalHouse.animalLimit.Value))); // feed trough if ((building is Barn || building is Coop) && upgradeLevel >= 2) { yield return(new GenericField(I18n.Building_FeedTrough(), I18n.Building_FeedTrough_Automated())); } else { this.GetFeedMetrics(animalHouse, out int totalFeedSpaces, out int filledFeedSpaces); yield return(new GenericField(I18n.Building_FeedTrough(), I18n.Building_FeedTrough_Summary(filled: filledFeedSpaces, max: totalFeedSpaces))); } } // slimes if (built && building.indoors.Value is SlimeHutch slimeHutch) { // slime count int slimeCount = slimeHutch.characters.OfType <GreenSlime>().Count(); yield return(new GenericField(I18n.Building_Slimes(), I18n.Building_Slimes_Summary(count: slimeCount, max: 20))); // water trough yield return(new GenericField(I18n.Building_WaterTrough(), I18n.Building_WaterTrough_Summary(filled: slimeHutch.waterSpots.Count(p => p), max: slimeHutch.waterSpots.Count))); } // upgrade level if (built) { var upgradeLevelSummary = this.GetUpgradeLevelSummary(building, upgradeLevel).ToArray(); if (upgradeLevelSummary.Any()) { yield return(new CheckboxListField(I18n.Building_Upgrades(), upgradeLevelSummary)); } } // specific buildings if (built) { switch (building) { // fish pond case FishPond pond: if (pond.fishType.Value <= -1) { yield return(new GenericField(I18n.Building_FishPond_Population(), I18n.Building_FishPond_Population_Empty())); } else { // get fish population SObject fish = pond.GetFishObject(); fish.Stack = pond.FishCount; var pondData = pond.GetFishPondData(); // population field { string populationStr = $"{fish.DisplayName} ({I18n.Generic_Ratio(pond.FishCount, pond.maxOccupants.Value)})"; if (pond.FishCount < pond.maxOccupants.Value) { SDate nextSpawn = SDate.Now().AddDays(pondData.SpawnTime - pond.daysSinceSpawn.Value); populationStr += Environment.NewLine + I18n.Building_FishPond_Population_NextSpawn(relativeDate: this.GetRelativeDateStr(nextSpawn)); } yield return(new ItemIconField(this.GameHelper, I18n.Building_FishPond_Population(), fish, text: populationStr)); } // output yield return(new ItemIconField(this.GameHelper, I18n.Building_OutputReady(), pond.output.Value)); // drops int chanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, pond.currentOccupants.Value / 10f) * 100); yield return(new FishPondDropsField(this.GameHelper, I18n.Building_FishPond_Drops(), pond.currentOccupants.Value, pondData, preface: I18n.Building_FishPond_Drops_Preface(chance: chanceOfAnyDrop.ToString()))); // quests if (pondData.PopulationGates?.Any(gate => gate.Key > pond.lastUnlockedPopulationGate.Value) == true) { yield return(new CheckboxListField(I18n.Building_FishPond_Quests(), this.GetPopulationGates(pond, pondData))); } } break; // Junimo hut case JunimoHut hut: yield return(new GenericField(I18n.Building_JunimoHarvestingEnabled(), I18n.Stringify(!hut.noHarvest.Value))); yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputReady(), hut.output.Value?.GetItemsForPlayer(Game1.player.UniqueMultiplayerID), showStackSize: true)); break; // mill case Mill mill: yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputProcessing(), mill.input.Value?.GetItemsForPlayer(Game1.player.UniqueMultiplayerID), showStackSize: true)); yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputReady(), mill.output.Value?.GetItemsForPlayer(Game1.player.UniqueMultiplayerID), showStackSize: true)); break; // silo case Building _ when building.buildingType.Value == "Silo": { // hay summary Farm farm = Game1.getFarm(); int siloCount = Utility.numSilos(); int hayCount = farm.piecesOfHay.Value; int maxHay = Math.Max(farm.piecesOfHay.Value, siloCount * 240); yield return(new GenericField( I18n.Building_StoredHay(), siloCount == 1 ? I18n.Building_StoredHay_SummaryOneSilo(hayCount: hayCount, maxHay: maxHay) : I18n.Building_StoredHay_SummaryMultipleSilos(hayCount: hayCount, maxHay: maxHay, siloCount: siloCount) )); } break; } } }
internal static void GetTomorrowTemps() { Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice)); }
internal static void GetTodayTemps() { Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice)); }
["Seasons"] = (valueToCheck, _) => valueToCheck.ToLower().Split(' ').Any(s => s == SDate.Now().Season),
public virtual IDictionary <string, Func <string> > GetTokens() { var spouse = Game1.player.getSpouse(); return(new Dictionary <string, Func <string> >(StringComparer.OrdinalIgnoreCase) { // date and weather { "Day", () => SDate.Now().Day.ToString(CultureInfo.InvariantCulture) }, { "DayEvent", GetDayEvent }, { "DaysPlayed", () => Game1.stats.DaysPlayed.ToString(CultureInfo.InvariantCulture) }, { "Season", () => SDate.Now().Season }, { "Year", () => SDate.Now().Year.ToString(CultureInfo.InvariantCulture) }, { "Weather", GetWeather }, // player { "PlayerGender", () => Game1.player.IsMale ? "Male" : "Female" }, { "PlayerName", () => Game1.player.Name }, { "PreferredPet", () => Game1.player.catPerson ? "Cat" : "Dog" }, { "PetName", Game1.player.getPetName }, { "NickName", () => spouse?.getTermOfSpousalEndearment() }, // relationships { "SpouseGender", () => spouse?.Gender == 0 ? "Male" : "Female" }, { "Spouse", () => spouse?.getName() }, { "HasChild", () => Game1.player.getChildrenCount() > 0 ? "Yes" : "No" }, { "ChildName", () => Game1.player.getChildrenCount() > 0 ? Game1.player.getChildren().Shuffle().First().getName() : "" }, // world { "FarmName", () => Game1.player.farmName.Value }, }); }
["DaysOfWeek"] = (valueToCheck, _) => valueToCheck.Split(' ').Any( d => d.ToLower() == SDate.Now().DayOfWeek.ToString().ToLower()),
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> /// <remarks>Tree growth algorithm reverse engineered from <see cref="FruitTree.dayUpdate"/>.</remarks> public override IEnumerable <ICustomField> GetData(Metadata metadata) { FruitTree tree = this.Target; // get basic info bool isMature = tree.daysUntilMature.Value <= 0; bool isDead = tree.stump.Value; bool isStruckByLightning = tree.struckByLightningCountdown.Value > 0; // show next fruit if (isMature && !isDead) { string label = this.Translate(L10n.FruitTree.NextFruit); if (isStruckByLightning) { yield return(new GenericField(this.GameHelper, label, this.Translate(L10n.FruitTree.NextFruitStruckByLightning, new { count = tree.struckByLightningCountdown }))); } else if (Game1.currentSeason != tree.fruitSeason.Value && !tree.GreenHouseTree) { yield return(new GenericField(this.GameHelper, label, this.Translate(L10n.FruitTree.NextFruitOutOfSeason))); } else if (tree.fruitsOnTree.Value == FruitTree.maxFruitsOnTrees) { yield return(new GenericField(this.GameHelper, label, this.Translate(L10n.FruitTree.NextFruitMaxFruit))); } else { yield return(new GenericField(this.GameHelper, label, this.Translate(L10n.Generic.Tomorrow))); } } // show growth data if (!isMature) { SDate dayOfMaturity = SDate.Now().AddDays(tree.daysUntilMature.Value); string grownOnDateText = this.Translate(L10n.FruitTree.GrowthSummary, new { date = this.Stringify(dayOfMaturity) }); string daysUntilGrownText = this.Text.GetPlural(tree.daysUntilMature.Value, L10n.Generic.Tomorrow, L10n.Generic.InXDays).Tokens(new { count = tree.daysUntilMature }); string growthText = $"{grownOnDateText} ({daysUntilGrownText})"; yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.NextFruit), this.Translate(L10n.FruitTree.NextFruitTooYoung))); yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.Growth), growthText)); if (this.HasAdjacentObjects(this.Tile)) { yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.Complaints), this.Translate(L10n.FruitTree.ComplaintsAdjacentObjects))); } } else { // get quality schedule ItemQuality currentQuality = this.GetCurrentQuality(tree, metadata.Constants.FruitTreeQualityGrowthTime); if (currentQuality == ItemQuality.Iridium) { yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.Quality), this.Translate(L10n.FruitTree.QualityNow, new { quality = this.Translate(L10n.For(currentQuality)) }))); } else { string[] summary = this .GetQualitySchedule(tree, currentQuality, metadata.Constants.FruitTreeQualityGrowthTime) .Select(entry => { // read schedule ItemQuality quality = entry.Key; int daysLeft = entry.Value; SDate date = SDate.Now().AddDays(daysLeft); int yearOffset = date.Year - Game1.year; // generate summary line string qualityName = this.Translate(L10n.For(quality)); if (daysLeft <= 0) { return("-" + this.Translate(L10n.FruitTree.QualityNow, new { quality = qualityName })); } string line; if (yearOffset == 0) { line = $"-{this.Translate(L10n.FruitTree.QualityOnDate, new { quality = qualityName, date = this.Stringify(date) })}"; } else if (yearOffset == 1) { line = $"-{this.Translate(L10n.FruitTree.QualityOnDateNextYear, new { quality = qualityName, date = this.Stringify(date) })}"; } else { line = $"-{this.Translate(L10n.FruitTree.QualityOnDate, new { quality = qualityName, date = this.Text.Stringify(date, withYear: true), year = date.Year })}"; } line += $" ({this.Text.GetPlural(daysLeft, L10n.Generic.Tomorrow, L10n.Generic.InXDays).Tokens(new { count = daysLeft })})"; return(line); }) .ToArray(); yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.Quality), string.Join(Environment.NewLine, summary))); } } // show season yield return(new GenericField(this.GameHelper, this.Translate(L10n.FruitTree.Season), this.Translate(L10n.FruitTree.SeasonSummary, new { season = this.Text.GetSeasonName(tree.fruitSeason.Value) }))); }
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) { bool outro = false; //revised this so it properly draws over the canon moon. :v if (Game1.activeClickableMenu is ShippingMenu ourMenu) { outro = Helper.Reflection.GetField <bool>(ourMenu, "outro").GetValue(); } if (!Game1.wasRainingYesterday && !outro && Game1.activeClickableMenu is ShippingMenu currMenu && currMenu.currentPage == -1) { float scale = Game1.pixelZoom * 1.25f; if (Game1.viewport.Width < 1024) { scale = Game1.pixelZoom * .8f; } if (Game1.viewport.Width < 810) { scale = Game1.pixelZoom * .6f; } if (Game1.viewport.Width < 700) { scale = Game1.pixelZoom * .35f; } Color moonColor = Color.LightCyan; if (OurMoon.GetLunarPhaseForDay(SDate.Now().AddDays(-1)) == MoonPhase.BlueMoon) { moonColor = Color.Blue; } Game1.spriteBatch.Draw(OurIcons.MoonSource, new Vector2(Game1.viewport.Width - 65 * Game1.pixelZoom, Game1.pixelZoom), Sprites.Icons.GetNightMoonSprite(OurMoon.GetLunarPhaseForDay(SDate.Now().AddDays(-1))), moonColor, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 1f); } }
/// <summary>Get the custom fields for machine output.</summary> /// <param name="machine">The machine whose output to represent.</param> private IEnumerable <ICustomField> GetMachineOutputFields(SObject machine) { if (machine == null) { yield break; } SObject heldObj = machine.heldObject.Value; int minutesLeft = machine.MinutesUntilReady; // cask if (machine is Cask cask) { // output item if (heldObj != null) { ItemQuality curQuality = (ItemQuality)heldObj.Quality; // calculate aging schedule float effectiveAge = this.Constants.CaskAgeSchedule.Values.Max() - cask.daysToMature.Value; var schedule = ( from entry in this.Constants.CaskAgeSchedule let quality = entry.Key let baseDays = entry.Value where baseDays > effectiveAge orderby baseDays ascending let daysLeft = (int)Math.Ceiling((baseDays - effectiveAge) / cask.agingRate.Value) select new { Quality = quality, DaysLeft = daysLeft, HarvestDate = SDate.Now().AddDays(daysLeft) } ) .ToArray(); // display fields yield return(new ItemIconField(this.GameHelper, I18n.Item_Contents(), heldObj)); if (minutesLeft <= 0 || !schedule.Any()) { yield return(new GenericField(I18n.Item_CaskSchedule(), I18n.Item_CaskSchedule_Now(quality: I18n.For(curQuality)))); } else { string scheduleStr = string.Join(Environment.NewLine, ( from entry in schedule let str = I18n.GetPlural(entry.DaysLeft, I18n.Item_CaskSchedule_Tomorrow(quality: I18n.For(entry.Quality)), I18n.Item_CaskSchedule_InXDays(quality: I18n.For(entry.Quality), count: entry.DaysLeft, date: this.Stringify(entry.HarvestDate))) select $"-{str}" )); yield return(new GenericField(I18n.Item_CaskSchedule(), $"{I18n.Item_CaskSchedule_NowPartial(quality: I18n.For(curQuality))}{Environment.NewLine}{scheduleStr}")); } } } // crab pot else if (machine is CrabPot pot) { // bait if (heldObj == null) { if (pot.bait.Value != null) { yield return(new ItemIconField(this.GameHelper, I18n.Item_CrabpotBait(), pot.bait.Value)); } else if (Game1.player.professions.Contains(11)) // no bait needed if luremaster { yield return(new GenericField(I18n.Item_CrabpotBait(), I18n.Item_CrabpotBaitNotNeeded())); } else { yield return(new GenericField(I18n.Item_CrabpotBait(), I18n.Item_CrabpotBaitNeeded())); } } // output item if (heldObj != null) { string summary = I18n.Item_Contents_Ready(name: heldObj.DisplayName); yield return(new ItemIconField(this.GameHelper, I18n.Item_Contents(), heldObj, summary)); } } // furniture else if (machine is Furniture) { // displayed item if (heldObj != null) { string summary = I18n.Item_Contents_Placed(name: heldObj.DisplayName); yield return(new ItemIconField(this.GameHelper, I18n.Item_Contents(), heldObj, summary)); } } // auto-grabber else if (machine.ParentSheetIndex == Constant.ObjectIndexes.AutoGrabber && machine.GetItemType() == ItemType.BigCraftable) { string readyText = I18n.Stringify(heldObj is Chest output && output.GetItemsForPlayer(Game1.player.UniqueMultiplayerID).Any()); yield return(new GenericField(I18n.Item_Contents(), readyText)); } // generic machine else { // output item if (heldObj != null) { string summary = minutesLeft <= 0 ? I18n.Item_Contents_Ready(name: heldObj.DisplayName) : I18n.Item_Contents_Partial(name: heldObj.DisplayName, time: this.Stringify(TimeSpan.FromMinutes(minutesLeft))); yield return(new ItemIconField(this.GameHelper, I18n.Item_Contents(), heldObj, summary)); } } }
/********* ** Private methods *********/ /// <summary>Get the global value providers with which to initialize the token manager.</summary> /// <param name="contentHelper">The content helper from which to load data assets.</param> /// <param name="installedMods">The installed mod IDs.</param> private IEnumerable <IValueProvider> GetGlobalValueProviders(IContentHelper contentHelper, InvariantHashSet installedMods) { bool NeedsBasicInfo() => this.IsBasicInfoLoaded; // date and weather yield return(new ConditionTypeValueProvider(ConditionType.Day, () => SDate.Now().Day.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo, allowedValues: Enumerable.Range(0, 29).Select(p => p.ToString()))); // day 0 = new-game intro yield return(new ConditionTypeValueProvider(ConditionType.DayEvent, () => this.GetDayEvent(contentHelper), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.DayOfWeek, () => SDate.Now().DayOfWeek.ToString(), NeedsBasicInfo, allowedValues: Enum.GetNames(typeof(DayOfWeek)))); yield return(new ConditionTypeValueProvider(ConditionType.DaysPlayed, () => Game1.stats.DaysPlayed.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.Season, () => SDate.Now().Season, NeedsBasicInfo, allowedValues: new[] { "Spring", "Summer", "Fall", "Winter" })); yield return(new ConditionTypeValueProvider(ConditionType.Year, () => SDate.Now().Year.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.Weather, this.GetCurrentWeather, NeedsBasicInfo, allowedValues: Enum.GetNames(typeof(Weather)))); // player yield return(new ConditionTypeValueProvider(ConditionType.HasFlag, this.GetFlags, NeedsBasicInfo)); yield return(new HasProfessionValueProvider(NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.HasReadLetter, this.GetReadLetters, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.HasSeenEvent, this.GetEventsSeen, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.HasDialogueAnswer, this.GetDialogueAnswers, NeedsBasicInfo)); yield return(new HasWalletItemValueProvider(NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsMainPlayer, () => Context.IsMainPlayer.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsOutdoors, () => Game1.currentLocation?.IsOutdoors.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.LocationName, () => Game1.currentLocation?.Name, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PlayerGender, () => (Game1.player.IsMale ? Gender.Male : Gender.Female).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PlayerName, () => Game1.player.Name, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PreferredPet, () => (Game1.player.catPerson ? PetType.Cat : PetType.Dog).ToString(), NeedsBasicInfo)); yield return(new SkillLevelValueProvider(NeedsBasicInfo)); // relationships yield return(new VillagerHeartsValueProvider()); yield return(new VillagerRelationshipValueProvider()); yield return(new ConditionTypeValueProvider(ConditionType.Spouse, () => Game1.player?.spouse, NeedsBasicInfo)); // world yield return(new ConditionTypeValueProvider(ConditionType.FarmCave, () => this.GetEnum(Game1.player.caveChoice.Value, FarmCaveType.None).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmhouseUpgrade, () => Game1.player.HouseUpgradeLevel.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmName, () => Game1.player.farmName.Value, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmType, () => this.GetEnum(Game1.whichFarm, FarmType.Custom).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsCommunityCenterComplete, () => this.GetIsCommunityCenterComplete().ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsJojaMartComplete, () => this.GetIsJojaMartComplete().ToString(), NeedsBasicInfo)); yield return(new HavingChildValueProvider(ConditionType.Pregnant, NeedsBasicInfo)); yield return(new HavingChildValueProvider(ConditionType.HavingChild, NeedsBasicInfo)); // string manipulation yield return(new RangeValueProvider()); // other yield return(new ImmutableValueProvider(ConditionType.HasMod.ToString(), installedMods, canHaveMultipleValues: true)); yield return(new HasValueValueProvider()); yield return(new ConditionTypeValueProvider(ConditionType.Language, () => contentHelper.CurrentLocaleConstant.ToString(), allowedValues: Enum.GetNames(typeof(LocalizedContentManager.LanguageCode)).Where(p => p != LocalizedContentManager.LanguageCode.th.ToString()))); }
// Converts time into a continuous counter from 0 to n. // Each increment represents 10 minutes, and each day has 120 possible // values. 600 is 0, 610 is 1, 700 is 6, and 2600 is 120. // 121 possible values for each day. // 600 day 2 is 121. public static uint TimeStamp() { return(TimeStamp(SDate.Now(), Game1.timeOfDay)); }
private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady || !Context.IsPlayerFree || Game1.activeClickableMenu != null || !e.Button.IsActionButton() && e.Button != SButton.ControllerA) { return; } var property = Game1.currentLocation.doesTileHaveProperty((int)e.Cursor.GrabTile.X, (int)e.Cursor.GrabTile.Y, "Action", "Buildings"); switch (property) { case "Buy General": if (_config.Pierre && (_config.ShopsAlwaysOpen || IsNpcInLocation("Pierre"))) { Helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(((SeedShop)Game1.currentLocation).shopStock(), 0, "Pierre"); } break; case "Carpenter": if (_config.Carpenter) { if (_config.ShopsAlwaysOpen) { Carpenters(); } else { NPC robin; if (Game1.currentLocation.characters.Find("Robin") is NPC npc) { robin = npc; } else { break; } var carpenters = Helper.Reflection.GetMethod(Game1.currentLocation, "carpenters"); var tileLocation = robin.getTileLocation(); carpenters.Invoke(new Location((int)tileLocation.X, (int)tileLocation.Y)); } Helper.Input.Suppress(e.Button); } break; case "AnimalShop": if (_config.Ranch) { if (_config.ShopsAlwaysOpen) { AnimalShop(); } else { NPC marnie; if (Game1.currentLocation.characters.Find("Marnie") is NPC npc) { marnie = npc; } else { break; } var animalShop = Helper.Reflection.GetMethod(Game1.currentLocation, "animalShop"); var tileLocation = marnie.getTileLocation(); animalShop.Invoke(new Location((int)tileLocation.X, (int)tileLocation.Y + 1)); } Helper.Input.Suppress(e.Button); } break; case "Buy Fish": if (_config.FishShop && (_config.ShopsAlwaysOpen || IsNpcInLocation("Willy") || IsNpcInLocation("Willy", "Beach"))) { Helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getFishShopStock(Game1.player), 0, "Willy"); } break; case "Blacksmith": if (_config.Blacksmith) { if (_config.ShopsAlwaysOpen) { Blacksmith(Game1.getCharacterFromName("Clint")); } else { NPC clint; if (Game1.currentLocation.characters.Find("Clint") is NPC npc) { clint = npc; } else { break; } Blacksmith(clint); } Helper.Input.Suppress(e.Button); } break; case "IceCreamStand": if (_config.IceCreamStand && (_config.ShopsAlwaysOpen || _config.IceCreamInAllSeasons || SDate.Now().Season == "summer")) { var d = new Dictionary <ISalable, int[]> { { new Object(233, 1), new[] { 250, int.MaxValue } } }; Game1.activeClickableMenu = new ShopMenu(d); Helper.Input.Suppress(e.Button); } break; default: break; } }
public static void addSpecificTemporarySprite(Event __instance, ref string key, GameLocation location, string[] split) { if (!key.StartsWith("animalContest")) { return; } if (key == "animalContest") { String outdoorsTextureName = null; switch (SDate.Now().Season) { case "spring": outdoorsTextureName = spring_outdoorsTileSheetName; break; case "summer": outdoorsTextureName = summer_outdoorsTileSheetName; break; case "fall": outdoorsTextureName = fall_outdoorsTileSheetName; break; case "winter": outdoorsTextureName = winter_outdoorsTileSheetName; break; } location.TemporarySprites.Add(new TemporaryAnimatedSprite(DataLoader.LooseSpritesName, new Rectangle(84, 0, 98, 79), 9999f, 1, 999, new Vector2(26f, 59f) * (float)Game1.tileSize, false, false, (float)(59 * Game1.tileSize) / 10000f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)); //Outdoors Rectangle singleFeed = new Rectangle(304, 144, 16, 32); Rectangle doubleFeed = new Rectangle(320, 128, 32, 32); Rectangle water = new Rectangle(288, 112, 32, 32); Rectangle create = new Rectangle(288, 144, 16, 32); //LooseSprites Rectangle TopLeft = new Rectangle(0, 44, 16, 16); Rectangle TopCenter = new Rectangle(16, 44, 16, 16); Rectangle TopRight = new Rectangle(32, 44, 16, 16); Rectangle CenterLeft = new Rectangle(0, 60, 16, 16); Rectangle CenterCenter = new Rectangle(16, 60, 16, 16); Rectangle CenterRight = new Rectangle(32, 60, 16, 16); Rectangle BottonLeft = new Rectangle(0, 76, 16, 16); Rectangle BottonCenter = new Rectangle(16, 76, 16, 16); Rectangle BottonRight = new Rectangle(32, 76, 16, 16); Rectangle LeftUp = new Rectangle(48, 44, 16, 16); Rectangle RightUp = new Rectangle(64, 44, 16, 16); Rectangle LeftDown = new Rectangle(48, 60, 16, 16); Rectangle RightDown = new Rectangle(64, 60, 16, 16); addTemporarySprite(location, outdoorsTextureName, doubleFeed, 24, 62); addTemporarySprite(location, outdoorsTextureName, water, 32, 62); addTemporarySprite(location, outdoorsTextureName, singleFeed, 34, 62); addTemporarySprite(location, outdoorsTextureName, create, 23, 62); addTemporarySprite(location, DataLoader.LooseSpritesName, TopLeft, 22, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopRight, 23, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopLeft, 24, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 25, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 26, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 27, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 28, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 29, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 30, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 31, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopRight, 32, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopLeft, 33, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopCenter, 34, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, TopRight, 35, 64); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 22, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, RightUp, 23, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, LeftUp, 24, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 25, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 26, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 27, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 28, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 29, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 30, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 31, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterRight, 32, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 33, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 34, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterRight, 35, 65); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 22, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 23, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 24, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 25, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 26, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 27, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 28, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 29, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 30, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 31, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterRight, 32, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 33, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 34, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterRight, 35, 66); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 22, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 23, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, RightDown, 24, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, LeftDown, 25, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 26, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 27, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 28, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 29, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 30, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, RightDown, 31, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonRight, 32, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterLeft, 33, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterCenter, 34, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, CenterRight, 35, 67); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonLeft, 22, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 23, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonRight, 24, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, TopLeft, 24, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonLeft, 25, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, TopRight, 25, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 26, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 27, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 28, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 29, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 30, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonRight, 31, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonLeft, 33, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonCenter, 34, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonRight, 35, 68); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonLeft, 24, 69); addTemporarySprite(location, DataLoader.LooseSpritesName, BottonRight, 25, 69); } else if (key == "animalContestJoshDogSteak") { location.removeTemporarySpritesWithID(10); location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_cursorsName, new Microsoft.Xna.Framework.Rectangle(324, 1936, 12, 20), 80f, 4, 99999, new Vector2(31f, 65f) * (float)Game1.tileSize + new Vector2(3f, 3f) * 4f, false, false, (float)((66 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 11f }); location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_cursorsName, new Microsoft.Xna.Framework.Rectangle(497, 1918, 11, 11), 999f, 1, 9999, new Vector2(30f, 66f) * (float)Game1.tileSize + new Vector2(32f, -8f), false, false, 1f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 12f }); } else if (key == "animalContestJoshDogOut") { location.removeTemporarySpritesWithID(1); location.removeTemporarySpritesWithID(12); location.removeTemporarySpritesWithID(11); location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_cursorsName, new Microsoft.Xna.Framework.Rectangle(324, 1916, 12, 20), 500f, 6, 9999, new Vector2(31f, 65f) * (float)Game1.tileSize + new Vector2(3f, 3f) * 4f, false, false, (float)((66 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 10f }); } else if (key == "animalContestJoshDog") { String townTextureName = null; switch (SDate.Now().Season) { case "spring": townTextureName = spring_towntName; break; case "summer": townTextureName = summer_towntName; break; case "fall": townTextureName = fall_towntName; break; case "winter": townTextureName = winter_towntName; break; } location.TemporarySprites.Add(new TemporaryAnimatedSprite(townTextureName, new Microsoft.Xna.Framework.Rectangle(208, 0, 16, 32), 9999f, 1, 999 , new Vector2(31, 64) * (float)Game1.tileSize, false, false, (float)(65 * Game1.tileSize) / 10000f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)); Action <int> addDogEyes = null; void AddDogEyesHidden(int x) { location.TemporarySprites.Add(new TemporaryAnimatedSprite(townTextureName, new Microsoft.Xna.Framework.Rectangle(192, 0, 16, 16), 1000f, 1, 8, new Vector2(31f, 65f) * (float)Game1.tileSize, false, false, (float)((66 * Game1.tileSize) / 10000f) - 0.01f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 1, endFunction = new TemporaryAnimatedSprite.endBehavior(addDogEyes) }); } addDogEyes = (int x) => { location.TemporarySprites.Add(new TemporaryAnimatedSprite(townTextureName, new Microsoft.Xna.Framework.Rectangle(192, 0, 16, 16), 1000f, 1, 1, new Vector2(31f, 65f) * (float)Game1.tileSize, false, false, (float)((66 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 1, endFunction = new TemporaryAnimatedSprite.endBehavior((Action <int>)AddDogEyesHidden) }); }; AddDogEyesHidden(0); } else if (key == "animalContestFrogShow") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 240, 16, 16), 500f, 1, 9999, new Vector2(29f, 64f) * (float)Game1.tileSize + FrogOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 2 }); } else if (key == "animalContestFrogCroak") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(64, 240, 16, 16), 100f, 4, 1, new Vector2(29f, 64f) * (float)Game1.tileSize + FrogOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00003f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)); } else if (key == "animalContestFrogRun") { location.removeTemporarySpritesWithID(2); location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 240, 16, 16), 100f, 4, 5, new Vector2(29f, 64f) * (float)Game1.tileSize + FrogOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { motion = new Vector2(5f, 0f) }); } else if (key == "animalContestSquirrelShow") { Action <int> addStillSquirrel = null; void AddNimbleSquirrel(int x) { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 192, 32, 32), 200f, 2, 4, new Vector2(29f, 64f) * (float)Game1.tileSize + SquirrelOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 3, endFunction = new TemporaryAnimatedSprite.endBehavior(addStillSquirrel) }); } addStillSquirrel = (int x) => { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 192, 32, 32), 2500f, 1, 1, new Vector2(29f, 64f) * (float)Game1.tileSize + SquirrelOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 3, endFunction = new TemporaryAnimatedSprite.endBehavior((Action <int>)AddNimbleSquirrel) }); }; AddNimbleSquirrel(0); } else if (key == "animalContestSquirrelRun") { location.removeTemporarySpritesWithID(3); location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(64, 192, 32, 32), 50f, 6, 8, new Vector2(29f, 64f) * (float)Game1.tileSize + SquirrelOffset * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { motion = new Vector2(5f, 0f) }); } else if (key == "animalContestBirdShow") { Action <int> addSleepBird = null; void AddStillBird(int x) { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(160, 64, 32, 32), 2500f, 1, 1, new Vector2(29f, 64f) * (float)Game1.tileSize + BirdOffset * 4f, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 4, endFunction = new TemporaryAnimatedSprite.endBehavior(addSleepBird) }); } addSleepBird = (int x) => { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 96, 32, 32), 1500f, 1, 1, new Vector2(29f, 64f) * (float)Game1.tileSize + BirdOffset * 4f, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 4, endFunction = new TemporaryAnimatedSprite.endBehavior((Action <int>)AddStillBird) }); }; AddStillBird(0); } else if (key == "animalContestWildBird") { Action <int> addSleepBird = null; void AddStillBird(int x) { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(160, 128, 32, 32), 2500f, 1, 1, new Vector2(34f, 66f) * (float)Game1.tileSize + BirdOffset * 4f, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 7, endFunction = new TemporaryAnimatedSprite.endBehavior(addSleepBird) }); } addSleepBird = (int x) => { location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(0, 160, 32, 32), 1500f, 1, 1, new Vector2(34f, 66f) * (float)Game1.tileSize + BirdOffset * 4f, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 7, endFunction = new TemporaryAnimatedSprite.endBehavior((Action <int>)AddStillBird) }); }; AddStillBird(0); } else if (key == "animalContestBirdFly2") { location.removeTemporarySpritesWithID(4); location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(32, 96, 32, 32), 60f, 3, 18, new Vector2(29f, 64f) * (float)Game1.tileSize + BirdOffset * 4f, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00003f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { pingPong = true, motion = new Vector2(6f, -1f) }); } else if (key == "animalContestBirdFly") { location.removeTemporarySpritesWithID(4); int count = 18; Action <int> addBirdFlap = null; TemporaryAnimatedSprite lastSprite = null; void AddBirdFly(int x) { if (count == 0) { return; } Game1.playSound("batFlap"); Vector2 position = lastSprite == null ? new Vector2(29f, 64f) * (float)Game1.tileSize + BirdOffset * 4f : lastSprite.Position; lastSprite = new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(32, 96, 32, 32), 60f, 3, 1, position, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00003f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { endFunction = new TemporaryAnimatedSprite.endBehavior(addBirdFlap), motion = new Vector2(6f, -1.3f) }; location.TemporarySprites.Add(lastSprite); count--; } addBirdFlap = (int x) => { lastSprite = new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(64, 96, 32, 32), 60f, 1, 1, lastSprite.Position, false, true, (float)((64 * Game1.tileSize) / 10000f) + 0.00003f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { endFunction = new TemporaryAnimatedSprite.endBehavior((Action <int>)AddBirdFly), motion = new Vector2(6f, -1.3f) }; location.TemporarySprites.Add(lastSprite); }; AddBirdFly(0); } else if (key == "animalContestRabbitShow") { bool flipped = split.Length > 4 && Convert.ToBoolean(split[4]); location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(256, 192, 32, 32), 9999f, 1, 999, new Vector2(Convert.ToSingle(split[2]), Convert.ToSingle(split[3])) * (float)Game1.tileSize + new Vector2(flipped? -7f: -10f, -20f) * 4f, false, flipped, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = split.Length > 5 ? 5 : 0 }); } else if (key == "animalContestRabbitRun") { location.removeTemporarySpritesWithID(5); location.TemporarySprites.Add(new TemporaryAnimatedSprite(tileSheets_critters, new Microsoft.Xna.Framework.Rectangle(128, 160, 32, 32), 45f, 6, 14, new Vector2(29f, 64f) * (float)Game1.tileSize + new Vector2(-10f, -20f) * 4f, false, false, (float)((64 * Game1.tileSize) / 10000f) + 0.00002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { motion = new Vector2(6f, 0f) }); } else if (key == "animalContestEmilyParrot") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(townInterior, new Microsoft.Xna.Framework.Rectangle(464, 1056, 16, 32), 9999f, 1, 999, new Vector2(34f, 65f) * (float)Game1.tileSize, false, false, 0.000001f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)); location.TemporarySprites.Add(new EmilysParrot(new Vector2(34, 64) * (float)Game1.tileSize + new Vector2(4f, 8f) * 4f)); } else if (key == "animalContestEmilyParrotAction") { if (location.getTemporarySpriteByID(5858585) is EmilysParrot emilysParrot) { emilysParrot.doAction(); } } else if (key == "animalContestEmilyBoomBox") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_cursorsName, new Microsoft.Xna.Framework.Rectangle(586, 1871, 24, 14), 9999f, 1, 999, new Vector2(33f, 65f) * (float)Game1.tileSize, false, false, 0.0000009f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { id = 6 }); } else if (key == "animalContestEmilyBoomBoxStart") { location.getTemporarySpriteByID(6).pulse = true; location.getTemporarySpriteByID(6).pulseTime = 420f; } else if (key == "animalContestEmilyBoomBoxStop") { location.getTemporarySpriteByID(6).pulse = false; location.getTemporarySpriteByID(6).scale = 4f; } else if (key == "animalContestEmilyParrotDance") { if (location.getTemporarySpriteByID(5858585) is EmilysParrot emilysParrot) { Vector2 position = emilysParrot.initialPosition; location.removeTemporarySpritesWithID(5858585); location.TemporarySprites.Add(new EmilysParrotDancer(position)); } } else if (key == "animalContestEmilyParrotStopDance") { if (location.getTemporarySpriteByID(5858586) is EmilysParrotDancer emilysParrotDancer) { Vector2 position = emilysParrotDancer.initialPosition; location.removeTemporarySpritesWithID(5858586); location.TemporarySprites.Add(new EmilysParrot(position)); } } else if (key == "animalContestMaruRobot") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(townInterior, new Microsoft.Xna.Framework.Rectangle(448, 576, 16, 16), 9999f, 1, 999, new Vector2(31f, 66f) * (float)Game1.tileSize, false, false, 0.000001f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false)); } else if (key == "animalContestAbigailSlime") { __instance.actors.Add(new EventGreenSlime(new Vector2(31f, 66f) * (float)Game1.tileSize, 5)); } else if (key == "animalContestWillyCrab") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_temporary_sprites_1, new Microsoft.Xna.Framework.Rectangle(259, 146, 18, 18), 250f, 3, 99999, new Vector2(31f, 66f) * (float)Game1.tileSize + CrabOffset * 4f, false, false, 0.000001f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) { pingPong = true }); } else if (key == "animalContestMarnieWinning") { location.TemporarySprites.Add(new TemporaryAnimatedSprite(looseSprites_cursorsName, new Microsoft.Xna.Framework.Rectangle(558, 1425, 20, 26), 400f, 3, 99999, new Vector2(24f, 65f) * 64f, false, false, 0.416f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, false) { pingPong = true }); } else if (key == "animalContestEnding") { AnimalContestController.EndEvent(FarmerLoader.FarmerData.AnimalContestData.Last()); } }
public static Dictionary <string, Func <string, CustomQuest, bool> > GetConditions() { return(new Dictionary <string, Func <string, CustomQuest, bool> >() { ["Weather"] = (valueToCheck, _) => GetCurrentWeatherName() == valueToCheck.ToLower(), ["Date"] = (valueToCheck, _) => SDate.Now() == Utils.ParseDate(valueToCheck), ["Days"] = (valueToCheck, _) => Utility.parseStringToIntArray(valueToCheck).Any(d => d == SDate.Now().Day), ["Seasons"] = (valueToCheck, _) => valueToCheck.ToLower().Split(' ').Any(s => s == SDate.Now().Season), ["DaysOfWeek"] = (valueToCheck, _) => valueToCheck.Split(' ').Any( d => d.ToLower() == SDate.Now().DayOfWeek.ToString().ToLower()), ["Friendship"] = (valueToCheck, _) => DeprecatedCondition(() => CheckFriendshipLevel(valueToCheck), "Friendship", "FriendshipLevel"), ["FriendshipLevel"] = (valueToCheck, _) => CheckFriendshipLevel(valueToCheck), // Emily 7 ["FriendshipStatus"] = (valueToCheck, _) => CheckFriendshipStatus(valueToCheck), // Shane Dating ["MailReceived"] = (valueToCheck, _) => CheckReceivedMailCondition(valueToCheck), ["EventSeen"] = (valueToCheck, _) => CheckEventSeenCondition(valueToCheck), ["MinDaysPlayed"] = (valueToCheck, _) => Game1.Date.TotalDays >= Convert.ToInt32(valueToCheck), ["MaxDaysPlayed"] = (valueToCheck, _) => Game1.Date.TotalDays <= Convert.ToInt32(valueToCheck), ["DaysPlayed"] = (valueToCheck, _) => Game1.Date.TotalDays == Convert.ToInt32(valueToCheck), ["IsPlayerMarried"] = (valueToCheck, _) => ParseBool(valueToCheck) == Game1.player.isMarried(), ["QuestAcceptedInPeriod"] = (valueToCheck, managedQuest) => IsQuestAcceptedInPeriod(valueToCheck, managedQuest), ["QuestAcceptedDate"] = (valueToCheck, managedQuest) => IsQuestAcceptedDate(Utils.ParseDate(valueToCheck), managedQuest), ["QuestCompletedDate"] = (valueToCheck, managedQuest) => IsQuestCompletedDate(Utils.ParseDate(valueToCheck), managedQuest), ["QuestAcceptedToday"] = (valueToCheck, managedQuest) => IsQuestAcceptedDate(SDate.Now(), managedQuest) == ParseBool(valueToCheck), ["QuestCompletedToday"] = (valueToCheck, managedQuest) => IsQuestCompletedDate(SDate.Now(), managedQuest) == ParseBool(valueToCheck), ["QuestNeverAccepted"] = (valueToCheck, managedQuest) => managedQuest.IsNeverAccepted() == ParseBool(valueToCheck), ["QuestNeverCompleted"] = (valueToCheck, managedQuest) => managedQuest.IsNeverCompleted() == ParseBool(valueToCheck), ["KnownCraftingRecipe"] = (valueToCheck, _) => Game1.player.craftingRecipes.ContainsKey(valueToCheck), ["KnownCookingRecipe"] = (valueToCheck, _) => Game1.player.cookingRecipes.ContainsKey(valueToCheck), ["IsCommunityCenterCompleted"] = (valueToCheck, _) => ParseBool(valueToCheck) == Game1.player.hasCompletedCommunityCenter(), ["BuildingConstructed"] = (valueToCheck, _) => CheckBuilding(valueToCheck), // Barn ["SkillLevel"] = (valueToCheck, _) => CheckSkillLevel(valueToCheck), // Farming 1 Foraging 2 ["HasMod"] = (valueToCheck, _) => CheckHasModCondition(valueToCheck), ["Random"] = (valueToCheck, _) => Game1.random.NextDouble() < Convert.ToDouble(valueToCheck) / 100, // Chance is in % ["EPU"] = (valueToCheck, _) => CheckEpuCondition(valueToCheck), // For compatibility with EPU conditions }); }
/** * <summary>Resets the factory to its original state as though it were seeded with the given date.</summary> * <remarks> * This can be used to avoid recreating factories every time new events * need to be generated. See the examples in the class description. * </remarks> * * <param name="date">The date to reseed the RNG with. (Default: current date)</param> * <returns>The same factory itself.</returns> * * <seealso cref="ResetRNG"/> */ public EconEventFactory ReseedWithDate(SDate date = null) { this.dateSeed = date ?? SDate.Now(); return(ResetRNG()); }
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public override IEnumerable <ICustomField> GetData(Metadata metadata) { NPC npc = this.Target; switch (this.TargetType) { case TargetType.Villager: // special NPCs like Gunther if (metadata.Constants.AsocialVillagers.Contains(npc.Name)) { // no data } // children else if (npc is Child child) { // birthday SDate birthday = SDate.Now().AddDays(-child.daysOld); yield return(new GenericField(this.GameHelper, L10n.Npc.Birthday(), this.Text.Stringify(birthday, withYear: true))); // age { ChildAge stage = (ChildAge)child.Age; int daysOld = child.daysOld; int daysToNext = this.GetDaysToNextChildGrowth(stage, daysOld); bool isGrown = daysToNext == -1; int daysAtNext = daysOld + (isGrown ? 0 : daysToNext); string ageDesc = isGrown ? L10n.NpcChild.AgeDescriptionGrown(label: stage) : L10n.NpcChild.AgeDescriptionPartial(label: stage, count: daysToNext, nextLabel: stage + 1); yield return(new PercentageBarField(this.GameHelper, L10n.NpcChild.Age(), child.daysOld, daysAtNext, Color.Green, Color.Gray, ageDesc)); } // friendship if (Game1.player.friendshipData.ContainsKey(child.Name)) { FriendshipModel friendship = this.GameHelper.GetFriendshipForVillager(Game1.player, child, Game1.player.friendshipData[child.Name], metadata); yield return(new CharacterFriendshipField(this.GameHelper, L10n.Npc.Friendship(), friendship, this.Text)); yield return(new GenericField(this.GameHelper, L10n.Npc.TalkedToday(), this.Stringify(Game1.player.friendshipData[child.Name].TalkedToToday))); } } // villagers else { // birthday if (npc.Birthday_Season != null) { SDate birthday = new SDate(npc.Birthday_Day, npc.Birthday_Season); yield return(new GenericField(this.GameHelper, L10n.Npc.Birthday(), this.Text.Stringify(birthday))); } // friendship if (Game1.player.friendshipData.ContainsKey(npc.Name)) { // friendship/romance FriendshipModel friendship = this.GameHelper.GetFriendshipForVillager(Game1.player, npc, Game1.player.friendshipData[npc.Name], metadata); yield return(new GenericField(this.GameHelper, L10n.Npc.CanRomance(), friendship.IsSpouse ? L10n.Npc.CanRomanceMarried() : this.Stringify(friendship.CanDate))); yield return(new CharacterFriendshipField(this.GameHelper, L10n.Npc.Friendship(), friendship, this.Text)); // talked/gifted today yield return(new GenericField(this.GameHelper, L10n.Npc.TalkedToday(), this.Stringify(friendship.TalkedToday))); yield return(new GenericField(this.GameHelper, L10n.Npc.GiftedToday(), this.Stringify(friendship.GiftsToday > 0))); // kissed today if (friendship.IsSpouse) { yield return(new GenericField(this.GameHelper, L10n.Npc.KissedToday(), this.Stringify(this.Reflection.GetField <bool>(npc, "hasBeenKissedToday").GetValue()))); } // gifted this week if (!friendship.IsSpouse) { yield return(new GenericField(this.GameHelper, L10n.Npc.GiftedThisWeek(), L10n.Generic.Ratio(value: friendship.GiftsThisWeek, max: NPC.maxGiftsPerWeek))); } } else { yield return(new GenericField(this.GameHelper, L10n.Npc.Friendship(), L10n.Npc.FriendshipNotMet())); } // gift tastes var giftTastes = this.GetGiftTastes(npc, metadata); yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.LovesGifts(), giftTastes, GiftTaste.Love)); yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.LikesGifts(), giftTastes, GiftTaste.Like)); yield return(new CharacterGiftTastesField(this.GameHelper, L10n.Npc.NeutralGifts(), giftTastes, GiftTaste.Neutral)); } break; case TargetType.Pet: Pet pet = (Pet)npc; yield return(new CharacterFriendshipField(this.GameHelper, L10n.Pet.Love(), this.GameHelper.GetFriendshipForPet(Game1.player, pet), this.Text)); yield return(new GenericField(this.GameHelper, L10n.Pet.PettedToday(), this.Stringify(this.Reflection.GetField <bool>(pet, "wasPetToday").GetValue()))); break; case TargetType.Monster: // basic info Monster monster = (Monster)npc; bool canRerollDrops = Game1.player.isWearingRing(Ring.burglarsRing); yield return(new GenericField(this.GameHelper, L10n.Monster.Invincible(), L10n.Generic.Seconds(count: this.Reflection.GetField <int>(monster, "invincibleCountdown").GetValue()), hasValue: monster.isInvincible())); yield return(new PercentageBarField(this.GameHelper, L10n.Monster.Health(), monster.Health, monster.MaxHealth, Color.Green, Color.Gray, L10n.Generic.PercentRatio(percent: (int)Math.Round((monster.Health / (monster.MaxHealth * 1f) * 100)), value: monster.Health, max: monster.MaxHealth))); yield return(new ItemDropListField(this.GameHelper, L10n.Monster.Drops(), this.GetMonsterDrops(monster), fadeNonGuaranteed: true, crossOutNonGuaranteed: !canRerollDrops, defaultText: L10n.Monster.DropsNothing())); yield return(new GenericField(this.GameHelper, L10n.Monster.Experience(), this.Stringify(monster.ExperienceGained))); yield return(new GenericField(this.GameHelper, L10n.Monster.Defence(), this.Stringify(monster.resilience.Value))); yield return(new GenericField(this.GameHelper, L10n.Monster.Attack(), this.Stringify(monster.DamageToFarmer))); // Adventure Guild quest AdventureGuildQuestData adventureGuildQuest = metadata.GetAdventurerGuildQuest(monster.Name); if (adventureGuildQuest != null) { int kills = adventureGuildQuest.Targets.Select(p => Game1.stats.getMonstersKilled(p)).Sum(); yield return(new GenericField(this.GameHelper, L10n.Monster.AdventureGuild(), $"{(kills >= adventureGuildQuest.RequiredKills ? L10n.Monster.AdventureGuildComplete() : L10n.Monster.AdventureGuildIncomplete())} ({L10n.Monster.AdventureGuildProgress(count: kills, requiredCount: adventureGuildQuest.RequiredKills)})")); } break; } }
["Days"] = (valueToCheck, _) => Utility.parseStringToIntArray(valueToCheck).Any(d => d == SDate.Now().Day),
/**** ** Methods ****/ /// <summary>Whether the mod effects should be enabled for the current date.</summary> private bool ShouldApply() { return(this.ShouldApply(SDate.Now())); }
private void SetTomorrowWeather() { //if tomorrow is a festival or wedding, we need to set the weather and leave. if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.currentSeason)) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_festival; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Festival tomorrow. Aborting processing.", LogLevel.Trace); } //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString()); return; } if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_wedding; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Wedding tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherUtilities.CheckForForceDay(DescriptionEngine, SDate.Now().AddDays(1), Monitor, WeatherOpt.Verbose)) { Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"The game will force tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherOpt.Verbose) { Monitor.Log("Setting weather for tomorrow"); } //now set tomorrow's weather var OddsForTheDay = GameClimate.GetClimateForDate(SDate.Now().AddDays(1)); //get system odds double rainSystem = OddsForTheDay.RetrieveSystemOdds("rain"); double windSystem = OddsForTheDay.RetrieveSystemOdds("debris"); double sunSystem = OddsForTheDay.RetrieveSystemOdds("sunny"); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainSystem = Math.Max(rainSystem - .1, 0); windSystem = Math.Max(windSystem - .1, 0); sunSystem = Math.Min(sunSystem + .2, 1); } //get loose odds double rainDays = OddsForTheDay.RetrieveOdds(Dice, "rain", SDate.Now().AddDays(1).Day); double windyDays = OddsForTheDay.RetrieveOdds(Dice, "debris", SDate.Now().AddDays(1).Day); double stormDays = OddsForTheDay.RetrieveOdds(Dice, "storm", SDate.Now().AddDays(1).Day); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainDays = Math.Max(rainDays - .1, 0); windyDays = Math.Max(windyDays - .1, 0); } if (WeatherOpt.Verbose) { Monitor.Log($"Weather Odds are Rain: {rainDays.ToString("N3")}, Windy: {windyDays.ToString("N3")}, and Storm {stormDays.ToString("N3")}"); Monitor.Log($"Weather System Odds are Rain: {rainSystem.ToString("N3")}, Windy: {windSystem.ToString("N3")}, and Storm {sunSystem.ToString("N3")}"); } //set tomorrow's weather if (Conditions.trackerModel.IsWeatherSystem) { double SystemContinuesOdds = WeatherProcessing.GetWeatherSystemOddsForNewDay(Conditions); if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {SystemContinuesOdds.ToString("N3")}"); } if (Dice.NextDouble() < SystemContinuesOdds) { if (WeatherOpt.Verbose) { Monitor.Log($"Continuing system odds - now for {Conditions.trackerModel.WeatherSystemDays + 1} for weather {Conditions.trackerModel.WeatherSystemType}"); } Conditions.trackerModel.WeatherSystemDays++; WeatherProcessing.SetWeatherTomorrow(Conditions.trackerModel.WeatherSystemType, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { if (WeatherOpt.Verbose) { Monitor.Log($"Ending system, new weather type."); } Conditions.trackerModel.IsWeatherSystem = false; WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } else { if (Dice.NextDouble() < WeatherOpt.WeatherSystemChance) { if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {WeatherOpt.WeatherSystemChance.ToString("N3")}, created system."); } ProbabilityDistribution <string> SystemDist = new ProbabilityDistribution <string>(); SystemDist.AddNewCappedEndPoint(rainSystem, "rain"); SystemDist.AddNewCappedEndPoint(windSystem, "debris"); SystemDist.AddNewCappedEndPoint(sunSystem, "sunny"); double distOdd = Dice.NextDoublePositive(); if (!(SystemDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; Monitor.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } Conditions.SetNewWeatherSystem(Result, 1); WeatherProcessing.SetWeatherTomorrow(Result, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } }