private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (Context.IsWorldReady) { PlacedAugmentorsManager.Instance?.Update(); } }
static void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!StardewModdingAPI.Context.IsWorldReady) { return; } //TODO make noise for interactable objects/people/warps/... foreach (Character character in Game1.currentLocation.getCharacters()) { Vector2 charPos = character.Position; if (Utility.distance(charPos.X, Game1.player.Position.X, charPos.Y, Game1.player.Position.Y) < hearing_distance * Game1.tileSize) { PlaySoundEffect(sound_guitar, charPos); } } //TODO do this not only every second and better aligned with tiles, change sound int pX = (int)Game1.player.Position.X / Game1.tileSize; int pY = (int)Game1.player.Position.Y / Game1.tileSize; if (Game1.currentLocation is Farm farm && farm.isTileHoeDirt(new Vector2(pX, pY)) && farm.terrainFeatures[new Vector2(pX, pY)] is HoeDirt hoeDirt && hoeDirt.crop is Crop) { Game1.playSound("seeds"); } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!floorsList.Any()) { return; } Vector2 stairs = floorsList[config.FloorNames[0]].stairsStart; int x = (int)stairs.X; int y = (int)stairs.Y; Warp warp = new Warp(config.MainFloorStairsX + 1, config.MainFloorStairsY + 3, "MultipleFloors0", x + 1, y + 2, true, false); if (!Utility.getHomeOfFarmer(Game1.player).warps.Contains(warp)) { Utility.getHomeOfFarmer(Game1.player).warps.Add(warp); } warp.TargetName = "MultipleFloors0"; warp = new Warp(config.MainFloorStairsX + 2, config.MainFloorStairsY + 3, "MultipleFloors0", x + 2, y + 2, true, false); if (!Utility.getHomeOfFarmer(Game1.player).warps.Contains(warp)) { Utility.getHomeOfFarmer(Game1.player).warps.Add(warp); } warp.TargetName = "MultipleFloors0"; Helper.Events.GameLoop.OneSecondUpdateTicked -= GameLoop_OneSecondUpdateTicked; }
/// <summary> /// Update all music packs every second. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { foreach (MusicPack pack in MusicManager.MusicPacks.Values) { pack.update(); } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (this.dist != -1 && this.config.PrintToConsole) { this.Monitor.Log($"#Tiles from land: {this.dist}", LogLevel.Info); this.Monitor.Log($"Pixels from player: {this.dist2}", LogLevel.Info); } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { // Todo: check that player is not in menu/cutscene if (previousLocation == null) { previousLocation = Game1.player.getStandingPosition(); return; } // being in a menu / cutscene does not count as standing still // and it is only a challenge if the player can move if (previousLocation.Value.Equals(Game1.player.getStandingPosition())) { if (Context.IsPlayerFree) { standingStillForSeconds++; // Logger.Debug($"Standing still for {standingStillForSeconds} s"); previousLocation = Game1.player.getStandingPosition(); if (standingStillForSeconds >= Parameters.SecondsToStandStill) { if ((standingStillForSeconds - Parameters.SecondsToStandStill) % Parameters.RegenIntervalSeconds == 0) { int currValue = GetCurrentValue(Game1.player); int max = GetMaxValue(Game1.player); if (!Game1.player.isGlowing && currValue < max) { Game1.player.startGlowing(Parameters.GlowColor, false, 1 / 60.0f); } if (currValue < max) { Logger.Debug($"{AttributeName} regen +{Parameters.RegenAmount}"); SetCurrentValue(Game1.player, Math.Min(currValue + Parameters.RegenAmount, max)); } if (currValue >= max && Game1.player.isGlowing && Game1.player.glowingColor == Parameters.GlowColor) { Game1.player.stopGlowing(); } } } } } else { if (standingStillForSeconds > 0 && Game1.player.isGlowing && Game1.player.glowingColor == Parameters.GlowColor) { Game1.player.stopGlowing(); } standingStillForSeconds = 0; previousLocation = Game1.player.getStandingPosition(); } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!Context.IsWorldReady) { return; } Utils.CheckForInfection(); }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!config.EnableMod || config.RequireMetalDetectorSwing || !Context.IsPlayerFree || (config.RequireMetalDetector && Game1.player.CurrentTool?.Name != config.MetalDetectorID) || ++deltaTime < config.SecondsPerPoll) { return; } DoBlip(); }
void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (Game1.currentLocation == null || !Game1.player.hasPet() || GetPet() == null) { return; } switch (petState) { case PetState.Vanilla: break; case PetState.CatchingUp: case PetState.Waiting: case PetState.Retrieve: if (PlayerPetDistance() > catch_up_distance && Game1.currentLocation == pet.currentLocation) { CurrentPath = PathFinder.CalculatePath(pet, new Vector2(Game1.player.getTileX(), Game1.player.getTileY())); if (CurrentPath.Count > 0) { SetPetPositionFromTile(CurrentPath.Peek()); if (petState == PetState.Waiting) { SetState(PetState.CatchingUp); } } else { CannotReachPlayer(); } } TryChaseCritterInRange(); break; case PetState.Chasing: case PetState.Fetching: case PetState.WaitingToFetch: if (TimeOut()) { Log("timeout during " + petState); Confused(); SetState(PetState.Waiting); } break; } if (petState != PetState.Vanilla) { GetPet().CurrentBehavior = PetBehaviour; } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!Context.CanPlayerMove) { UpdateInteraction(false); return; } lock (_testlock) { if (_list.Count == 0 && !MessageIsShown && LastInteraction.AddSeconds(Config.IdleTime) <= DateTime.Now) { Game1.pauseThenMessage(250, Helper.Translation.Get("idle_text"), false); MessageIsShown = true; } } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { // Only fire after 1 sec. in-game. if (e.Ticks < 60) { return; } // And only fire once. Helper.Events.GameLoop.OneSecondUpdateTicked -= GameLoop_OneSecondUpdateTicked; // Create a warning message if patches failed to apply cleanly. if (broken_mods.Count == 0) { return; } var mod_list = new List <string>(); foreach (var i in broken_mods) { var mod = Helper.ModRegistry.Get(i).Manifest; mod_list.Add($"{mod.Name} (v{mod.Version})"); } // The message is a list containing a single string. var dialogue = new List <string>() { "StardewHack v" + ModManifest.Version + " failed to apply some bytecode patches. The following mods won't work correctly or at all: " + mod_list.Join() + ". Check your console or error log for further instructions." }; // Create the dialogue box. We can't pass a string directly as the signature differs between the PC and android version. var box = new StardewValley.Menus.DialogueBox(dialogue); StardewValley.Game1.activeClickableMenu = box; StardewValley.Game1.dialogueUp = true; box.finishTyping(); }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { Helper.Events.GameLoop.OneSecondUpdateTicked -= GameLoop_OneSecondUpdateTicked; }
void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!CanUpdatePet()) { return; } switch (petState) { case PetState.Vanilla: break; case PetState.CatchingUp: case PetState.Waiting: case PetState.Retrieve: if (petState == PetState.Waiting || !Compare(pet.Position, oldPetPos)) { oldPetPos = pet.Position; SetTimer(); } if (PlayerPetDistance() > catch_up_distance && Game1.currentLocation == pet.currentLocation) // && (CurrentPath == null || CurrentPath.Count == 0)) { var oldpath = CurrentPath; var path = PathFinder.CalculatePath(pet, new Vector2(Game1.player.getTileX(), Game1.player.getTileY())); //TODO use player.Position instead? CurrentPath = path; if (CurrentPath.Count > 0) { if (oldpath == null || oldpath.Count == 0) { SetPetPositionFromTile(CurrentPath.Peek()); //this sets the pet on a proper tile. This is only done if the pet starts moving //Log("Snapped pet position to first tile of current path"); } else { CurrentPath.Dequeue(); //if pet is already moving: remove first node. Otherwise the pet might be a few pixels ahead and tries to move back first. } if (petState == PetState.Waiting) { SetState(PetState.CatchingUp); } } else { CannotReachPlayer(); } } TryChaseCritterInRange(); if (TimeOut(60)) { Log("timeout during " + petState); Confused(); SetState(PetState.Waiting); } break; case PetState.Chasing: case PetState.Fetching: case PetState.WaitingToFetch: if (TimeOut()) { Log("timeout during " + petState); Confused(); SetState(PetState.Waiting); } break; } if (petState != PetState.Vanilla) { GetPet().CurrentBehavior = PetBehaviour; } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!Context.IsWorldReady || !Game1.player.IsMainPlayer || !(Game1.player.currentLocation is Farm) || thisWave == null) { return; } if (waveStarted) { if (Game1.getFarm().characters.Where(n => n is Monster).Count() >= Config.MaxSimultaneousMonsters) { if (waitingSeconds++ > 60) { ClearMonsters(); } return; } waitingSeconds = 0; if (thisWave.totalMonsters() <= 0) { thisWave = null; waveStarted = false; return; } Vector2[] spots = GetOpenSpots().ToArray(); spotIndex = 0; if (thisWave.slimes > 0) { Game1.getFarm().characters.Add(new GreenSlime(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.slimes--; } if (thisWave.bigSlimes > 0) { Game1.getFarm().characters.Add(new BigSlime(spots[spotIndex++] * Game1.tileSize, 40) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.bigSlimes--; } if (thisWave.bats > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.bats--; } if (thisWave.flies > 0) { Game1.getFarm().characters.Add(new Fly(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.flies--; } if (thisWave.dustSpirits > 0) { Game1.getFarm().characters.Add(new DustSpirit(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.dustSpirits--; } if (thisWave.shadowBrutes > 0) { Game1.getFarm().characters.Add(new ShadowBrute(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.shadowBrutes--; } if (thisWave.skeletons > 0) { Game1.getFarm().characters.Add(new Skeleton(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.skeletons--; } if (thisWave.shadowShamans > 0) { Game1.getFarm().characters.Add(new ShadowShaman(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.shadowShamans--; } if (thisWave.serpents > 0) { Game1.getFarm().characters.Add(new Serpent(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.serpents--; } if (thisWave.squidKids > 0) { Game1.getFarm().characters.Add(new SquidKid(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.squidKids--; } if (thisWave.dinos > 0) { Game1.getFarm().characters.Add(new DinoMonster(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.dinos--; } if (thisWave.skulls > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize, 77377)); spotIndex %= spots.Length; thisWave.skulls--; } if (thisWave.dolls > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize, -666)); spotIndex %= spots.Length; thisWave.dolls--; } } }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!IsModEnabled()) { return; } if (slimeFarmer) { if (!Config.SlimeEnabled || Game1.random.NextDouble() < 0.1) { slimeFarmer = false; } } else if (Config.SlimeEnabled) { slimeFarmer = Game1.random.NextDouble() < 0.01; if (slimeFarmer) { if (slime == null) { slime = new BigSlime(Game1.player.Position, 121); } } } if (backwardsFarmer) { if (!Config.BackwardsEnabled || Game1.random.NextDouble() < 0.1) { backwardsFarmer = false; } } else if (Config.BackwardsEnabled) { backwardsFarmer = Game1.random.NextDouble() < 0.008; } if (gianting) { if (Config.GiantEnabled || Game1.random.NextDouble() < 0.1) { gianting = false; } } else if (Config.GiantEnabled) { gianting = Game1.random.NextDouble() < 0.01; } if (asciifying) { if (!Config.AsciiEnabled || Game1.random.NextDouble() < 0.1) { asciifying = false; } } else if (pixelating) { if (!Config.PixelateEnabled || Game1.random.NextDouble() < 0.1) { pixelating = false; } } else { if (Config.PixelateEnabled) { pixelating = Game1.random.NextDouble() < 0.01; } if (!pixelating && Config.AsciiEnabled) { asciifying = Game1.random.NextDouble() < 0.008; } else { asciifying = false; } } if (!Config.BeesEnabled || beeDataList.Count > 30) { beeDataList.Clear(); } else if (Game1.random.NextDouble() < (beeDataList.Count + 1) / 30f) { beeDataList.Add(new BeeData() { pos = new Vector2(Game1.random.Next(Game1.viewport.Width), Game1.random.Next(Game1.viewport.Height)) }); } }
private void OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { CheckForEdits("OneSecondUpdateTicked"); }