public Debris(int objectIndex, Vector2 debrisOrigin, Vector2 playerPosition) : this(objectIndex, 1, debrisOrigin, playerPosition) { string str; if (objectIndex <= 0) { str = "Crafting"; } else { str = Game1.objectInformation[objectIndex].Split('/')[3].Split(' ')[0]; } this.debrisType = !str.Equals("Arch") ? Debris.DebrisType.OBJECT : Debris.DebrisType.ARCHAEOLOGY; if (objectIndex == 92) { this.debrisType = Debris.DebrisType.RESOURCE; } if (Game1.player.speed >= 5 && !Game1.IsMultiplayer) { for (int index = 0; index < this.chunks.Count; ++index) { this.chunks[index].xVelocity *= Game1.player.FacingDirection == 1 || Game1.player.FacingDirection == 3 ? 1f : 1f; } } this.chunks[0].debrisType = objectIndex; }
public Debris(string message, int numberOfChunks, Vector2 debrisOrigin, Color messageColor, float scale, float rotation) : this(-1, numberOfChunks, debrisOrigin, Game1.player.Position) { this.debrisType = Debris.DebrisType.LETTERS; this.debrisMessage = message; this.nonSpriteChunkColor = messageColor; this.chunks[0].rotation = rotation; this.chunks[0].scale = scale; }
public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location) { int chunkType = -1; Debris.DebrisType debrisType = Debris.DebrisType.RESOURCE; int numChunks = -1; string removalMessage = ""; Random random = new Random((int)((double)Game1.uniqueIDForThisGame + (double)featureSaveData.featurePosition.X * 7.0 + (double)featureSaveData.featurePosition.Y * 11.0 + (double)Game1.mine.mineLevel + (double)Game1.player.timesReachedMineBottom)); if (random.NextDouble() < 0.005) { chunkType = 114; debrisType = Debris.DebrisType.OBJECT; numChunks = 1; removalMessage = "ancient seed"; } else if (random.NextDouble() < 0.01) { bool lessThan = random.NextDouble() < 0.5; chunkType = lessThan ? 382 : 8; debrisType = lessThan ? Debris.DebrisType.RESOURCE : Debris.DebrisType.CHUNKS; numChunks = random.Next(1, 2); removalMessage = "coal"; } else if (random.NextDouble() < 0.02) { chunkType = 92; debrisType = Debris.DebrisType.OBJECT; numChunks = random.Next(2, 4); removalMessage = "sap"; } if (chunkType != -1) { //A bug in the game code adds items to Game1.currentLocation instead of the location of the CosmeticPlant. location = Game1.currentLocation; for (int i = 0; i < location.debris.Count; i++) { Debris debris = location.debris[i]; if (debris.chunkType == chunkType && debris.debrisType == debrisType && debris.Chunks.Count == numChunks) { if (!WithinRange(featureSaveData.featurePosition, debris.Chunks[0].position / Game1.tileSize, 2)) { continue; } location.debris.RemoveAt(i); i--; monitor.Log($"Removed {removalMessage} for grass.", LogLevel.Trace); break; } } } }
public Debris(int number, Vector2 debrisOrigin, Color messageColor, float scale, Character toHover) : this(-1, 1, debrisOrigin, Game1.player.Position) { this.chunkType = number; this.debrisType = Debris.DebrisType.NUMBERS; this.nonSpriteChunkColor = messageColor; this.chunks[0].scale = scale; this.toHover = toHover; this.chunks[0].xVelocity = (float)Game1.random.Next(-1, 2); }
public Debris(int type, int numberOfChunks, Vector2 debrisOrigin, Vector2 playerPosition, int groundLevel, int color = -1) : this(-1, numberOfChunks, debrisOrigin, playerPosition) { this.debrisType = Debris.DebrisType.CHUNKS; for (int i = 0; i < this.chunks.Count; i++) { this.chunks[i].debrisType = type; } this.chunkType = type; this.chunksColor = this.getColorForDebris((color == -1) ? type : color); }
public Debris(Texture2D spriteSheet, Rectangle sourceRect, int numberOfChunks, Vector2 debrisOrigin) : this(-1, numberOfChunks, debrisOrigin, Game1.player.Position) { this.debrisType = Debris.DebrisType.SPRITECHUNKS; this.spriteChunkSheet = spriteSheet; for (int i = 0; i < this.chunks.Count; i++) { this.chunks[i].xSpriteSheet = Game1.random.Next(sourceRect.X, sourceRect.X + sourceRect.Width - 4); this.chunks[i].ySpriteSheet = Game1.random.Next(sourceRect.Y, sourceRect.Y + sourceRect.Width - 4); this.chunks[i].scale = 1f; } }
public Debris(Texture2D spriteSheet, int numberOfChunks, Vector2 debrisOrigin) : this(-1, numberOfChunks, debrisOrigin, Game1.player.Position) { this.debrisType = Debris.DebrisType.SPRITECHUNKS; this.spriteChunkSheet = spriteSheet; for (int i = 0; i < this.chunks.Count; i++) { this.chunks[i].xSpriteSheet = Game1.random.Next(0, Game1.tileSize - 8); this.chunks[i].ySpriteSheet = Game1.random.Next(0, Game1.tileSize * 3 / 2 - 8); this.chunks[i].scale = 1f; } }
public Debris(Texture2D spriteSheet, Rectangle sourceRect, int numberOfChunks, Vector2 debrisOrigin, Vector2 playerPosition, int groundLevel) : this(-1, numberOfChunks, debrisOrigin, playerPosition) { this.debrisType = Debris.DebrisType.SPRITECHUNKS; this.spriteChunkSheet = spriteSheet; for (int index = 0; index < this.chunks.Count; ++index) { this.chunks[index].xSpriteSheet = Game1.random.Next(sourceRect.X, sourceRect.X + sourceRect.Width - 4); this.chunks[index].ySpriteSheet = Game1.random.Next(sourceRect.Y, sourceRect.Y + sourceRect.Width - 4); this.chunks[index].scale = 1f; } this.chunkFinalYLevel = groundLevel; }
public static bool Prefix(GameLocation __instance, int xTile, int yTile, Debris.DebrisType type, ref bool __result) { if (!Config.EnableMod || !__instance.Name.Equals("Dreamscape")) { return(true); } var tile = __instance.map.GetLayer("Back").PickTile(new Location(xTile * 64, yTile * 64), Game1.viewport.Size); if ((tile != null && tile.TileIndex != 26 && tile.TileIndex != 15) || __instance.map.GetLayer("Back3").PickTile(new Location(xTile * 64, yTile * 64), Game1.viewport.Size) is not null) { __result = true; } return(false); }
public Debris(Texture2D spriteSheet, Rectangle sourceRect, int numberOfChunks, Vector2 debrisOrigin, Vector2 playerPosition, int groundLevel, int sizeOfSourceRectSquares) : this(-1, numberOfChunks, debrisOrigin, Game1.player.Position) { this.sizeOfSourceRectSquares = sizeOfSourceRectSquares; this.debrisType = Debris.DebrisType.SPRITECHUNKS; this.spriteChunkSheet = spriteSheet; for (int i = 0; i < this.chunks.Count; i++) { this.chunks[i].xSpriteSheet = Game1.random.Next(2) * sizeOfSourceRectSquares + sourceRect.X; this.chunks[i].ySpriteSheet = Game1.random.Next(2) * sizeOfSourceRectSquares + sourceRect.Y; this.chunks[i].rotationVelocity = ((Game1.random.NextDouble() < 0.5) ? ((float)(3.1415926535897931 / (double)Game1.random.Next(-32, -16))) : ((float)(3.1415926535897931 / (double)Game1.random.Next(16, 32)))); this.chunks[i].xVelocity *= 1.2f; this.chunks[i].yVelocity *= 1.2f; this.chunks[i].scale = (float)Game1.pixelZoom; } }
public Debris(int objectIndex, Vector2 debrisOrigin, Vector2 playerPosition) : this(objectIndex, 1, debrisOrigin, playerPosition) { string text; if (objectIndex <= 0) { text = "Crafting"; } else { text = Game1.objectInformation[objectIndex].Split(new char[] { '/' })[3].Split(new char[] { ' ' })[0]; } if (text.Equals("Arch")) { this.debrisType = Debris.DebrisType.ARCHAEOLOGY; } else { this.debrisType = Debris.DebrisType.OBJECT; } if (objectIndex == 92) { this.debrisType = Debris.DebrisType.RESOURCE; } if (Game1.player.speed >= 5 && !Game1.IsMultiplayer) { for (int i = 0; i < this.chunks.Count; i++) { this.chunks[i].xVelocity *= (float)((Game1.player.FacingDirection == 1 || Game1.player.FacingDirection == 3) ? 1 : 1); } } this.chunks[0].debrisType = objectIndex; }
public Debris(int debrisType, int numberOfChunks, Vector2 debrisOrigin, Vector2 playerPosition, float velocityMultiplyer) { switch (debrisType) { case 0: case 378: debrisType = 378; this.debrisType = Debris.DebrisType.RESOURCE; break; case 2: case 380: debrisType = 380; this.debrisType = Debris.DebrisType.RESOURCE; break; case 4: case 382: debrisType = 382; this.debrisType = Debris.DebrisType.RESOURCE; break; case 6: case 384: debrisType = 384; this.debrisType = Debris.DebrisType.RESOURCE; break; case 8: this.debrisType = Debris.DebrisType.CHUNKS; break; case 10: case 386: debrisType = 386; this.debrisType = Debris.DebrisType.RESOURCE; break; case 12: case 388: debrisType = 388; this.debrisType = Debris.DebrisType.RESOURCE; break; case 14: case 390: debrisType = 390; this.debrisType = Debris.DebrisType.RESOURCE; break; default: this.debrisType = Debris.DebrisType.OBJECT; break; } if (debrisType != -1) { playerPosition -= (playerPosition - debrisOrigin) * 2f; } this.chunkType = debrisType; int num1; if (Game1.objectInformation.ContainsKey(debrisType)) { num1 = Game1.objectInformation[debrisType].Split('/')[3].Contains("-4") ? 1 : 0; } else { num1 = 0; } this.floppingFish = num1 != 0; int num2; if (Game1.objectInformation.ContainsKey(debrisType)) { num2 = Game1.objectInformation[debrisType].Split('/')[3].Contains("Fish") ? 1 : 0; } else { num2 = 0; } this.isFishable = num2 != 0; int num3; int num4; int num5; int num6; if ((double)playerPosition.Y >= (double)debrisOrigin.Y - (double)(Game1.tileSize / 2) && (double)playerPosition.Y <= (double)debrisOrigin.Y + (double)(Game1.tileSize / 2)) { this.chunkFinalYLevel = (int)debrisOrigin.Y - Game1.tileSize / 2; num3 = 220; num4 = 250; if ((double)playerPosition.X < (double)debrisOrigin.X) { num5 = 20; num6 = 140; } else { num5 = -140; num6 = -20; } } else if ((double)playerPosition.Y < (double)debrisOrigin.Y - (double)(Game1.tileSize / 2)) { this.chunkFinalYLevel = (int)debrisOrigin.Y + (int)((double)(Game1.tileSize / 2) * (double)velocityMultiplyer); num3 = 150; num4 = 200; num5 = -50; num6 = 50; } else { this.movingFinalYLevel = true; this.chunkFinalYLevel = (int)debrisOrigin.Y - 1; this.chunkFinalYTarget = (int)debrisOrigin.Y - (int)((double)(Game1.tileSize * 3 / 2) * (double)velocityMultiplyer); this.movingUp = true; num3 = 350; num4 = 400; num5 = -50; num6 = 50; } debrisOrigin.X -= (float)(Game1.tileSize / 2); debrisOrigin.Y -= (float)(Game1.tileSize / 2); int minValue1 = (int)((double)num5 * (double)velocityMultiplyer); int maxValue1 = (int)((double)num6 * (double)velocityMultiplyer); int minValue2 = (int)((double)num3 * (double)velocityMultiplyer); int maxValue2 = (int)((double)num4 * (double)velocityMultiplyer); this.uniqueID = Game1.recentMultiplayerRandom.Next(int.MinValue, int.MaxValue); for (int index = 0; index < numberOfChunks; ++index) { this.chunks.Add(new Chunk(debrisOrigin, (float)Game1.recentMultiplayerRandom.Next(minValue1, maxValue1) / 40f, (float)Game1.recentMultiplayerRandom.Next(minValue2, maxValue2) / 40f, Game1.recentMultiplayerRandom.Next(debrisType, debrisType + 2))); } }
private void UpdateTicking(object sender, UpdateTickingEventArgs e) { if (!Context.IsWorldReady) { return; } GameLocation location = Game1.getPlayerOrEventFarmer().currentLocation; Netcode.NetCollection <Debris> debris = location.debris; GameTime time = new GameTime(); float rangeMult = magnetRangeMult; bool infRange = (rangeMult < 0 ? true : false); int speedMult = magnetSpeedMult; bool noBounce = noLootBounce; bool noWave = noLootWave; for (int j = 0; j < debris.Count; j++) { Debris d = debris[j]; NetObjectShrinkList <Chunk> chunks = (NetObjectShrinkList <Chunk>) typeof(Debris).GetField("chunks", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(d); if (chunks.Count == 0) { continue; } d.timeSinceDoneBouncing += (float)time.ElapsedGameTime.Milliseconds; if (d.timeSinceDoneBouncing >= (d.floppingFish ? 2500f : ((d.debrisType == Debris.DebrisType.SPRITECHUNKS || d.debrisType == Debris.DebrisType.NUMBERS) ? 1800f : (noBounce ? 0f : 600f)))) { if (d.debrisType == Debris.DebrisType.LETTERS || d.debrisType == Debris.DebrisType.NUMBERS || d.debrisType == Debris.DebrisType.SQUARES || d.debrisType == Debris.DebrisType.SPRITECHUNKS || (d.debrisType == Debris.DebrisType.CHUNKS && chunks[0].debrisType - chunks[0].debrisType % 2 != 8)) { continue; } if (d.debrisType == Debris.DebrisType.ARCHAEOLOGY || d.debrisType == Debris.DebrisType.OBJECT || d.debrisType == Debris.DebrisType.RESOURCE || d.debrisType == Debris.DebrisType.CHUNKS) { d.chunksMoveTowardPlayer = true; } d.timeSinceDoneBouncing = 0f; } if (location.farmers.Count == 0) { continue; } Vector2 total = default(Vector2); foreach (Chunk chunk in chunks) { total += chunk.position.Value; } Vector2 position = total / (float)chunks.Count; if (d.player.Value != null && (d.player.Value.currentLocation != location || !infRange && !(Math.Abs(position.X + 32f - (float)d.player.Value.getStandingX()) <= (float)d.player.Value.MagneticRadius * rangeMult && Math.Abs(position.Y + 32f - (float)d.player.Value.getStandingY()) <= (float)d.player.Value.MagneticRadius * rangeMult))) { d.player.Value = null; } Farmer farmer = d.player.Value; if (farmer == null && (Game1.IsMasterGame || location.isTemp())) { float bestDistance = float.MaxValue; Farmer bestFarmer = null; foreach (Farmer f in location.farmers) { bool pir = infRange || (Math.Abs(position.X + 32f - (float)f.getStandingX()) <= (float)f.MagneticRadius * rangeMult && Math.Abs(position.Y + 32f - (float)f.getStandingY()) <= (float)f.MagneticRadius * rangeMult); if ((f.UniqueMultiplayerID != d.DroppedByPlayerID || bestFarmer == null) && pir) { float distance = (f.Position - position).LengthSquared(); if (distance < bestDistance || (bestFarmer != null && bestFarmer.UniqueMultiplayerID == d.DroppedByPlayerID)) { bestFarmer = f; bestDistance = distance; } } } farmer = bestFarmer; } bool anyCouldMove = false; for (int i = chunks.Count - 1; i >= 0; i--) { Chunk chunk = chunks[i]; chunk.position.UpdateExtrapolation(chunk.getSpeed()); if (chunk.alpha > 0.1f && (d.debrisType == Debris.DebrisType.SPRITECHUNKS || d.debrisType == Debris.DebrisType.NUMBERS) && d.timeSinceDoneBouncing > 600f) { chunk.alpha = (1800f - d.timeSinceDoneBouncing) / 1000f; } if (chunk.position.X < -128f || chunk.position.Y < -64f || chunk.position.X >= (float)(location.map.DisplayWidth + 64) || chunk.position.Y >= (float)(location.map.DisplayHeight + 64)) { chunks.RemoveAt(i); } else { bool canMoveTowardPlayer = farmer != null; if (canMoveTowardPlayer) { Debris.DebrisType value = d.debrisType.Value; if (value - Debris.DebrisType.ARCHAEOLOGY > 1) { canMoveTowardPlayer = (value != Debris.DebrisType.RESOURCE || farmer.couldInventoryAcceptThisObject(chunk.debrisType - chunk.debrisType % 2, 1, 0)); } else if (d.item != null) { canMoveTowardPlayer = farmer.couldInventoryAcceptThisItem(d.item); } else { if (chunk.debrisType < 0) { canMoveTowardPlayer = farmer.couldInventoryAcceptThisItem(new StardewValley.Object(Vector2.Zero, chunk.debrisType * -1, false)); } else { canMoveTowardPlayer = farmer.couldInventoryAcceptThisObject(chunk.debrisType, 1, d.itemQuality); } if (chunk.debrisType == 102 && farmer.hasMenuOpen) { canMoveTowardPlayer = false; } } anyCouldMove = (anyCouldMove || canMoveTowardPlayer); if (canMoveTowardPlayer) { d.player.Value = farmer; } } if ((d.chunksMoveTowardPlayer || d.isFishable) && canMoveTowardPlayer) { if (d.player.Value.IsLocalPlayer) { if (speedMult < 0) { chunk.position.X = d.player.Value.Position.X; chunk.position.Y = d.player.Value.Position.Y; } else { for (int l = 1; l < speedMult; l++) { if (noWave) { if (chunk.position.X < d.player.Value.Position.X - 12f) { chunk.xVelocity.Value = 8f; } else if (chunk.position.X > d.player.Value.Position.X + 12f) { chunk.xVelocity.Value = -8f; } if (chunk.position.Y < d.player.Value.Position.Y - 12f) { chunk.yVelocity.Value = -8f; } else if (chunk.position.Y > d.player.Value.Position.Y + 12f) { chunk.yVelocity.Value = 8f; } } else { if (chunk.position.X < d.player.Value.Position.X - 12f) { chunk.xVelocity.Value = Math.Min(chunk.xVelocity + 0.8f, 8f); } else if (chunk.position.X > d.player.Value.Position.X + 12f) { chunk.xVelocity.Value = Math.Max(chunk.xVelocity - 0.8f, -8f); } if (chunk.position.Y + 32f < (float)(d.player.Value.getStandingY() - 12)) { chunk.yVelocity.Value = Math.Max(chunk.yVelocity - 0.8f, -8f); } else if (chunk.position.Y + 32f > (float)(d.player.Value.getStandingY() + 12)) { chunk.yVelocity.Value = Math.Min(chunk.yVelocity + 0.8f, 8f); } } chunk.position.X += chunk.xVelocity; chunk.position.Y -= chunk.yVelocity; } } } } } } typeof(Debris).GetField("chunks", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(d, chunks); } }
public Debris(int debrisType, int numberOfChunks, Vector2 debrisOrigin, Vector2 playerPosition, float velocityMultiplyer) { switch (debrisType) { case 0: break; case 1: case 3: case 5: case 7: case 9: case 11: case 13: goto IL_13D; case 2: goto IL_D4; case 4: goto IL_104; case 6: goto IL_E4; case 8: this.debrisType = Debris.DebrisType.CHUNKS; goto IL_144; case 10: goto IL_F4; case 12: goto IL_114; case 14: goto IL_124; default: switch (debrisType) { case 378: break; case 379: case 381: case 383: case 385: case 387: case 389: goto IL_13D; case 380: goto IL_D4; case 382: goto IL_104; case 384: goto IL_E4; case 386: goto IL_F4; case 388: goto IL_114; case 390: goto IL_124; default: goto IL_13D; } break; } debrisType = 378; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_D4: debrisType = 380; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_E4: debrisType = 384; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_F4: debrisType = 386; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_104: debrisType = 382; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_114: debrisType = 388; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_124: debrisType = 390; this.debrisType = Debris.DebrisType.RESOURCE; goto IL_144; IL_13D: this.debrisType = Debris.DebrisType.OBJECT; IL_144: if (debrisType != -1) { playerPosition -= (playerPosition - debrisOrigin) * 2f; } this.chunkType = debrisType; this.floppingFish = (Game1.objectInformation.ContainsKey(debrisType) && Game1.objectInformation[debrisType].Split(new char[] { '/' })[3].Contains("-4")); this.isFishable = (Game1.objectInformation.ContainsKey(debrisType) && Game1.objectInformation[debrisType].Split(new char[] { '/' })[3].Contains("Fish")); int num; int num2; int num3; int num4; if (playerPosition.Y >= debrisOrigin.Y - (float)(Game1.tileSize / 2) && playerPosition.Y <= debrisOrigin.Y + (float)(Game1.tileSize / 2)) { this.chunkFinalYLevel = (int)debrisOrigin.Y - Game1.tileSize / 2; num = 220; num2 = 250; if (playerPosition.X < debrisOrigin.X) { num3 = 20; num4 = 140; } else { num3 = -140; num4 = -20; } } else if (playerPosition.Y < debrisOrigin.Y - (float)(Game1.tileSize / 2)) { this.chunkFinalYLevel = (int)debrisOrigin.Y + (int)((float)(Game1.tileSize / 2) * velocityMultiplyer); num = 150; num2 = 200; num3 = -50; num4 = 50; } else { this.movingFinalYLevel = true; this.chunkFinalYLevel = (int)debrisOrigin.Y - 1; this.chunkFinalYTarget = (int)debrisOrigin.Y - (int)((float)(Game1.tileSize * 3 / 2) * velocityMultiplyer); this.movingUp = true; num = 350; num2 = 400; num3 = -50; num4 = 50; } debrisOrigin.X -= (float)(Game1.tileSize / 2); debrisOrigin.Y -= (float)(Game1.tileSize / 2); num3 = (int)((float)num3 * velocityMultiplyer); num4 = (int)((float)num4 * velocityMultiplyer); num = (int)((float)num * velocityMultiplyer); num2 = (int)((float)num2 * velocityMultiplyer); this.uniqueID = Game1.recentMultiplayerRandom.Next(-2147483648, 2147483647); for (int i = 0; i < numberOfChunks; i++) { this.chunks.Add(new Chunk(debrisOrigin, (float)Game1.recentMultiplayerRandom.Next(num3, num4) / 40f, (float)Game1.recentMultiplayerRandom.Next(num, num2) / 40f, Game1.recentMultiplayerRandom.Next(debrisType, debrisType + 2))); } }