private void answerPregnancyQuestion(Farmer who, string answer) { if (answer.Equals("Yes")) { WorldDate birthingDate = new WorldDate(Game1.Date); birthingDate.TotalDays += 14; who.GetSpouseFriendship().NextBirthingDate = birthingDate; Game1.getCharacterFromName(who.spouse).isGaySpouse(); } }
public static void answerPregnancyQuestion(Farmer who, string answer) { if (answer.Equals("Yes")) { WorldDate birthingDate = new WorldDate(Game1.Date); birthingDate.TotalDays += ModEntry.config.PregnancyDays; who.friendshipData[lastPregnantSpouse.Name].NextBirthingDate = birthingDate; lastPregnantSpouse.isGaySpouse(); } }
private static void ConsoleCommand(List <string> args) { try { Utilities.CheckWorldReady(); uint limit = 20; if (args.Count > 0) { if (!uint.TryParse(args[0], out limit) || limit < 1) { throw new ArgumentException($"Invalid limit '{args[0]}', must be a number 1 or higher."); } args.RemoveAt(0); } uint number = Game1.player.stats.GeodesCracked + 1; if (args.Count > 0) { if (!uint.TryParse(args[0], out number) || number < 1) { throw new ArgumentException($"Invalid geode number '{args[0]}', must be a number 1 or higher."); } args.RemoveAt(0); } WorldDate date = Utilities.ArgsToWorldDate(args); List <GeodePrediction> predictions = ListTreasures(number, limit); Utilities.Monitor.Log($"Next {limit} treasure(s) starting with geode {number}:", LogLevel.Info); Utilities.Monitor.Log(" (*: museum donation needed; $: valuable)", LogLevel.Info); Utilities.Monitor.Log("Number | Geode *$ | Frozen Geode *$ | Magma Geode *$ | Omni Geode *$ | Artifact Trove *$", LogLevel.Info); Utilities.Monitor.Log("-------|---------------------------|---------------------------|---------------------------|---------------------------|--------------------------", LogLevel.Info); foreach (GeodePrediction prediction in predictions) { string treasures = string.Join(" | ", prediction.treasures.Values.Select((t) => string.Format("{0,2:D} {1,-20}{2}{3}", t.stack, t.displayName, t.needDonation ? "*" : " ", t.valuable ? "$" : " " ))); Utilities.Monitor.Log(string.Format("{0,5:D}. | {1}", prediction.number, treasures), LogLevel.Info); } } catch (Exception e) { Utilities.Monitor.Log(e.Message, LogLevel.Error); } }
private void selectDay(int day) { selectedDay = day; date = dayToWorldDate(day); Rectangle bounds = new Rectangle( dayButtons[day].bounds.X - 30, dayButtons[day].bounds.Y - 10, 20, 20); daySparkles = Utility.sparkleWithinArea(bounds, 2, SeasonData[day / 28].mainColor, 50); }
public void SetWorldDateCondition(WorldDate date, InequalityTypes beforeOrAfter) { conditionTypeSet = ConditionTypes.WorldDate; if (WorldDate == null) { worldDateCondition = new WorldDateCondition(); } worldDateCondition.Date = date; worldDateCondition.TimeOrientation = beforeOrAfter; }
private double[][,] calculateWaterData(double[][,] rainDays, double[][,] snowfall, out double[][,] snowCover, double[,] lastSnowOfYear, double[,] lastWaterOfYear) { double[][,] surfaceWater = new double[WorldDate.DAYS_PER_YEAR][, ]; snowCover = new double[WorldDate.DAYS_PER_YEAR][, ]; for (int day = 1; day <= WorldDate.DAYS_PER_YEAR; day++) { surfaceWater[day - 1] = new double[this.x, this.z]; snowCover[day - 1] = new double[this.x, this.z]; for (int x = 0; x < this.x; x++) { for (int z = 0; z < this.z; z++) { if (x == 0 && z == 0) { Console.Write(rainDays[day - 1][x, z] + " - "); } if (tileArray[x, z].terrain.oceanPercent < 1.0) { double yesterdaysSnow; double yesterdaysWater; if (day == 1) { yesterdaysSnow = lastSnowOfYear[x, z]; yesterdaysWater = lastWaterOfYear[x, z]; } else { yesterdaysSnow = snowCover[WorldDate.getYesterday(day) - 1][x, z]; yesterdaysWater = surfaceWater[WorldDate.getYesterday(day) - 1][x, z]; } int todaysTemp = tileArray[x, z].temperatures.dailyTemps.days[day - 1]; double snowMelt = Math.Min(Math.Max((todaysTemp - FREEZING_POINT) * MELT_CONST, 0.0), yesterdaysSnow); snowCover[day - 1][x, z] = Math.Round(Math.Max(yesterdaysSnow + snowfall[day - 1][x, z] - snowMelt, 0.0), ROUND_TO); double humid = tileArray[x, z].precipitation.getHumidity(day); double flowAway = 0.0; if (tileArray[x, z].rivers.flowDirection != Direction.CardinalDirections.none) { flowAway = tileArray[x, z].rivers.flowRate; } double waterRemoved = calculateSoilAbsorption(x, z) + flowAway + calculateEvaporation(yesterdaysWater, todaysTemp, humid, determineWeather(rainDays[day - 1][x, z], humid)); double waterGained = rainDays[day - 1][x, z] + getUpstreamFlow(day, x, z, surfaceWater, lastWaterOfYear) + snowMelt; surfaceWater[day - 1][x, z] = Math.Round(Math.Max(yesterdaysWater - waterRemoved + waterGained, 0.0), ROUND_TO); } } } } return(surfaceWater); }
// This constructor is intended only for loading extant worlds from File private World(WorldFile worldFile, Tile[,] tileArray, List <Herd> herds, List <Tribe> tribes) { this.x = worldFile.dimensions[0]; this.z = worldFile.dimensions[1]; Coordinates.setWorldSize(x, z); currentDate = new WorldDate(1, 1); this.herds = herds; this.tribes = tribes; doubleLayerGenerator = new LayerGenerator(x, z, ROUND_TO); intLayerGenerator = new LayerGenerator(x, z, 0); randy = new Random(); this.tileArray = tileArray; }
public void updateLobbyData() { setLobbyData("farmName", Game1.player.farmName.Value); setLobbyData("farmType", Convert.ToString(Game1.whichFarm)); WorldDate date = new WorldDate(Game1.year, Game1.currentSeason, Game1.dayOfMonth); setLobbyData("date", Convert.ToString(date.TotalDays)); IEnumerable <string> farmhandUserIds = from farmhand in Game1.getAllFarmhands() select farmhand.userID.Value; setLobbyData("farmhands", string.Join(",", farmhandUserIds.Where((string user) => user != ""))); setLobbyData("newFarmhands", Convert.ToString(Game1.options.enableFarmhandCreation && unclaimedFarmhandsExist())); }
public override bool Equals(object obj) { bool result = obj is WorldDate; if (result) { WorldDate other = obj as WorldDate; result = this.ToSeconds() == other.ToSeconds(); } return(result); }
public override bool ConditionTest() { WorldDate currentDate = TimeManagerScript.GetDate(); bool finishIsNextDay = (HoursOnly)? Start.ToSecondsHoursOnly() > Finish.ToSecondsHoursOnly() : false; bool currentIsNextDay = finishIsNextDay && Finish.ToSecondsHoursOnly() >= currentDate.ToSecondsHoursOnly(); return ((HoursOnly) ? CompareHoursOnly(currentDate, currentIsNextDay, finishIsNextDay) : CompareFullDates(currentDate)); }
// Returns the localized name of the day of the week for a given date. public static string GetLocalizedDayOfWeek(WorldDate date, bool shortName = false) { if (shortName) { return(Game1.shortDayDisplayNameFromDayOfSeason(date.DayOfMonth)); } else { // February 1999 was a Stardew month: 28 days starting on Monday return(new DateTime(1999, 2, date.DayOfMonth).ToString("dddd", GetCurrentCulture())); } }
public static void GetMovieForDate(ref MovieData __result, WorldDate date) { bool next = false; if (date != new WorldDate(Game1.Date)) { date.TotalDays -= 21; next = true; } int r = date.TotalDays / 7; var data = MovieTheater.GetMovieData(); string season = Game1.currentSeason; if (next && Game1.dayOfMonth > 21) { switch (season) { case "spring": season = "summer"; break; case "summer": season = "fall"; break; case "fall": season = "winter"; break; case "winter": season = "spring"; break; } } List <MovieData> movies = data.Values.Where(m => m.ID.StartsWith(season)).ToList(); __result = movies[r % movies.Count]; if (__result.Tags.Contains("CustomMovie")) { CMVAssetEditor.CurrentMovie = allTheMovies[__result.Tags.Find(t => t.StartsWith("CMovieID:")).Split(':')[1]]; } else { CMVAssetEditor.CurrentMovie = null; } if (lastMovie != CMVAssetEditor.CurrentMovie) { cmHelper.Content.InvalidateCache(@"LooseSprites\Movies"); } lastMovie = CMVAssetEditor.CurrentMovie; }
private void WeddingCommand(string arg1, string[] arg2) { if (!Context.IsWorldReady) { Monitor.Log("Game not loaded.", LogLevel.Error); return; } if ((Game1.player.spouse == null || !Game1.player.friendshipData.ContainsKey(Game1.player.spouse) || !Game1.player.friendshipData[Game1.player.spouse].IsEngaged())) { Monitor.Log("No upcoming wedding.", LogLevel.Alert); return; } string fiancee = Game1.player.spouse; if (arg2.Length == 0) { Monitor.Log($"{Game1.player.Name} is engaged to {fiancee}. The wedding is in {Game1.player.friendshipData[fiancee].CountdownToWedding} days, on {Utility.getDateStringFor(Game1.player.friendshipData[fiancee].WeddingDate.DayOfMonth, Game1.player.friendshipData[fiancee].WeddingDate.SeasonIndex, Game1.player.friendshipData[fiancee].WeddingDate.Year)}.", LogLevel.Info); } else if (arg2.Length == 1 && arg2[0] == "cancel") { Game1.player.friendshipData[fiancee].Status = FriendshipStatus.Dating; Game1.player.friendshipData[fiancee].WeddingDate = null; Game1.player.spouse = null; foreach (var f in Game1.player.friendshipData.Pairs) { if (f.Value.IsMarried()) { Game1.player.spouse = f.Key; break; } } Monitor.Log($"{Game1.player.Name} engagement to {fiancee} was cancelled.", LogLevel.Info); } else if (arg2.Length == 2 && arg2[0] == "set") { if (!int.TryParse(arg2[1], out int days) || days <= 0) { Monitor.Log($"Invalid number of days: {arg2[1]}.", LogLevel.Error); return; } WorldDate weddingDate = new WorldDate(Game1.Date); weddingDate.TotalDays += days; Game1.player.friendshipData[fiancee].WeddingDate = weddingDate; Monitor.Log($"{Game1.player.Name} wedding with {fiancee} was changed to {Game1.player.friendshipData[fiancee].CountdownToWedding} days from now, on {Utility.getDateStringFor(Game1.player.friendshipData[fiancee].WeddingDate.DayOfMonth, Game1.player.friendshipData[fiancee].WeddingDate.SeasonIndex, Game1.player.friendshipData[fiancee].WeddingDate.Year)}.", LogLevel.Info); } }
public void PerformCellHover(int x, int y, WorldDate date, Rectangle bounds) { if (Schedule == null) { return; } int time = Schedule[date.DayOfMonth - 1]; if (time < 0) { return; } Menu.HoverText = TimeHelper.FormatTime(time); }
// Finds the next Garbage Hat to be available on or after the given date. public static GarbagePrediction?FindGarbageHat(WorldDate fromDate) { for (int days = fromDate.TotalDays; days < fromDate.TotalDays + Utilities.MaxHorizon; ++days) { List <GarbagePrediction> predictions = ListLootForDate(Utilities.TotalDaysToWorldDate(days), true) .Where((p) => p.loot is Hat).ToList(); if (predictions.Count > 0) { return(predictions[0]); } } return(null); }
bool DrawGenericWorldDateField(WorldDate prevDate, int labelWidth, string labelText, out WorldDate newDate, bool omitHours = false) { bool result = false; bool foldout = prevDate == null || prevDate.ShowInFoldout; bool newFoldout = EditorGUILayout.Foldout(foldout, (foldout) ? labelText : labelText + ": " + ((prevDate == null) ? "..." : prevDate.ToString())); if (newFoldout) { EditorGUILayout.BeginVertical(Config.FoldoutInteriorStyle); { bool prevIsNull = prevDate == null; int days = (prevIsNull) ? 0 : prevDate.Days; int hours = (prevIsNull) ? 0 : prevDate.Hours; int minutes = (prevIsNull) ? 0 : prevDate.Minutes; int secs = (prevIsNull) ? 0 : prevDate.Seconds; days = (omitHours) ? 0 : EditorGUILayout.IntField("Day", days); hours = EditorGUILayout.IntField("Hour", hours); minutes = EditorGUILayout.IntField("Minute", minutes); secs = EditorGUILayout.IntField("Seconds", secs); days = (days >= 0) ? days : 0; hours = (hours >= 0) ? hours : 0; minutes = (minutes >= 0) ? minutes : 0; secs = (secs >= 0) ? secs : 0; newDate = new WorldDate(secs, minutes, hours, days); result = !newDate.Equals(prevDate); } EditorGUILayout.EndVertical(); } else { newDate = prevDate; } newDate.ShowInFoldout = newFoldout; prevDate.ShowInFoldout = newFoldout; return(result); }
// Returns the first day of the next season after a given date. public static WorldDate GetNextSeasonStart(WorldDate date) { switch (date.Season) { case "spring": return(new WorldDate(date.Year, "summer", 1)); case "summer": return(new WorldDate(date.Year, "fall", 1)); case "fall": return(new WorldDate(date.Year, "winter", 1)); default: return(new WorldDate(date.Year + 1, "spring", 1)); } }
protected override void doRun() { // Show the menu of modes. List <Response> modes = Modes.Select((mode) => new Response(mode, Helper.Translation.Get($"garbage.mode.{mode}"))).ToList(); Game1.drawObjectQuestionDialogue (Helper.Translation.Get("garbage.mode.question"), modes); Game1.currentLocation.afterQuestion = (Farmer _who, string mode) => { Game1.currentLocation.afterQuestion = null; WorldDate today = Utilities.Now(); switch (mode) { case "today": showPredictions(today, Garbage.ListLootForDate(today), mode); break; case "later": Game1.activeClickableMenu = new DatePicker(today, Helper.Translation.Get("garbage.date.question"), (date) => showPredictions(date, Garbage.ListLootForDate(date), mode)); break; case "hat": GarbagePrediction? hat = Garbage.FindGarbageHat(today); List <GarbagePrediction> predictions = new List <GarbagePrediction> (); if (hat.HasValue) { predictions.Add(hat.Value); } showPredictions(hat.HasValue ? hat.Value.date : today, predictions, mode); break; case "leave": default: extinguish(); break; } }; }
public OldCropInfo(string id, Item item, string name, SpriteInfo sprite, bool giantCrop, SpriteInfo giantSprite, Item[] seeds, bool trellisCrop, int[] phases, int regrow, bool paddyCrop, SpriteInfo[] phaseSprites, WorldDate startDate, WorldDate endDate) { Id = id; Item = item; Name = name; Sprite = sprite; IsGiantCrop = giantCrop; GiantSprite = giantSprite; Seeds = seeds; IsTrellisCrop = trellisCrop; Phases = phases; Regrow = regrow; IsPaddyCrop = paddyCrop; PhaseSprites = phaseSprites; Days = Phases.Sum(); StartDate = startDate; EndDate = endDate; }
public void SetWithinTimeRangeCondition(WorldDate startDate, WorldDate finishDate, bool hoursOnly) { conditionTypeSet = ConditionTypes.WithinTimeRange; if (worldDateRangeCondition == null) { worldDateRangeCondition = new WithinTimeRangeCondition(); } worldDateRangeCondition.Finish = finishDate; worldDateRangeCondition.Start = startDate; worldDateRangeCondition.HoursOnly = hoursOnly; if (!worldDateRangeCondition.ValidateParametres(hoursOnly)) { Debug.LogWarning("Incorrect parametres values! Start of the range should be earlier than it's finish"); } }
private static void ConsoleCommand(List <string> args) { try { WorldDate date = Utilities.ArgsToWorldDate(args); Prediction prediction = PredictForDate(date); Utilities.Monitor.Log($"On {prediction.effectiveDate}, the movie showing will be \"{prediction.currentMovie.Title}\". \"{prediction.currentMovie.Description}\"", LogLevel.Info); Utilities.Monitor.Log($"The Crane Game {(prediction.craneGameAvailable ? "WILL" : "will NOT")} be available.", LogLevel.Info); Utilities.Monitor.Log($"The next movie, \"{prediction.nextMovie.Title}\", will begin showing on {prediction.firstDateOfNextMovie}. \"{prediction.nextMovie.Description}\"", LogLevel.Info); } catch (Exception e) { Utilities.Monitor.Log(e.Message, LogLevel.Error); } }
public void AddCrop( IManifest manifest, string id, Item item, string name, int regrow, bool isGiantCrop, bool isPaddyCrop, bool isTrellisCrop, Item[] seeds, WorldDate start, WorldDate end, Tuple <Texture2D, Rectangle?, Color?, Texture2D, Rectangle?, Color?> sprite, Tuple <Texture2D, Rectangle?, Color?, Texture2D, Rectangle?, Color?> giantSprite, IReadOnlyCollection <int> phases, IReadOnlyCollection <Tuple <Texture2D, Rectangle?, Color?, Texture2D, Rectangle?, Color?> > phaseSprites ) { var provider = Mod.Crops.GetModProvider(manifest); provider !.AddCrop( id: id, item: item, name: name, sprite: sprite == null ? (item == null ? null : SpriteHelper.GetSprite(item)) : HydrateSprite(sprite), isTrellisCrop: isTrellisCrop, isGiantCrop: isGiantCrop, giantSprite: HydrateSprite(giantSprite), seeds: seeds, isPaddyCrop: isPaddyCrop, phases: phases, phaseSprites: HydrateSprites(phaseSprites), regrow: regrow, start: start, end: end ); }
protected TaskBase(string id, string name) { _id = id; _complete = false; _viewed = true; _index = 0; Name = name; Active = true; RenewPeriod = Period.Never; RenewDate = new WorldDate(1, "spring", 1); TargetDisplayName = string.Empty; TargetName = string.Empty; TargetIndex = -1; Variant = 0; Count = 0; MaxCount = 1; BasePrice = 0; }
public void AddCrop( IManifest manifest, string id, Item item, string name, int regrow, bool isGiantCrop, bool isPaddyCrop, bool isTrellisCrop, WorldDate start, WorldDate end, SpriteInfo sprite, SpriteInfo giantSprite, IReadOnlyCollection <int> phases, IReadOnlyCollection <SpriteInfo> phaseSprites ) { var provider = Mod.Crops.GetModProvider(manifest); provider !.AddCrop( id: id, item: item, name: name, sprite: sprite, isTrellisCrop: isTrellisCrop, isGiantCrop: isGiantCrop, giantSprite: giantSprite, seeds: null, isPaddyCrop: isPaddyCrop, phases: phases, phaseSprites: phaseSprites, regrow: regrow, start: start, end: end ); }
private void buildWorld(int x, int z) { this.x = x; this.z = z; Coordinates.setWorldSize(x, z); currentDate = new WorldDate(1, 1); herds = new List <Herd>(); tribes = new List <Tribe>(); doubleLayerGenerator = new LayerGenerator(x, z, ROUND_TO); intLayerGenerator = new LayerGenerator(x, z, 0); randy = new Random(); maxDiff = 0.0; tileArray = generateTileArray(); // Once the basic stats are generated - generate 20 years of weather // This finishes the rivers, and gives the data to generate the habitats. for (int year = 0; year < YEARS_TO_FULL_HABITAT_REGROWTH; year++) { generateYearOfWeather(year + 1); } }
// Lists the next several trains to arrive on or after the given date, // up to the given limit. public static List <Prediction> ListNextTrainsFromDate (WorldDate fromDate, uint limit) { Utilities.CheckWorldReady(); if (!IsAvailable) { throw new InvalidOperationException("The Railroad is not available."); } // Logic from StardewValley.Locations.Railroad.DayUpdate() // as implemented in Stardew Predictor by MouseyPounds. List <Prediction> predictions = new List <Prediction> (); for (int days = Math.Max(fromDate.TotalDays, 30); predictions.Count < limit && days < fromDate.TotalDays + Utilities.MaxHorizon; ++days) { Random rng = new Random(((int)Game1.uniqueIDForThisGame / 2) + days + 1); if (!(rng.NextDouble() < 0.2)) { continue; } int time = rng.Next(900, 1800); time -= time % 10; if (time % 100 >= 60) { continue; } WorldDate date = Utilities.TotalDaysToWorldDate(days); predictions.Add(new Prediction { date = date, time = time }); } return(predictions); }
public DatePicker(WorldDate initialDate, string promptMessage, Action <WorldDate> onConfirm) : base(X, Y, Width, Height) { this.initialDate = initialDate; date = initialDate; int initialYearStart = (this.initialDate.Year - 1) * 112; selectedDay = this.initialDate.TotalDays - initialYearStart; this.promptMessage = promptMessage; this.onConfirm = onConfirm; calendarTile = Helper.Content.Load <Texture2D> (Path.Combine("assets", "calendar.png")); dayButtonTiles = Helper.Content.Load <Texture2D> (Path.Combine("assets", "dayButton.png")); arrangeInterface(); }
public override bool ConditionTest() { switch (conditionTypeSet) { case ConditionTypes.AttributeCheck: return(attributeCheckCondition.ConditionTest()); case ConditionTypes.AttributeTest: return(attributeTestCondition.ConditionTest()); case ConditionTypes.SkillPossessed: return(skillPossessedCondition.ConditionTest()); case ConditionTypes.PlayerHasItem: return(playerHasItemCondition.ConditionTest()); case ConditionTypes.StoryStateHappened: return(storyStateHappenedCondition.ConditionTest()); case ConditionTypes.WithinTimeRange: return(WithinTimeRange.ConditionTest()); case ConditionTypes.WorldDate: return(WorldDate.ConditionTest()); case ConditionTypes.BackgroundRequired: return(BackgroundRequired.ConditionTest()); case ConditionTypes.PlayerHasMoney: return(PlayerHasMoney.ConditionTest()); case ConditionTypes.StatisticCheck: return(StatisticCheck.ConditionTest()); default: Debug.Log("Wtf, ConditionTest default"); return(false); } }
public void AddCrop( string id, Item item, string name, SpriteInfo?sprite, bool isTrellisCrop, bool isGiantCrop, SpriteInfo?giantSprite, Item[]?seeds, bool isPaddyCrop, IEnumerable <int> phases, IEnumerable <SpriteInfo?>?phaseSprites, int regrow, WorldDate start, WorldDate end ) { Crops[id] = new CropInfo( Id: id, Item: item, Name: name, Sprite: sprite, IsTrellisCrop: isTrellisCrop, IsGiantCrop: isGiantCrop, GiantSprite: giantSprite, Seeds: seeds, Phases: phases.ToArray(), PhaseSprites: phaseSprites?.ToArray(), Regrow: regrow, IsPaddyCrop: isPaddyCrop, StartDate: start, EndDate: end ); }
public static void NPC_engagementResponse_Postfix(NPC __instance, Farmer who, bool asRoommate = false) { Monitor.Log($"engagement response for {__instance.Name}"); if (asRoommate) { Monitor.Log($"{__instance.Name} is roomate"); return; } if (!who.friendshipData.ContainsKey(__instance.Name)) { Monitor.Log($"{who.Name} has no friendship data for {__instance.Name}", LogLevel.Error); return; } Friendship friendship = who.friendshipData[__instance.Name]; WorldDate weddingDate = new WorldDate(Game1.Date); weddingDate.TotalDays += Math.Max(1, Config.DaysUntilMarriage); while (!Game1.canHaveWeddingOnDay(weddingDate.DayOfMonth, weddingDate.Season)) { weddingDate.TotalDays++; } friendship.WeddingDate = weddingDate; }
public TimeCharacterAttribute(string name, decimal value, WorldDate endDate) { Name = name; EndDate = endDate; Value = value; }