public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { if (!who.bathingClothes && who.IsLocalPlayer && !who.onBridge.Value) { indexOfMenuItemView.Value = 2; base.CurrentParentTileIndex = 2; for (int j = 0; j < 12; j++) { Game1.multiplayer.broadcastSprites(who.currentLocation, new TemporaryAnimatedSprite(354, Game1.random.Next(25, 75), 6, 1, new Vector2(Game1.random.Next((int)who.position.X - 256, (int)who.position.X + 192), Game1.random.Next((int)who.position.Y - 256, (int)who.position.Y + 192)), flicker: false, (Game1.random.NextDouble() < 0.5) ? true : false)); } location.playSound("wand"); Game1.displayFarmer = false; who.temporarilyInvincible = true; who.temporaryInvincibilityTimer = -2000; who.Halt(); who.faceDirection(2); who.CanMove = false; who.freezePause = 2000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(wandWarpForReal, 1000); new Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, 64, 64).Inflate(192, 192); int i = 0; for (int xTile = who.getTileX() + 8; xTile >= who.getTileX() - 8; xTile--) { Game1.multiplayer.broadcastSprites(who.currentLocation, new TemporaryAnimatedSprite(6, new Vector2(xTile, who.getTileY()) * 64f, Color.White, 8, flipped: false, 50f) { layerDepth = 1f, delayBeforeAnimationStart = i * 25, motion = new Vector2(-0.25f, 0f) }); i++; } base.CurrentParentTileIndex = base.IndexOfMenuItemView; } }
// Token: 0x0600093E RID: 2366 RVA: 0x000C8898 File Offset: 0x000C6A98 public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { this.indexOfMenuItemView = 2; base.CurrentParentTileIndex = 2; if (who.IsMainPlayer) { for (int i = 0; i < 12; i++) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, (float)Game1.random.Next(25, 75), 6, 1, new Vector2((float)Game1.random.Next((int)who.position.X - Game1.tileSize * 4, (int)who.position.X + Game1.tileSize * 3), (float)Game1.random.Next((int)who.position.Y - Game1.tileSize * 4, (int)who.position.Y + Game1.tileSize * 3)), false, Game1.random.NextDouble() < 0.5)); } Game1.playSound("wand"); Game1.displayFarmer = false; Game1.player.Halt(); Game1.player.faceDirection(2); Game1.player.freezePause = 1000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(this.wandWarpForReal), 1000); Rectangle r = new Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, Game1.tileSize, Game1.tileSize); r.Inflate(Game1.tileSize * 3, Game1.tileSize * 3); int j = 0; for (int xTile = who.getTileX() + 8; xTile >= who.getTileX() - 8; xTile--) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2((float)xTile, (float)who.getTileY()) * (float)Game1.tileSize, Color.White, 8, false, 50f, 0, -1, -1f, -1, 0) { layerDepth = 1f, delayBeforeAnimationStart = j * 25, motion = new Vector2(-0.25f, 0f) }); j++; } } base.CurrentParentTileIndex = this.indexOfMenuItemView; }
public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { base.DoFunction(location, x, y, power, who); who.Stamina = who.Stamina - ((float)(2 * power) - (float)who.ForagingLevel * 0.1f); int tileX = x / Game1.tileSize; int tileY = y / Game1.tileSize; Rectangle rectangle = new Rectangle(tileX * Game1.tileSize, tileY * Game1.tileSize, Game1.tileSize, Game1.tileSize); Vector2 index1 = new Vector2((float)tileX, (float)tileY); if (location.map.GetLayer("Buildings").Tiles[tileX, tileY] != null) { PropertyValue propertyValue = (PropertyValue)null; location.map.GetLayer("Buildings").Tiles[tileX, tileY].TileIndexProperties.TryGetValue("TreeStump", out propertyValue); if (propertyValue != null) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Axe.cs.14023")); return; } } location.performToolAction((Tool)this, tileX, tileY); if (location.terrainFeatures.ContainsKey(index1) && location.terrainFeatures[index1].performToolAction((Tool)this, 0, index1, (GameLocation)null)) { location.terrainFeatures.Remove(index1); } Rectangle boundingBox; if (location.largeTerrainFeatures != null) { for (int index2 = location.largeTerrainFeatures.Count - 1; index2 >= 0; --index2) { boundingBox = location.largeTerrainFeatures[index2].getBoundingBox(); if (boundingBox.Intersects(rectangle) && location.largeTerrainFeatures[index2].performToolAction((Tool)this, 0, index1, (GameLocation)null)) { location.largeTerrainFeatures.RemoveAt(index2); } } } Vector2 index3 = new Vector2((float)tileX, (float)tileY); if (!location.Objects.ContainsKey(index3) || location.Objects[index3].Type == null || !location.Objects[index3].performToolAction((Tool)this)) { return; } if (location.Objects[index3].type.Equals("Crafting") && location.Objects[index3].fragility != 2) { List <Debris> debris1 = location.debris; int objectIndex = location.Objects[index3].bigCraftable ? -location.Objects[index3].ParentSheetIndex : location.Objects[index3].ParentSheetIndex; Vector2 toolLocation = who.GetToolLocation(false); boundingBox = who.GetBoundingBox(); double x1 = (double)boundingBox.Center.X; boundingBox = who.GetBoundingBox(); double y1 = (double)boundingBox.Center.Y; Vector2 playerPosition = new Vector2((float)x1, (float)y1); Debris debris2 = new Debris(objectIndex, toolLocation, playerPosition); debris1.Add(debris2); } location.Objects[index3].performRemoveAction(index3, location); location.Objects.Remove(index3); }
public override IActiveEffect OnCast(Farmer player, int level, int targetX, int targetY) { player.position.X = targetX - player.GetBoundingBox().Width / 2; player.position.Y = targetY - player.GetBoundingBox().Height / 2; player.LocalSound("powerup"); player.AddCustomSkillExperience(Magic.Skill, 4); return(null); }
public override IActiveEffect onCast(Farmer player, int level, int targetX, int targetY) { Log.debug($"{player.Name} cast Blink."); player.position.X = targetX - player.GetBoundingBox().Width / 2; player.position.Y = targetY - player.GetBoundingBox().Height / 2; Game1.playSound("powerup"); player.addMagicExp(5); return(null); }
public override bool performAction(string action, Farmer who, Location tileLocation) { if (action != null && action == "FarmObelisk") { for (int i = 0; i < 12; i++) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, Game1.random.Next(25, 75), 6, 1, new Vector2(Game1.random.Next((int)who.Position.X - 256, (int)who.Position.X + 192), Game1.random.Next((int)who.Position.Y - 256, (int)who.Position.Y + 192)), flicker: false, (Game1.random.NextDouble() < 0.5) ? true : false)); } who.currentLocation.playSound("wand"); Game1.displayFarmer = false; Game1.player.temporarilyInvincible = true; Game1.player.temporaryInvincibilityTimer = -2000; Game1.player.freezePause = 1000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(delegate { if (Game1.whichFarm == 5) { Game1.warpFarmer("Farm", 48, 39, flip: false); } else if (Game1.whichFarm == 6) { Game1.warpFarmer("Farm", 82, 29, flip: false); } else { Game1.warpFarmer("Farm", 48, 7, flip: false); } Game1.fadeToBlackAlpha = 0.99f; Game1.screenGlow = false; Game1.player.temporarilyInvincible = false; Game1.player.temporaryInvincibilityTimer = 0; Game1.displayFarmer = true; }, 1000); new Microsoft.Xna.Framework.Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, 64, 64).Inflate(192, 192); int j = 0; for (int x = who.getTileX() + 8; x >= who.getTileX() - 8; x--) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(x, who.getTileY()) * 64f, Color.White, 8, flipped: false, 50f) { layerDepth = 1f, delayBeforeAnimationStart = j * 25, motion = new Vector2(-0.25f, 0f) }); j++; } return(true); } return(base.performAction(action, who, tileLocation)); }
internal static void TeleportPlayerToDestination(string destinationName, Vector2 destinationTile) { Farmer who = Game1.player; GameLocation obeliskLocation = Game1.getLocationFromName(destinationName); for (int i = 0; i < 12; i++) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, Game1.random.Next(25, 75), 6, 1, new Vector2(Game1.random.Next((int)who.position.X - 256, (int)who.position.X + 192), Game1.random.Next((int)who.position.Y - 256, (int)who.position.Y + 192)), flicker: false, (Game1.random.NextDouble() < 0.5) ? true : false)); } who.currentLocation.playSound("wand"); Game1.displayFarmer = false; who.temporarilyInvincible = true; who.temporaryInvincibilityTimer = -2000; who.Halt(); who.faceDirection(2); who.CanMove = false; who.freezePause = 2000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(delegate { Game1.warpFarmer(obeliskLocation.NameOrUniqueName, (int)destinationTile.X, (int)destinationTile.Y, flip: false); if (!Game1.isStartingToGetDarkOut() && !Game1.isRaining) { Game1.playMorningSong(); } else { Game1.changeMusicTrack("none"); } Game1.fadeToBlackAlpha = 0.99f; Game1.screenGlow = false; who.temporarilyInvincible = false; who.temporaryInvincibilityTimer = 0; Game1.displayFarmer = true; who.CanMove = true; }, 1000); new Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, 64, 64).Inflate(192, 192); int j = 0; for (int xTile = who.getTileX() + 8; xTile >= who.getTileX() - 8; xTile--) { obeliskLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(xTile, who.getTileY()) * 64f, Color.White, 8, flipped: false, 50f) { layerDepth = 1f, delayBeforeAnimationStart = j * 25, motion = new Vector2(-0.25f, 0f) }); j++; } }
public void Move(int dColumn, int dRow) { // Face in the specified direction if (dRow < 0) { farmer.faceDirection(0); } else if (dRow > 0) { farmer.faceDirection(2); } else if (dColumn < 0) { farmer.faceDirection(3); } else if (dColumn > 0) { farmer.faceDirection(1); } // make sure the terrain in that direction isn't blocked Vector2 newTile = farmer.getTileLocation() + new Vector2(dColumn, dRow); var location = currentLocation; { // How to detect walkability in pretty much the same way as other characters: var newBounds = farmer.GetBoundingBox(); newBounds.X += dColumn * 64; newBounds.Y += dRow * 64; bool coll = location.isCollidingPosition(newBounds, Game1.viewport, isFarmer: false, 0, glider: false, farmer); if (coll) { //Debug.Log("Colliding position: " + newBounds); return; } } // start moving targetPos = newTile * 64; // Do collision actions (shake the grass, etc.) if (location.terrainFeatures.ContainsKey(newTile)) { //Rectangle posRect = new Rectangle((int)position.X-16, (int)position.Y-24, 32, 48); var feature = location.terrainFeatures[newTile]; var posRect = feature.getBoundingBox(newTile); feature.doCollisionAction(posRect, 4, newTile, null, location); } }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onUpdateTicked(object sender, UpdateTickedEventArgs e) { if (player.yJumpVelocity == 0 && prevJumpVel < 0) { player.canMove = true; events.GameLoop.UpdateTicked -= onUpdateTicked; } else { int tx = (int)player.position.X / Game1.tileSize; int ty = (int)player.position.Y / Game1.tileSize; int ox = 0, oy = 0; // Offset x, y switch (player.facingDirection.Value) { case Game1.up: oy = -1; break; case Game1.down: oy = 1; break; case Game1.left: ox = -1; break; case Game1.right: ox = 1; break; } var bb = player.GetBoundingBox(); var bb1 = player.GetBoundingBox(); bb1.X += ox * Game1.tileSize; bb1.Y += oy * Game1.tileSize; var bb2 = player.GetBoundingBox(); bb2.X += ox * Game1.tileSize * 2; bb2.Y += oy * Game1.tileSize * 2; bool n0 = player.currentLocation.isCollidingPosition(bb, Game1.viewport, true, 0, false, player); bool n1 = player.currentLocation.isCollidingPosition(bb1, Game1.viewport, true, 0, false, player); bool n2 = player.currentLocation.isCollidingPosition(bb2, Game1.viewport, true, 0, false, player); //Log.trace($"{n0} {n1} {n2}"); if (n0 || (!n0 && n1 && !n2) /*|| wasGoingOver*/) { //wasGoingOver = true; Game1.player.canMove = false; player.position.X += ox * 5; player.position.Y += oy * 5; } } prevJumpVel = player.yJumpVelocity; }
public static void TryToggleGate(Farmer player) { foreach (Fence fence in Util.GetObjectsWithin <Fence>(2).Where(f => f.isGate.Value)) { Vector2 loc = fence.TileLocation; bool?isUpDown = IsUpsideDown(fence); if (isUpDown == null) { if (!fence.getBoundingBox(loc).Intersects(player.GetBoundingBox())) { fence.gatePosition.Value = 0; } continue; } int gatePosition = fence.gatePosition.Value; bool flag = IsPlayerInClose(player, fence, fence.TileLocation, isUpDown); if (flag && gatePosition == 0) { fence.gatePosition.Value = 88; Game1.playSound("doorClose"); } else if (!flag && gatePosition >= 88) { fence.gatePosition.Value = 0; Game1.playSound("doorClose"); } } }
public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { this.currentParentTileIndex = 12; this.indexOfMenuItemView = 12; bool flag = false; Rectangle value = new Rectangle(location.orePanPoint.X * Game1.tileSize - Game1.tileSize, location.orePanPoint.Y * Game1.tileSize - Game1.tileSize, Game1.tileSize * 4, Game1.tileSize * 4); if (value.Contains(x, y) && Utility.distance((float)who.getStandingX(), (float)value.Center.X, (float)who.getStandingY(), (float)value.Center.Y) <= (float)(3 * Game1.tileSize)) { flag = true; } who.lastClick = Vector2.Zero; x = (int)who.GetToolLocation(false).X; y = (int)who.GetToolLocation(false).Y; who.lastClick = new Vector2((float)x, (float)y); Point arg_DD_0 = location.orePanPoint; if (!location.orePanPoint.Equals(Point.Zero)) { Rectangle boundingBox = who.GetBoundingBox(); if (flag || boundingBox.Intersects(value)) { who.faceDirection(2); who.FarmerSprite.animateOnce(303, 50f, 4); return(true); } } who.forceCanMove(); return(true); }
public override bool beginUsing(GameLocation location, int x, int y, Farmer who) { base.CurrentParentTileIndex = 12; base.IndexOfMenuItemView = 12; bool overrideCheck = false; Rectangle orePanRect = new Rectangle(location.orePanPoint.X * 64 - 64, location.orePanPoint.Y * 64 - 64, 256, 256); if (orePanRect.Contains(x, y) && Utility.distance(who.getStandingX(), orePanRect.Center.X, who.getStandingY(), orePanRect.Center.Y) <= 192f) { overrideCheck = true; } who.lastClick = Vector2.Zero; x = (int)who.GetToolLocation().X; y = (int)who.GetToolLocation().Y; who.lastClick = new Vector2(x, y); if (location.orePanPoint != null && !location.orePanPoint.Equals(Point.Zero)) { Rectangle panRect = who.GetBoundingBox(); if (overrideCheck || panRect.Intersects(orePanRect)) { who.faceDirection(2); who.FarmerSprite.animateOnce(303, 50f, 4); return(true); } } who.forceCanMove(); return(true); }
internal void fixPlayerHouseWarp(StardewModdingAPI.Events.WarpedEventArgs e) { Farmer farmer = e.Player; FarmHouse house = (e.NewLocation as FarmHouse); //if(e.OldLocation is Farm) //{ // if (farmer.getTileLocationPoint() == house.getEntryLocation() || new Point(farmer.getTileLocationPoint().X, farmer.getTileLocationPoint().Y - 1) == house.getEntryLocation()) // { // Logger.Log("Player warped to the farmhouse, and was in the entry location. Setting player to modded entry (if any)..."); // Point entryPoint = FarmHouseStates.getEntryLocation(house); // farmer.setTileLocation(new Vector2(entryPoint.X, entryPoint.Y)); // } //} if (e.OldLocation is Cellar) { if (farmer.getTileLocationPoint() == new Point(4, 25) || farmer.getTileLocationPoint() == new Point(5, 24)) { Logger.Log("Player warped to the farmhouse from the cellar, and was in the cellar return location. Setting player to modded cellar return (if any)..."); Point cellarPoint = FarmHouseStates.getCellarLocation(house); if (cellarPoint != new Point(-1, -1)) { //farmer.setTileLocation(new Vector2(cellarPoint.X, cellarPoint.Y)); farmer.position.Value = new Vector2(cellarPoint.X * 64f, cellarPoint.Y * 64f); Logger.Log("Set player to " + cellarPoint.X + ", " + cellarPoint.Y); } } else { Logger.Log("Player warped to the farmhouse from the cellar, but was not in the cellar return location. Player was at " + farmer.getTileLocationPoint().X + ", " + farmer.getTileLocationPoint().Y); } } if (farmer.getTileLocationPoint() == house.getEntryLocation()) { Logger.Log("Player warped to the farmhouse, and was in the entry location. Setting player to modded entry (if any)..."); Point entryPoint = FarmHouseStates.getEntryLocation(house); farmer.position.Value = new Vector2(entryPoint.X * 64f, entryPoint.Y * 64f); //farmer.setTileLocation(new Vector2()); } else { Logger.Log("Player warped to the farmhouse, but was not at the entry location! Player is at " + farmer.getTileLocationPoint().ToString() + " as a point, and " + farmer.getTileLocation().ToString() + " as a Vector2" + ", not the entry location " + house.getEntryLocation().ToString()); Logger.Log("Player warped from " + e.OldLocation.name + "."); Logger.Log("House upgrade level is " + house.upgradeLevel + "."); if (FarmHouseStates.getState(house).entryData != null) { Logger.Log("House entry data is " + FarmHouseStates.getState(house).entryData); } else { Logger.Log("House entry data not initialized!"); } Logger.Log("Player physical centerpoint is (" + farmer.GetBoundingBox().Center.X + ", " + farmer.GetBoundingBox().Bottom + "), with a bounding box of " + farmer.GetBoundingBox().ToString()); } if (house is Cabin) { fixWarps(house as Cabin); } }
public bool Update(GameTime time, GameLocation location) { if (Game1.IsMasterGame) { position.X += (float)time.ElapsedGameTime.Milliseconds * speed; } wheelRotation += (float)time.ElapsedGameTime.Milliseconds * ((float)Math.PI / 256f); wheelRotation %= (float)Math.PI * 2f; if (!Game1.eventUp && location.Equals(Game1.currentLocation)) { Farmer player = Game1.player; if (player.GetBoundingBox().Intersects(getBoundingBox())) { player.xVelocity = 8f; player.yVelocity = (float)(getBoundingBox().Center.Y - player.GetBoundingBox().Center.Y) / 4f; player.takeDamage(20, overrideParry: true, null); if (player.UsingTool) { Game1.playSound("clank"); } } } if (Game1.random.NextDouble() < 0.001 && location.Equals(Game1.currentLocation)) { Game1.playSound("trainWhistle"); whistleSteam = new TemporaryAnimatedSprite(27, new Vector2(position.X - 250f, 2624f), Color.White, 8, flipped: false, 100f, 0, 64, 1f, 64); } if (whistleSteam != null) { whistleSteam.Position = new Vector2(position.X - 258f, 2592f); if (whistleSteam.update(time)) { whistleSteam = null; } } smokeTimer -= time.ElapsedGameTime.Milliseconds; if (smokeTimer <= 0f) { location.temporarySprites.Add(new TemporaryAnimatedSprite(25, new Vector2(position.X - 170f, 2496f), Color.White, 8, flipped: false, 100f, 0, 64, 1f, 128)); smokeTimer = speed * 2000f; } if (position.X > (float)(cars.Count * 128 * 4 + 4480)) { return(true); } return(false); }
public static Rectangle GetFarmerBounds(Farmer f) { var bounds = f.GetBoundingBox(); int s = 32 * 2; bounds.Y -= s; bounds.Height += s; return bounds; }
public static bool island_performAction_prefix(string action, Farmer who, Location tileLocation, bool __result) { //only override obelisk action if (action == "FarmObelisk") { //display stuff from vanilla //not sure what exactly all of it does for (int index = 0; index < 12; ++index) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, (float)Game1.random.Next(25, 75), 6, 1, new Vector2((float)Game1.random.Next((int)who.Position.X - 256, (int)who.Position.X + 192), (float)Game1.random.Next((int)who.Position.Y - 256, (int)who.Position.Y + 192)), false, Game1.random.NextDouble() < 0.5)); } who.currentLocation.playSound("wand", NetAudio.SoundContext.Default); Game1.displayFarmer = false; Game1.player.temporarilyInvincible = true; Game1.player.temporaryInvincibilityTimer = -2000; Game1.player.freezePause = 1000; Game1.flashAlpha = 1f; //the IMPORTANT BIT! actually warp the farmer and show fade-in DelayedAction.fadeAfterDelay((Game1.afterFadeFunction)(() => { warpToFarm(who); }), 1000); //more stuff from vanilla //not really sure what it does new Microsoft.Xna.Framework.Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, 64, 64).Inflate(192, 192); int num = 0; for (int index = who.getTileX() + 8; index >= who.getTileX() - 8; --index) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2((float)index, (float)who.getTileY()) * 64f, Color.White, 8, false, 50f, 0, -1, -1f, -1, 0) { layerDepth = 1f, delayBeforeAnimationStart = num * 25, motion = new Vector2(-0.25f, 0.0f) }); ++num; } //set the return value to true and skip the original code //prevents duplicate warping and other shenanigans __result = true; return(false); } //some other action, ignore and continue to the original code return(true); }
public static void ShearingAndMilking(Farmer player) { int radius = InstanceHolder.Config.AnimalHarvestRadius * Game1.tileSize; Rectangle bb = Util.Expand(player.GetBoundingBox(), radius); foreach (FarmAnimal animal in Util.GetAnimalsList(player)) { string lowerType = animal.type.Value.ToLower(); if (animal.currentProduce.Value < 0 || animal.age.Value < animal.ageWhenMature.Value || player.CurrentTool == null || !animal.GetBoundingBox().Intersects(bb)) { continue; } if ((!lowerType.Contains("sheep") || !(player.CurrentTool is Shears) || !(player.Stamina >= 4f)) && (!lowerType.Contains("cow") || !(player.CurrentTool is MilkPail) || !(player.Stamina >= 4f)) && (!lowerType.Contains("goat") || !(player.CurrentTool is MilkPail) || !(player.Stamina >= 4f))) { continue; } if (!player.addItemToInventoryBool( new Object(Vector2.Zero, animal.currentProduce.Value, null, false, true, false, false) { Quality = animal.produceQuality.Value })) { continue; } switch (player.CurrentTool) { case Shears _: Shears.playSnip(player); break; case MilkPail _: player.currentLocation.localSound("Milking"); DelayedAction.playSoundAfterDelay("fishingRodBend", 300); DelayedAction.playSoundAfterDelay("fishingRodBend", 1200); break; default: continue; } animal.doEmote(20); Game1.playSound("coin"); animal.currentProduce.Value = -1; if (animal.showDifferentTextureWhenReadyForHarvest.Value) { animal.Sprite.LoadTexture("Animals\\Sheared" + animal.type.Value); } player.gainExperience(0, 5); } }
public SpellProjectile(Farmer theSource, ProjectileSpell theSpell, int dmg, float theDir, float theVel, bool theSeeking) : this() { source = theSource; spell = theSpell; damage.Value = dmg; dir.Value = theDir; vel.Value = theVel; seeking.Value = theSeeking; theOneWhoFiredMe.Set(theSource.currentLocation, source); position.Value = source.getStandingPosition(); position.X += source.GetBoundingBox().Width; position.Y += source.GetBoundingBox().Height; rotation = theDir; xVelocity.Value = (float)Math.Cos(dir) * vel; yVelocity.Value = (float)Math.Sin(dir) * vel; damagesMonsters.Value = true; tex = Content.loadTexture("magic/" + spell.ParentSchoolId + "/" + spell.Id + "/projectile.png"); texId.Value = Content.loadTextureKey("magic/" + spell.ParentSchoolId + "/" + spell.Id + "/projectile.png"); if (seeking) { float nearestDist = float.MaxValue; Monster nearestMob = null; foreach (var character in theSource.currentLocation.characters) { if (character is Monster mob) { float dist = Utility.distance(mob.Position.X, position.X, mob.Position.Y, position.Y); if (dist < nearestDist) { nearestDist = dist; nearestMob = mob; } } } seekTarget = nearestMob; } }
public SpellProjectile(Farmer theSource, ProjectileSpell theSpell, int dmg, float theDir, float theVel) { source = theSource; spell = theSpell; damage = dmg; dir = theDir; vel = theVel; theOneWhoFiredMe.Set(theSource.currentLocation, source); position.Value = source.getStandingPosition(); position.X += source.GetBoundingBox().Width; position.Y += source.GetBoundingBox().Height; rotation = theDir; xVelocity.Value = (float)Math.Cos(dir) * vel; yVelocity.Value = (float)Math.Sin(dir) * vel; damagesMonsters.Value = true; tex = Content.loadTexture("magic/" + spell.ParentSchoolId + "/" + spell.Id + "/projectile.png"); texId = Content.loadTextureKey("magic/" + spell.ParentSchoolId + "/" + spell.Id + "/projectile.png"); }
public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { if (who.bathingClothes) { return; } this.indexOfMenuItemView = 2; this.CurrentParentTileIndex = 2; if (who.IsMainPlayer) { for (int index = 0; index < 12; ++index) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, (float)Game1.random.Next(25, 75), 6, 1, new Vector2((float)Game1.random.Next((int)who.position.X - Game1.tileSize * 4, (int)who.position.X + Game1.tileSize * 3), (float)Game1.random.Next((int)who.position.Y - Game1.tileSize * 4, (int)who.position.Y + Game1.tileSize * 3)), false, Game1.random.NextDouble() < 0.5)); } Game1.playSound("wand"); Game1.displayFarmer = false; Game1.player.Halt(); Game1.player.faceDirection(2); Game1.player.freezePause = 1000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(this.wandWarpForReal), 1000); new Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, Game1.tileSize, Game1.tileSize).Inflate(Game1.tileSize * 3, Game1.tileSize * 3); int num1 = 0; for (int index = who.getTileX() + 8; index >= who.getTileX() - 8; --index) { List <TemporaryAnimatedSprite> temporarySprites = who.currentLocation.temporarySprites; TemporaryAnimatedSprite temporaryAnimatedSprite = new TemporaryAnimatedSprite(6, new Vector2((float)index, (float)who.getTileY()) * (float)Game1.tileSize, Color.White, 8, false, 50f, 0, -1, -1f, -1, 0); temporaryAnimatedSprite.layerDepth = 1f; int num2 = num1 * 25; temporaryAnimatedSprite.delayBeforeAnimationStart = num2; Vector2 vector2 = new Vector2(-0.25f, 0.0f); temporaryAnimatedSprite.motion = vector2; temporarySprites.Add(temporaryAnimatedSprite); ++num1; } } this.CurrentParentTileIndex = this.indexOfMenuItemView; }
public static void draw(SpriteBatch b, Farmer farmer) { SpriteFont font = MessageFont(LocalizedContentManager.CurrentLanguageCode); int width = (int)font.MeasureString(farmer.name).X; int height = (int)font.MeasureString(farmer.name).Y; int x = farmer.getStandingX() - width / 2 - Game1.viewport.X; int y = farmer.getStandingY() - (farmer.GetBoundingBox().Height * 2 + height * 2) - 16 - Game1.viewport.Y; float drawLayer = farmer.getDrawLayer(); b.Draw(Game1.staminaRect, new Rectangle(x, y, width, height), null, Color.Black * 0.6f, 0f, Vector2.Zero, SpriteEffects.None, drawLayer); b.DrawString(font, farmer.name, new Vector2(x, y), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, drawLayer + 0.01f); }
public static bool beginUsing_Prefix(ref Pan __instance, GameLocation location, int x, int y, Farmer who, ref bool __result) { float maxDistance = 192f; switch (__instance.UpgradeLevel) { default: // Copper pan. Just use standard functionality. return(true); case 2: maxDistance = 208f; break; case 3: maxDistance = 224f; break; case 4: maxDistance = 256f; break; } __instance.CurrentParentTileIndex = 12; __instance.IndexOfMenuItemView = 12; bool overrideCheck = false; Rectangle orePanRect = new Rectangle(location.orePanPoint.X * 64 - 64, location.orePanPoint.Y * 64 - 64, 256, 256); if (orePanRect.Contains(x, y) && Utility.distance(who.getStandingX(), orePanRect.Center.X, who.getStandingY(), orePanRect.Center.Y) <= maxDistance) { overrideCheck = true; } who.lastClick = Vector2.Zero; x = (int)who.GetToolLocation().X; y = (int)who.GetToolLocation().Y; who.lastClick = new Vector2(x, y); if (location.orePanPoint != null && !location.orePanPoint.Equals(Point.Zero)) { Rectangle panRect = who.GetBoundingBox(); if (overrideCheck || panRect.Intersects(orePanRect)) { who.faceDirection(2); int exhaustion = (who.Stamina <= 0f && who.usingTool.Value) ? 2 : 1; who.FarmerSprite.animateOnce(303, 50f, 4); __result = true; return(false); } } who.forceCanMove(); __result = true; return(false); }
public override bool doAction(Vector2 tileLocation, Farmer who) { if (who.IsLocalPlayer && !this.isTilePassable(tileLocation)) { for (var index = 0; index < 12; ++index) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, Game1.random.Next(25, 75), 6, 1, new Vector2( Game1.random.Next((int)who.position.X - Game1.tileSize * 4, (int)who.position.X + Game1.tileSize * 3), Game1.random.Next((int)who.position.Y - Game1.tileSize * 4, (int)who.position.Y + Game1.tileSize * 3)), false, Game1.random.NextDouble() < 0.5)); } who.currentLocation.playSound("wand"); Game1.displayFarmer = false; Game1.player.freezePause = 1000; Game1.flashAlpha = 1f; DelayedAction.fadeAfterDelay(this.WarpToDesert, 1000); new Rectangle(who.GetBoundingBox().X, who.GetBoundingBox().Y, Game1.tileSize, Game1.tileSize).Inflate( Game1.tileSize * 3, Game1.tileSize * 3); var num = 0; for (var index = who.getTileX() + 8; index >= who.getTileX() - 8; --index) { who.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(index, who.getTileY()) * 64f, Color.White, 8, false, 50f, 0, -1, -1f, -1, 0) { layerDepth = 1f, delayBeforeAnimationStart = num * 25, motion = new Vector2(-0.25f, 0.0f) }); ++num; } } return(false); }
private static void ShowFarmerParticleEffect(SpriteBatch b, Farmer instance, string key, ParticleEffectData ped) { if (!farmerEffectDict.TryGetValue(instance.UniqueMultiplayerID, out EntityParticleData entityParticleData)) { entityParticleData = new EntityParticleData(); farmerEffectDict[instance.UniqueMultiplayerID] = entityParticleData; } if (!entityParticleData.particleDict.TryGetValue(key, out var particleList)) { particleList = new List <ParticleData>(); farmerEffectDict[instance.UniqueMultiplayerID].particleDict[key] = particleList; } ShowParticleEffect(b, particleList, ped, instance.GetBoundingBox().Center.ToVector2() + new Vector2(ped.fieldOffsetX, ped.fieldOffsetY), instance.getDrawLayer()); farmerEffectDict[instance.UniqueMultiplayerID] = entityParticleData; }
public static void FarmHouse_resetLocalState_Postfix(ref FarmHouse __instance) { try { Farmer f = __instance.owner; if (f == null) { return; } ModEntry.PMonitor.Log($"reset farmhouse state - upgrade level {__instance.upgradeLevel}"); Misc.ResetSpouses(f); if (f.currentLocation == __instance && Misc.IsInBed(__instance, f.GetBoundingBox())) { f.position.Value = Misc.GetFarmerBedPosition(__instance); } if (ModEntry.config.CustomBed && __instance.upgradeLevel > 0) { Maps.ReplaceBed(__instance); } if (__instance.upgradeLevel > 0 && __instance.upgradeLevel < 4) { Maps.BuildSpouseRooms(__instance); __instance.setFloors(); } if (Misc.ChangingKidsRoom()) { if (__instance.upgradeLevel > 1 && __instance.upgradeLevel < 4) { NPCPatches.SetCribs(__instance); Maps.ExpandKidsRoom(__instance); } } if (Misc.GetSpouses(f, 0).ContainsKey("Sebastian") && Game1.netWorldState.Value.hasWorldStateID("sebastianFrog")) { if (Game1.random.NextDouble() < 0.1 && Game1.timeOfDay > 610) { DelayedAction.playSoundAfterDelay("croak", 1000, null, -1); } } } catch (Exception ex) { Monitor.Log($"Failed in {nameof(FarmHouse_resetLocalState_Postfix)}:\n{ex}", LogLevel.Error); } }
public static Microsoft.Xna.Framework.Rectangle slopePositionHalf(Farmer player, double yOffset, bool playerAscend) { Microsoft.Xna.Framework.Rectangle boundingBox = player.GetBoundingBox(); if (player.movementDirections.Contains(1)) { boundingBox.X += (int)Math.Ceiling((double)player.getMovementSpeed()); boundingBox.Y += (int)(Math.Ceiling(yOffset) * (playerAscend ? -0.5 : 0.5)); } else if (player.movementDirections.Contains(3)) { boundingBox.X -= (int)Math.Ceiling((double)player.getMovementSpeed()); boundingBox.Y += (int)Math.Ceiling((yOffset) * (playerAscend ? -0.5 : 0.5)); } return(boundingBox); }
public static void PetNearbyPets() { GameLocation location = Game1.currentLocation; Farmer player = Game1.player; Rectangle bb = Util.Expand(player.GetBoundingBox(), Config.AutoPetRadius * Game1.tileSize); foreach (Pet pet in location.characters.OfType <Pet>().Where(pet => pet.GetBoundingBox().Intersects(bb))) { bool wasPet = WasPetToday(pet); if (!wasPet) { Logger.Log($"Petted {(pet is Dog ? "Dog" : "Cat")}'{pet.Name}' @{pet.getTileLocationPoint()}"); pet.checkAction(player, location); // Pet pet... lol } } }
private static bool IsPlayerInClose(Farmer player, Fence fence, Vector2 fenceLocation, bool?isUpDown) { if (isUpDown == null) { return(fence.getBoundingBox(fence.TileLocation).Intersects(player.GetBoundingBox())); } Vector2 playerTileLocation = player.getTileLocation(); if (playerTileLocation == fenceLocation) { return(true); } if (!IsPlayerFaceOrBackToFence(isUpDown == true, player)) { return(false); } return(isUpDown.Value ? ExpandSpecific(fence.getBoundingBox(fenceLocation), 0, 16).Intersects(player.GetBoundingBox()) : ExpandSpecific(fence.getBoundingBox(fenceLocation), 16, 0).Intersects(player.GetBoundingBox())); }
public override void update(GameTime time, GameLocation environment, Farmer who) { for (int i = environment.characters.Count - 1; i >= 0; i--) { Character character = environment.characters[i]; Point characterPos = character.GetBoundingBox().Center; Point playerPos = who.GetBoundingBox().Center; Vector2 distance = new Vector2(characterPos.X - playerPos.X, characterPos.Y - playerPos.Y); if (character is Monster monster && distance.Length() <= M.Config.Range) { if (monster.Slipperiness != -1) { distance.Normalize(); distance *= M.Config.Knockback; monster.xVelocity = distance.X; monster.yVelocity = -distance.Y; } int damage; if (M.Config.PercentageDamage) { damage = monster.MaxHealth * M.Config.Damage / 100; } else { damage = M.Config.Damage; } if (!M.Config.IgnoreResilience) { damage = Math.Max(1, damage - monster.resilience.Value); } if (!M.Config.IgnoreMissChance && Game1.random.NextDouble() < monster.missChance) { damage = 0; } if (M.Config.IgnoreCooldown || !monster.isInvincible()) { monster.setInvincibleCountdown(225); DamageMonster(monster, damage, who); } } } }
public override bool OverlapsFarmerForDamage(Farmer who) { if (base.OverlapsFarmerForDamage(who)) { return(true); } if (IsRoyalSerpent()) { Rectangle farmer_box = who.GetBoundingBox(); Rectangle bounding_box = GetBoundingBox(); Vector2 offset = new Vector2((float)bounding_box.X - base.Position.X, (float)bounding_box.Y - base.Position.Y); foreach (Vector3 segment in segments) { bounding_box.X = (int)(segment.X + offset.X); bounding_box.Y = (int)(segment.Y + offset.Y); if (bounding_box.Intersects(farmer_box)) { return(true); } } } return(false); }