/// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (Config.NotifyBirthdayReminder && e.NewTime == Config.BirthdayReminderTime) { generalNotification.DoBirthdayReminder(Helper.Translation); } }
private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (_currentEffect != Effect.Nighttime && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) { _fxOpacity = ModEntry.GetProgressFromEveningIntoNighttime(); } }
private static void CheckTimeChangedEvent_Changed(Chord chord) { object timeChangedSender = null; TimeChangedEventArgs timeChangedEventArgs = null; chord.TimeChanged += (sender, eventArgs) => { timeChangedSender = sender; timeChangedEventArgs = eventArgs; }; var lengthChangedFired = false; chord.LengthChanged += (_, __) => lengthChangedFired = true; var oldTime = chord.Time; chord.Time += 100; Assert.IsFalse(lengthChangedFired, "Length changed event fired."); Assert.AreSame(chord, timeChangedSender, "Sender is invalid."); Assert.IsNotNull(timeChangedEventArgs, "Event args is null."); Assert.AreEqual(oldTime, timeChangedEventArgs.OldTime, "Old time is invalid."); Assert.AreEqual(chord.Time, timeChangedEventArgs.NewTime, "New time is invalid."); Assert.AreNotEqual(oldTime, chord.Time, "New time is equal to old one."); }
/// <summary>The method invoked once the game clock has updated, this is used for checking if the player has passed out.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { var location = Game1.currentLocation; // ensure an NPC is in the area passed out in and that the time is passed 2am if (location.characters.Count == 0 || Game1.timeOfDay < 2600) { return; } HasPassoutBeenHandled = true; // pick a random NPC that is in that location and set as the mail sender NPC letterSender = location.characters[Game1.random.Next(location.characters.Count)]; // check if the player is in the NPC's home or not, this will determine what letter to send if (letterSender.DefaultMap == location.Name) { Game1.mailbox.Add("better10Hearts_" + letterSender.Name + "_Home"); } else { Game1.mailbox.Add("better10Hearts_" + letterSender.Name + "_Away"); } }
void OnMp3PlayerTimeChanged(object sender, TimeChangedEventArgs e) { if (timelist == null || timelist.Length == 0) { return; } var t = e.Current; if (isworking) { return; } isworking = true; var i = binarySearch(timelist, t, 0, timelist.Length - 1); isworking = false; if (i == -1) { return; } UIHelper.RunOnUI(() => { SelectedIndex = i; this.ScrollToCenterOfView(SelectedItem); }); }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { if (e.NewTime % 300 == 0) { this.manager.ChangeWavePattern(Game1.isDebrisWeather); } }
private static void CheckTimeChangedEvent_Changed(long initialTime) { var registeredParameters = GetParameters(); registeredParameters.ToList().ForEach(p => p.Time = initialTime); foreach (var registeredParameter in registeredParameters) { object timeChangedSender = null; TimeChangedEventArgs timeChangedEventArgs = null; registeredParameter.TimeChanged += (sender, eventArgs) => { timeChangedSender = sender; timeChangedEventArgs = eventArgs; }; var oldTime = registeredParameter.Time; registeredParameter.Time += 100; Assert.AreSame(registeredParameter, timeChangedSender, "Sender is invalid."); Assert.IsNotNull(timeChangedEventArgs, "Event args is null."); Assert.AreEqual(oldTime, timeChangedEventArgs.OldTime, "Old time is invalid."); Assert.AreEqual(registeredParameter.Time, timeChangedEventArgs.NewTime, "New time is invalid."); Assert.AreNotEqual(oldTime, registeredParameter.Time, "New time is equal to old one."); } }
private void AlarmClockSelection(object sender, TimeChangedEventArgs e) { AlarmClockReminder = Game1.getTrulyDarkTime(); if (Game1.timeOfDay == AlarmClockReminder - 200) { AlarmClockMessage = SunSettingDown; } else if (Game1.timeOfDay == AlarmClockReminder) { AlreadyAsked = false; AlarmClockMessage = SunSetDown; } else if (Game1.timeOfDay == 2200) { AlreadyAsked = false; AlarmClockMessage = GettingVeryLate; } if (Game1.timeOfDay >= (AlarmClockReminder - 200) && AlarmClockSet == false && Game1.player.currentLocation == Game1.getLocationFromName("FarmHouse") && Game1.timeOfDay < 2200 && AlreadyAsked == false) { AlarmClockDialogSetupEarly(); } else if (Game1.timeOfDay == 2200 && AlarmClockSet == false) { AlarmClockDialogSetupLate(); } }
/********* ** Private methods *********/ /// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { // check battery state if (!this.noBattery) { ObjectQuery query = new ObjectQuery("Select EstimatedChargeRemaining FROM Win32_Battery"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); ManagementObjectCollection col = searcher.Get(); if (col.Count == 0) { this.noBattery = true; } else if (!this.messageShown) //checking no Battery twice, cause of first run... { foreach (ManagementBaseObject mo in col) { foreach (PropertyData property in mo.Properties) { if (Convert.ToInt16(property.Value) < 25) { Game1.drawObjectDialogue(this.Helper.Translation.Get("message")); this.messageShown = true; } } } } } }
protected virtual void OnTimeChanged(TimeChangedEventArgs e) { if (TimeChanged != null) { TimeChanged(this, e); } }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { this.StateMachine.Companion.clearSchedule(); if (e.NewTime >= 2200) { NPC companion = this.StateMachine.Companion; Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetDialogueString(companion, "companionDismissAuto"), companion); this.dismissalDialogue = dismissalDialogue; this.StateMachine.Companion.doEmote(24); this.StateMachine.Companion.updateEmote(Game1.currentGameTime); DialogueHelper.DrawDialogue(dismissalDialogue); } MineShaft mines = this.StateMachine.Companion.currentLocation as MineShaft; // Fix spawn ladder if area is infested and all monsters is killed but NPC following us if (mines != null && mines.mustKillAllMonstersToAdvance()) { var monsters = from c in mines.characters where c.IsMonster select c; if (monsters.Count() == 0) { Vector2 vector2 = this.StateMachine.Reflection.GetProperty <Vector2>(mines, "tileBeneathLadder").GetValue(); if (mines.getTileIndexAt(Utility.Vector2ToPoint(vector2), "Buildings") == -1) { mines.createLadderAt(vector2, "newArtifact"); } } } }
private void OnTimeChange(object sender, TimeChangedEventArgs e) { // ignore if player hasn't loaded a save yet if (!Context.IsWorldReady) { return; } holdy.Clear(); ready_items.Clear(); //Monitor.Log($"{e.NewTime.ToString()} time changed.", LogLevel.Debug); foreach (GameLocation location in GetGameLocations()) { if ((location is FarmCave && cfg.showCaveItems) || (!(location is FarmCave) && !cfg.showCaveItems)) { if (location.IsFarm || location.IsGreenhouse) { OverlaidDictionary.ValuesCollection locationObjects = GetLocationObjects(location); CheckMachineItems(locationObjects); CheckCrops(location); if (cfg.showAnimalDroppings) { CheckAnimalDroppings(locationObjects); } } } } if (holdy.Count > 0) { ShowNotification(); } }
private void OnTimeChanged(object sender, TimeChangedEventArgs e) { CheckRottable(); UpdateTurnipPrice(); UpdateLastestTimeData(); DaisyMaeManager.TickUpdate(); }
private void timeChanged(object sender, TimeChangedEventArgs e) { int hourDiff = e.NewTime / 100 - e.NewTime / 100; int minDiff = e.NewTime % 100 - e.OldTime % 100; if (minDiff != 10 && (hourDiff != 1 && minDiff != -50)) { return; } Game1.player.UseFullness(Config.DrainPer10Min); if (Game1.player.GetFullness() <= 0) { Game1.player.takeDamage(Config.StarvationDamagePer10Min, true, null); if (Game1.player.health <= 0) { Log.trace("Player starved to death, resetting hunger"); if (Config.NegativeBuffThreshold != 0) { Game1.player.UseFullness(-Config.NegativeBuffThreshold); } else { Game1.player.UseFullness(-25); // Just incase they set the negative buff threshold to 0 } } } }
/// <summary> /// Update table of NPCs who have "recently" given conversation topic dialogue. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onTimeChanged(object sender, TimeChangedEventArgs e) { int currentTime = e.NewTime; int intTimeLimit = HOURS_CONSIDERED_RECENT * 100; List <string> toDelete = new List <string>(); foreach (KeyValuePair <string, int> speaker in RecentTopicSpeakers) { if (Math.Abs(currentTime - speaker.Value) >= intTimeLimit) { toDelete.Add(speaker.Key); } } int count = 0; foreach (string npc in toDelete) { RecentTopicSpeakers.Remove(npc); count++; } if (Config.DebugMode) { Monitor.Log($"Cleared {count} NPCs from RecentTopicSpeakers.", LogLevel.Debug); } }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { // ignore if the screenshot had been captured or the player is not in farm if (isScreenshottedToday || !nowInFarm) { return; } string fullName = takeMapscreenshot.Invoke <string>(scale, screenshot_name, null); if (fullName != null) { // take screenshot addMessage.Invoke("Saved screenshot as '" + fullName + "'.", Color.Green); isScreenshottedToday = true; } else { if (tryTimes++ > 3) { isScreenshottedToday = true; addMessage.Invoke("Failed taking screenshot over 3 times, won't try agian today!", Color.Red); } else { addMessage.Invoke("Failed taking screenshot!", Color.Red); } } }
private void TimeChanged(object sender, TimeChangedEventArgs e) { OurFog.UpdateWeather(); if (!Context.IsMainPlayer) { return; } if (OurFog.IsWeatherVisible) { return; } if (Game1.isFestival()) { return; } if ((FogToday && Game1.timeOfDay <= Utility.ModifyTime(Game1.getStartingToGetDarkTime(), -100) && Randoms.NextDouble() <= ModOptions.EveningWeatherFogChance) || ((Randoms.NextDouble() <= ModOptions.EveningWeatherFogChance / 4) && Game1.timeOfDay <= Utility.ModifyTime(Game1.getStartingToGetDarkTime(), -100)) && Game1.timeOfDay > 1500) { Monitor.Log("Firing off evening fog chance", LogLevel.Info); //evening fog var numTime = Randoms.Next(60, 190); numTime = ClampTimeToTens(numTime); var startTime = Game1.getStartingToGetDarkTime(); var endTime = Utility.ModifyTime(Game1.getTrulyDarkTime(), numTime); var todayType = FogType.Normal; OurFog.CreateWeather(todayType, true); OurFog.SetWeatherTime(startTime, endTime); SendFogMessage(todayType, startTime, endTime); FogToday = false; } }
private void TimeEvents_TimeChanged(object sender, TimeChangedEventArgs e) { StardewValley.Farmer player = Game1.player; bool allowAccess = this.location == "FarmHouse" || this.location == "Cabin"; if (Context.IsWorldReady == false || allowAccess == false || player.Stamina >= (float)player.MaxStamina) { return; } float currentPercentage = (player.Stamina / player.MaxStamina) * 100; float multiplicator = 0; if (currentPercentage < 20 || currentPercentage >= 80) { multiplicator = 0.05f; } else { multiplicator = 0.1f; } int staminaToGive = (int)Math.Round(player.MaxStamina * multiplicator, MidpointRounding.AwayFromZero); if ((player.Stamina + staminaToGive) > player.MaxStamina) { staminaToGive = (int)Math.Floor(player.MaxStamina - player.stamina); } player.Stamina += staminaToGive; }
/// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (!Game1.hasLoadedGame) { return; } if (!Context.IsMainPlayer) { return; } Conditions.TenMinuteUpdate(); if (Game1.currentLocation.IsOutdoors && Conditions.HasWeather(CurrentWeather.Lightning) && !Conditions.HasWeather(CurrentWeather.Rain) && Game1.timeOfDay < 2400) { Utility.performLightningUpdate(Game1.timeOfDay); } //queued messages clear if (Game1.timeOfDay == 610 && queuedMsg != null) { Game1.hudMessages.Add(queuedMsg); queuedMsg = null; } WeatherProcessing.ProcessHazardousCropWeather(Conditions, Game1.timeOfDay, Dice); ClimatesOfFerngill.WindOverrideSpeed = 0f; //reset once time has passed. }
private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (!this.IsFishing) { return; } if (Game1.random.Next(3) == 1) { SObject fish = this.fisher.currentLocation.getFish(200, 1, this.farmer.FishingLevel / 2, this.farmer, 4.5d, Vector2.Zero); if (fish == null || fish.ParentSheetIndex <= 0) { fish = new SObject(Game1.random.Next(167, 173), 1, false, -1, 0); } if (fish.Category == -20 || fish.ParentSheetIndex == 152 || fish.ParentSheetIndex == 153 || fish.ParentSheetIndex == 157 || fish.ParentSheetIndex == 797 || fish.ParentSheetIndex == 79) { fish = new SObject(Game1.random.Next(167, 173), 1, false, -1, 0); } if (fish.Category != -20 && fish.ParentSheetIndex != 152 && fish.ParentSheetIndex != 153 && fish.ParentSheetIndex != 157 && fish.ParentSheetIndex != 797 && fish.ParentSheetIndex != 79) { int skill = this.farmer.fishingLevel.Value; int addedSkill = this.farmer.addedFishingLevel.Value; int quality = 0; float skillPower = (skill * 0.01f + addedSkill * 0.001f + (float)this.farmer.DailyLuck) * this.GetSkillMultiplier(); // There are chance to miss a fish. Depends on farmer's fishing skill and luck if (Game1.random.NextDouble() < 0.2f - Math.Min(skill * 0.01 - this.farmer.DailyLuck * 2, 0.18f) - skillPower / 4) { var bbox = this.fisher.GetBoundingBox(); this.Invicibility += 1000; this.fisher.currentLocation.debris.Add(new Debris("Miss", 1, new Vector2((float)bbox.Center.X, (float)bbox.Center.Y), Color.Yellow, 1f, 0f)); return; } if (skill >= 8 && Game1.random.NextDouble() < .01f + skillPower) { quality = 4; } else if (skill >= 6 && Game1.random.NextDouble() < 0.1f + skillPower) { quality = 2; } else if (skill >= 2 && Game1.random.NextDouble() < 0.2f + skillPower) { quality = 1; } fish.Quality = quality; this.fishCaught.Push(fish); this.Invicibility += 2000 - Math.Min(this.fishCaught.Count + 100, 2000); } this.lastCaughtFishIdx = fish.ParentSheetIndex; this.fishCaughtTimer = 3000; this.Invicibility += 1000; } }
/// <summary> /// Will check everytime the time changes for checking where the player has passed out at and if there are any NPC in the area /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Events_TimeChanged(object sender, TimeChangedEventArgs e) { // Get to current location to check the NPCs against var location = Game1.currentLocation; // Make sure an NPC is in the area passed out in and that the time is 2am + if (location.characters.Count == 0 || Game1.timeOfDay < 2600) { return; } // Make sure to set the passout as being handled so the game doesn't handle it HasPassoutBeenHandled = true; // Pick a random NPC that is in that location and set as the mail sender NPC letterSender = location.characters[new Random().Next(location.characters.Count)]; // Check if the player is in the NPC's home or not if (letterSender.DefaultMap == location.Name) { // Send the player mail from that NPC as if they are at home Game1.mailbox.Add("better10Hearts_" + letterSender.Name + "_Home"); } else { // Send the player mail from that NPC as if they are away from home Game1.mailbox.Add("better10Hearts_" + letterSender.Name + "_Away"); } }
//track player position for fox statue private static void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (!Game1.player.eventsSeen.Contains(UNSEALEVENT)) { return; } int distance = Math.Abs(Game1.player.getTileX() - 18) + Math.Abs(Game1.player.getTileY() - 10); if (distance < 3) { FoxStatueCounter.Value += 1; } else { FoxStatueCounter.Value = 0; } if (FoxStatueCounter.Value >= 12) { SpawnJAItemAsDebris("Relic Fox Mask", 18, 10, Game1.getLocationFromName("Custom_Ridgeside_Ridge")); Game1.player.mailReceived.Add(FLAGFOXMASK); FoxStatueCounter.Value = 0; Helper.Events.GameLoop.TimeChanged -= OnTimeChanged; OnFoxStatueMap = false; } }
/// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (Game1.timeOfDay == OurMoon.GetMoonRiseTime() && Game1.timeOfDay > 0600 && ModConfig.ShowMoonPhase) { Game1.addHUDMessage(new TCHUDMessage( Helper.Translation.Get("moon-text.moonrise", new { moonPhase = OurMoon.DescribeMoonPhase(), moonSet = OurMoon.GetMoonSetTime() }), OurMoon.CurrentPhase())); } if (Game1.timeOfDay == OurMoon.GetMoonSetTime() && ModConfig.ShowMoonPhase) { Game1.addHUDMessage(new TCHUDMessage(Helper.Translation.Get("moon-text.moonset", new { moonPhase = OurMoon.DescribeMoonPhase() }), OurMoon.CurrentPhase())); } if (OurMoon.IsEclipse) { Game1.globalOutdoorLighting = .5f; Game1.ambientLight = nightColor; Game1.currentLocation.switchOutNightTiles(); ResetTicker = 1; if (!Game1.currentLocation.IsOutdoors && Game1.currentLocation is DecoratableLocation) { var loc = Game1.currentLocation as DecoratableLocation; foreach (Furniture f in loc.furniture) { if (f.furniture_type.Value == Furniture.window) { Helper.Reflection.GetMethod(f, "addLights").Invoke(Game1.currentLocation); } } } if ((Game1.farmEvent == null && Game1.random.NextDouble() < (0.25 - Game1.player.team.AverageDailyLuck() / 2.0)) && Game1.spawnMonstersAtNight && Context.IsMainPlayer) { if (ModConfig.Verbose) { Monitor.Log("Spawning a monster, or attempting to.", LogLevel.Debug); } if (Game1.random.NextDouble() < 0.25) { if (Game1.currentLocation.IsFarm) { Game1.getFarm().spawnFlyingMonstersOffScreen(); return; } } else { Game1.getFarm().spawnGroundMonsterOffScreen(); } } } //moon 10-minute OurMoon.TenMinuteUpdate(); }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { if (!Context.IsWorldReady || !Context.IsMainPlayer || !config.Enabled || !config.UseOldMethod) return; if (e.NewTime > config.TimeFreezesAt) Game1.timeOfDay = config.TimeFreezesAt; }
protected void OnTimeChanged(int tick) { if (this.TimeChangedEvent != null) { var args = new TimeChangedEventArgs(tick); this.TimeChangedEvent(this, args); // eventa ni preprasta dirketno kam methoda da se izpalni } }
protected void OnTimeChanged(int tick) { if (TimeChanged != null) { TimeChangedEventArgs args = new TimeChangedEventArgs(tick); TimeChanged(this, args); } }
private TimeChangedEventArgs OnTimeChanged(string time) { TimeChangedEventArgs args = new TimeChangedEventArgs(time); OnTimeChanged(args); return(args); }
private TimeChangedEventArgs OnTimeChangedForOut() { TimeChangedEventArgs args = new TimeChangedEventArgs(); OnTimeChanged(args); return(args); }
private void OnTimeChanged(object sender, TimeChangedEventArgs e) { BarsUpdate.UpdateBarsInformation(); BarsUpdate.CalculatePercentage(); BarsWarnings.VerifyStatus(); Penalty.VerifyPenalty(); NetController.Sync(); }
/// <summary>Raised after the in-game clock time changes.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnTimeChanged(object sender, TimeChangedEventArgs e) { if (e.NewTime == OneTimeReminder || e.NewTime == RecurringReminder) { Game1.addHUDMessage(new HUDMessage($"Reminder: it is {e.NewTime}", Color.OrangeRed, 8450f)); OneTimeReminder = 0; } }
private void onTimeChanged(object _sender, TimeChangedEventArgs _e) { if (chooser != null && currentMonsters != null) { cleanUpMonsters(); spawnCropbeast(); } }
public void ChangeTime(DateTime date, int hour) { EventHandler<TimeChangedEventArgs> handler = TimeChanged; if (handler != null) { TimeChangedEventArgs arg = new TimeChangedEventArgs(); arg.Date = date; arg.Hour = hour; handler(this, arg); } Date = date; Hour = hour; }
private static void TimeChangedMethod(object sender, TimeChangedEventArgs eventArgs) { Console.WriteLine("{0}! Ticks left = {1}", sender.GetType().Name, eventArgs.TicksLeft); }
//Event Handler public static void timerTimeChanged(object sender, TimeChangedEventArgs e) { Console.WriteLine("Seconds left: " + e.SecondsChanged); }
private static void Timer_TimeChanged(object sender, TimeChangedEventArgs eventArgs) { Console.WriteLine("Timer! Ticks left = {0}", eventArgs.TicksLeft); }