public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { if (npc.ai[1] >= 1400) { Texture2D texture = ModContent.GetTexture("ElementsAwoken/Projectiles/NPCProj/CosmicObserver/ObserverTarget"); Texture2D backTexture = ModContent.GetTexture("ElementsAwoken/Projectiles/NPCProj/CosmicObserver/ObserverTarget1"); Vector2 position = npc.Center; Player P = Main.player[npc.target]; Vector2 mountedCenter = P.MountedCenter; int height = 34; Rectangle?sourceRectangle = new Rectangle(0, height * targetLaserFrame, texture.Width, height); Vector2 origin = new Vector2((float)texture.Width * 0.5f, (float)height * 0.5f); float num1 = (float)height; Vector2 vector2_4 = mountedCenter - position; float rotation = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f; bool flag = true; if (float.IsNaN(position.X) && float.IsNaN(position.Y)) { flag = false; } if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y)) { flag = false; } while (flag) { if ((double)vector2_4.Length() < (double)num1 + 1.0) { flag = false; } else { Vector2 vector2_1 = vector2_4; vector2_1.Normalize(); position += vector2_1 * num1; vector2_4 = mountedCenter - position; Tile t = Main.tile[position.ToTileCoordinates().X, position.ToTileCoordinates().Y]; if (Main.tileSolid[t.type] && t.active()) { return; } Main.spriteBatch.Draw(backTexture, position - Main.screenPosition, new Rectangle?(), Color.White * (beamCharge / beamChargeMax), rotation, origin, 1f, SpriteEffects.None, 0.0f); Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, Color.White, rotation, origin, 1f, SpriteEffects.None, 0.0f); } } } }
// Token: 0x0600004D RID: 77 RVA: 0x0000824C File Offset: 0x0000644C public static void CheckArenaScore(Vector2 arenaCenter, out Point xLeftEnd, out Point xRightEnd, int walkerWidthInTiles = 5, int walkerHeightInTiles = 10) { bool flag = false; Point point = arenaCenter.ToTileCoordinates(); xLeftEnd = (xRightEnd = point); int num; int y; Collision.ExpandVertically(point.X, point.Y, out num, out y, 0, 4); point.Y = y; if (flag) { Dust.QuickDust(point, Color.Blue).scale = 5f; } int num2; Point point2; StrayMethods.SendWalker(point, walkerHeightInTiles, -1, out num2, out point2, 120, flag); int num3; Point point3; StrayMethods.SendWalker(point, walkerHeightInTiles, 1, out num3, out point3, 120, flag); point2.X++; point3.X--; if (flag) { Dust.QuickDustLine(point2.ToWorldCoordinates(8f, 8f), point3.ToWorldCoordinates(8f, 8f), 50f, Color.Pink); } xLeftEnd = point2; xRightEnd = point3; }
public static bool PlotTileTale(Vector2 start, Vector2 end, float width, PerLinePoint plot) { float halfWidth = width / 2f; Vector2 value = end - start; Vector2 vector = value / value.Length(); Vector2 perpOffset = new Vector2(0f - vector.Y, vector.X); Point pointStart = start.ToTileCoordinates(); Point point = end.ToTileCoordinates(); int length = 0; PlotLine(pointStart.X, pointStart.Y, point.X, point.Y, delegate { length++; return(true); }); length--; int curLength = 0; return(PlotLine(pointStart.X, pointStart.Y, point.X, point.Y, delegate(int x, int y) { float scaleFactor = 1f - (float)curLength / (float)length; curLength++; Point point2 = (start - perpOffset * halfWidth * scaleFactor).ToTileCoordinates(); Point point3 = (start + perpOffset * halfWidth * scaleFactor).ToTileCoordinates(); Point point4 = new Point(point2.X - pointStart.X, point2.Y - pointStart.Y); Point point5 = new Point(point3.X - pointStart.X, point3.Y - pointStart.Y); return PlotLine(x + point4.X, y + point4.Y, x + point5.X, y + point5.Y, plot, false); })); }
public void FireProjectile() { List <Point> list4 = new List <Point>(); Vector2 vec5 = Main.player[npc.target].Center + new Vector2(Main.player[npc.target].velocity.X * 30f, 0f); Point point14 = vec5.ToTileCoordinates(); int num1468 = 0; while (num1468 < 1000 && list4.Count < 1) { bool flag118 = false; int num1469 = Main.rand.Next(point14.X - 30, point14.X + 30 + 1); foreach (Point current in list4) { if (Math.Abs(current.X - num1469) < 10) { flag118 = true; break; } } if (!flag118) { int startY = point14.Y - 20; Collision.ExpandVertically(num1469, startY, out int num1470, out int num1471, 1, 51); if (StrayMethods.CanSpawnSandstormHostile(new Vector2(num1469, num1471 - 15) * 16f, 15, 15)) { list4.Add(new Point(num1469, num1471 - 15)); } } num1468++; } foreach (Point current2 in list4) { Projectile.NewProjectile(current2.X * 16, current2.Y * 16, 0f, 0f, 658, damage, 0f, Main.myPlayer, 0f, 0f); } }
public void Update() { foreach (Flock fishflock in Flocks) { fishflock.Update(); } Player player = Main.LocalPlayer; MyPlayer modPlayer = player.GetSpiritPlayer(); //Test if ((Main.GameUpdateCount % SPAWNRATE > 38 && Main.LocalPlayer.ZoneBeach) || (Main.GameUpdateCount % SPAWNRATE > 32 && modPlayer.nearLure)) { int flock = Main.rand.Next(0, Flocks.Count); int fluff = 1000; Vector2 rand = new Vector2( Main.rand.Next(-Main.screenWidth / 2 - fluff, Main.screenWidth / 2 + fluff), Main.rand.Next(-Main.screenHeight / 2 - fluff, Main.screenHeight / 2 + fluff)); if (!new Rectangle(0, 0, Main.screenWidth, Main.screenHeight).Contains(rand.ToPoint())) { Vector2 position = Main.LocalPlayer.Center + rand; Point tP = position.ToTileCoordinates(); if (WorldGen.InWorld(tP.X, tP.Y, 10)) { Tile tile = Framing.GetTileSafely(tP.X, tP.Y); if (tile.liquid > 100) { Flocks[flock].Populate(position, Main.rand.Next(20, 30), 50f); } } } } }
public override void Kill(int timeLeft) { Vector2 shockwavePosition = new Vector2(projectile.position.X, projectile.position.Y); Point shockwavePoint = shockwavePosition.ToTileCoordinates(); Tile shockwaveTile = Framing.GetTileSafely((int)shockwavePoint.X, (int)shockwavePoint.Y); if (!Main.tileSolid[shockwaveTile.type] && shockwaveTile.active()) { for (int i = 0; i < 3; i++) { if (shockwaveTile.active()) { if (!Main.tileSolid[shockwaveTile.type]) { shockwavePosition -= new Vector2(0f, 16); shockwavePoint = shockwavePosition.ToTileCoordinates(); shockwaveTile = Framing.GetTileSafely((int)shockwavePosition.X, (int)shockwavePosition.Y); } else { break; } } } } Projectile.NewProjectile(shockwavePoint.X * 16 + 8, shockwavePoint.Y * 16 + 8, 0f, 0f, mod.ProjectileType("Shockwave"), 0, 0f, projectile.owner, 9f, 1f); Projectile.NewProjectile(shockwavePoint.X * 16 + 8, shockwavePoint.Y * 16 + 8, 0f, 0f, mod.ProjectileType("Shockwave"), 0, 0f, projectile.owner, 9f, -1f); Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 69); }
public static void HitGolfBall(Entity entity, Vector2 velocity, float roughLandResistance) { Vector2 bottom = entity.Bottom; bottom.Y += 1f; Point point = bottom.ToTileCoordinates(); Tile tile = Main.tile[point.X, point.Y]; if (tile != null && tile.active()) { TileMaterial byTileId = TileMaterials.GetByTileId(tile.type); velocity = Vector2.Lerp(velocity * byTileId.GolfPhysics.ClubImpactDampening, velocity, byTileId.GolfPhysics.ImpactDampeningResistanceEfficiency * roughLandResistance); } entity.velocity = velocity; Projectile projectile = entity as Projectile; if (projectile != null) { projectile.timeLeft = 18000; if (projectile.ai[1] < 0f) { projectile.ai[1] = 0f; } projectile.ai[1] += 1f; projectile.localAI[1] = 1f; Main.LocalGolfState.RecordSwing(projectile); } }
public static Vector2 RaycastNear(this Vector2 pos) { Tile tile = Framing.GetTileSafely(pos); Tile under = Framing.GetTileSafely((pos + Vector2.UnitY).ToTileCoordinates()); Tile over = Framing.GetTileSafely((pos - Vector2.UnitY).ToTileCoordinates()); Vector2 near1 = pos; Vector2 near2 = pos; while (!over.active() || tile.active()) { near1.Y -= 1; over = Framing.GetTileSafely(near1.ToTileCoordinates()); } while (!under.active() || tile.active()) // while under tile inactive or down tile active { near2.Y += 1; under = Framing.GetTileSafely(near2.ToTileCoordinates()); } float dist1 = Vector2.Distance(pos, near1); float dist2 = Vector2.Distance(pos, near2); if (dist1 > dist2) { return(near2); } return(near1); }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; Point point; Point origin = position.ToTileCoordinates(); while (!WorldUtils.Find(position.ToTileCoordinates(), Searches.Chain(new Searches.Down(1), new GenCondition[] { new Conditions.IsSolid() }), out point)) { position.Y++; origin = position.ToTileCoordinates(); } return(true); }
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints) { Point[] array = new Point[4]; int num = 0; Point point = Center.ToTileCoordinates(); for (int i = -5; i <= 5; i += 2) { if (i == -1 || i == 1) { continue; } for (int j = -5; j < 12; j++) { int num2 = point.X + i * 2; int num3 = point.Y + j; if ((WorldGen.SolidTile(num2, num3) || TileID.Sets.Platforms[Framing.GetTileSafely(num2, num3).type]) && (!Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1) || (!Collision.SolidTiles(num2, num2, num3 - 3, num3 - 1) && !Collision.SolidTiles(num2 + 1, num2 + 1, num3 - 3, num3 - 2) && !Collision.SolidTiles(num2 - 1, num2 - 1, num3 - 3, num3 - 2)))) { array[num++] = new Point(num2, num3); break; } } } if (num != 4) { spawnPoints = null; return(false); } spawnPoints = array; return(true); }
public override void Kill(int timeLeft) { Player player = Main.player[projectile.owner]; if (projectile.localAI[1] == 1) { player.fullRotation = 0; } if (projectile.ai[1] >= 226 && projectile.ai[0] == 2) { Vector2 posi = new Vector2(player.Center.X + 64 * projectile.direction * projectile.scale, player.position.Y + player.height + 4); Point pos = posi.ToTileCoordinates(); Tile tileSafely = Framing.GetTileSafely(pos.X, pos.Y); for (int d = 0; d < 80; d++) { Dust dust = Main.dust[WorldGen.KillTile_MakeTileDust(pos.X, pos.Y, tileSafely)]; dust.velocity.X = dust.velocity.X + Main.rand.Next(-10, 10) * 0.3f; dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-12, -6) * 0.4f; } Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 70); if (player.gravDir == -1) { Projectile.NewProjectile(player.Center.X + 48 * projectile.direction * projectile.scale, projectile.Center.Y, projectile.direction * 8f, 0f, mod.ProjectileType("GrogWaveFlipped"), (int)(projectile.damage * 3.5f), projectile.knockBack * 2.5f, projectile.owner); } else { Projectile.NewProjectile(player.Center.X + 48 * projectile.direction * projectile.scale, projectile.Center.Y, projectile.direction * 8f, 0f, mod.ProjectileType("GrogWave"), (int)(projectile.damage * 3.5f), projectile.knockBack * 2.5f, projectile.owner); } player.fullRotation = 0f; } }
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints) { Point[] pointArray = new Point[4]; int num1 = 0; Point tileCoordinates = Center.ToTileCoordinates(); int num2 = -5; while (num2 <= 5) { if (num2 != -1 && num2 != 1) { for (int index = -5; index < 12; ++index) { int i = tileCoordinates.X + num2 * 2; int j = tileCoordinates.Y + index; if (WorldGen.SolidTile(i, j) && !Collision.SolidTiles(i - 1, i + 1, j - 3, j - 1)) { pointArray[num1++] = new Point(i, j); break; } } } num2 += 2; } if (num1 != 4) { spawnPoints = (Point[])null; return(false); } spawnPoints = pointArray; return(true); }
public void DrawToDrawData(List <DrawData> drawDataList, int selectionMode) { Main.instance.LoadProjectile(734); Asset <Texture2D> val = TextureAssets.Projectile[734]; Rectangle rectangle = val.Frame(1, 8, 0, _frameNumber); Color color = Lighting.GetColor(_position.ToTileCoordinates()); color = Color.Lerp(color, Color.White, 0.5f); color *= _opacity; DrawData drawData = new DrawData(val.get_Value(), _position - Main.screenPosition, rectangle, color, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None, 0); drawDataList.Add(drawData); for (float num = 0f; num < 1f; num += 0.34f) { DrawData item = drawData; item.color = new Color(127, 50, 127, 0) * _opacity; item.scale *= 1.1f; float x = (Main.GlobalTimeWrappedHourly / 5f * ((float)Math.PI * 2f)).ToRotationVector2().X; item.color *= x * 0.1f + 0.3f; item.position += ((Main.GlobalTimeWrappedHourly / 5f + num) * ((float)Math.PI * 2f)).ToRotationVector2() * (x * 1f + 2f); drawDataList.Add(item); } if (selectionMode != 0) { int num2 = (color.R + color.G + color.B) / 3; if (num2 > 10) { Color selectionGlowColor = Colors.GetSelectionGlowColor(selectionMode == 2, num2); drawData = new DrawData(TextureAssets.Extra[93].get_Value(), _position - Main.screenPosition, rectangle, selectionGlowColor, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None, 0); drawDataList.Add(drawData); } } }
/// <summary> /// Paints tiles between the 2 provided world coordinates /// </summary> /// <param name="start">The starting position of the line to paint. Expects values in world coordinates</param> /// <param name="end">The ending position of the line to paint. Expects values in world coordinates</param> /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param> /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param> /// <param name="paintedTiles">A list of all the tiles that were updated in this function</param> public static void paintBetweenPoints(Vector2 start, Vector2 end, PaintData data, List <Point> paintedTiles = null, bool useWorldGen = false) { if (!(data.blocksAllowed || data.wallsAllowed)) { return; } Vector2 unitVector = end - start; float distance = unitVector.Length(); unitVector.Normalize(); int iterations = (int)Math.Ceiling(distance / 8f); int count = 0; for (int i = 0; i < iterations; i++) { Vector2 pos = start + (unitVector * i * 8); if (paint(pos, data, useWorldGen)) { count++; if (paintedTiles != null) { Point tPos = pos.ToTileCoordinates(); if (!paintedTiles.Contains(tPos)) { paintedTiles.Add(tPos); } } } } }
// Token: 0x0600127E RID: 4734 RVA: 0x00417EC4 File Offset: 0x004160C4 public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints) { Point[] array = new Point[4]; int num = 0; Point point = Center.ToTileCoordinates(); for (int i = -5; i <= 5; i += 2) { if (i != -1 && i != 1) { for (int j = -5; j < 12; j++) { int num2 = point.X + i * 2; int num3 = point.Y + j; if (WorldGen.SolidTile(num2, num3) && !Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1)) { array[num++] = new Point(num2, num3); break; } } } } if (num != 4) { spawnPoints = null; return(false); } spawnPoints = array; return(true); }
public static bool PlotTileTale(Vector2 start, Vector2 end, float width, Utils.PerLinePoint plot) { float single1 = width / 2f; Vector2 vector2 = end - start; Vector2 vector21 = vector2 / vector2.Length(); Vector2 vector22 = new Vector2(-vector21.Y, vector21.X); Point point3 = start.ToTileCoordinates(); Point point4 = end.ToTileCoordinates(); int num = 0; Utils.PlotLine(point3.X, point3.Y, point4.X, point4.Y, (int x, int y) => { num++; return(true); }, true); num--; int num1 = 0; return(Utils.PlotLine(point3.X, point3.Y, point4.X, point4.Y, (int x, int y) => { float single = 1f - (float)num1 / (float)num; num1++; Point tileCoordinates = (start - ((vector22 * single1) * single)).ToTileCoordinates(); Point point = (start + ((vector22 * single1) * single)).ToTileCoordinates(); Point point1 = new Point(tileCoordinates.X - point3.X, tileCoordinates.Y - point3.Y); Point point2 = new Point(point.X - point3.X, point.Y - point3.Y); return Utils.PlotLine(x + point1.X, y + point1.Y, x + point2.X, y + point2.Y, plot, false); }, true)); }
public static void CheckArenaScore( Vector2 arenaCenter, out Point xLeftEnd, out Point xRightEnd, int walkerWidthInTiles = 5, int walkerHeightInTiles = 10) { bool showDebug = false; Point tileCoordinates = arenaCenter.ToTileCoordinates(); xLeftEnd = xRightEnd = tileCoordinates; int bottomY; Collision.ExpandVertically(tileCoordinates.X, tileCoordinates.Y, out int _, out bottomY, 0, 4); tileCoordinates.Y = bottomY; if (showDebug) { Dust.QuickDust(tileCoordinates, Color.Blue).scale = 5f; } Point lastIteratedFloorSpot1; StrayMethods.SendWalker(tileCoordinates, walkerHeightInTiles, -1, out int _, out lastIteratedFloorSpot1, 120, showDebug); Point lastIteratedFloorSpot2; StrayMethods.SendWalker(tileCoordinates, walkerHeightInTiles, 1, out int _, out lastIteratedFloorSpot2, 120, showDebug); ++lastIteratedFloorSpot1.X; --lastIteratedFloorSpot2.X; if (showDebug) { Dust.QuickDustLine(lastIteratedFloorSpot1.ToWorldCoordinates(8f, 8f), lastIteratedFloorSpot2.ToWorldCoordinates(8f, 8f), 50f, Color.Pink); } xLeftEnd = lastIteratedFloorSpot1; xRightEnd = lastIteratedFloorSpot2; }
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints) { Point[] array = new Point[4]; int num = 0; Point point = Center.ToTileCoordinates(); for (int i = -5; i <= 5; i += 2) { if (i != -1 && i != 1) { for (int j = -5; j < 12; j++) { int num2 = point.X + i * 2; int num3 = point.Y + j; if (WorldGen.SolidTile(num2, num3) && !Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1)) { array[num++] = new Point(num2, num3); break; } } } } if (num != 4) { spawnPoints = null; return false; } spawnPoints = array; return true; }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { bool immune = false; foreach (int k in ElementsAwoken.instakillImmune) { if (target.type == k) { immune = true; } } if (!immune && target.active && target.damage > 0 && !target.dontTakeDamage && !target.boss && target.lifeMax < 1000) { Vector2 newPos = new Vector2(target.Center.X, target.Center.Y); bool isntColliding = false; int num = 0; while (!isntColliding && num < 300) { num++; newPos = new Vector2(target.Center.X + Main.rand.Next(-300, 300), target.Center.Y + Main.rand.Next(-300, 300)); Point newPoint = newPos.ToTileCoordinates(); bool colliding = Main.tile[newPoint.X, newPoint.Y].nactive() && Main.tileSolid[(int)Main.tile[newPoint.X, newPoint.Y].type] && !Main.tileSolidTop[(int)Main.tile[newPoint.X, newPoint.Y].type] && Main.tile[newPoint.X, newPoint.Y].type != TileID.Rope; if (!colliding) { isntColliding = true; } } CircleDust(target); target.Center = newPos; CircleDust(target); } }
public override bool UseItem(Player player) { Terraria.Audio.LegacySoundStyle hitSound = SoundID.Item1; Vector2 position = GetLightPosition(player); //Vector2 location = hitbox.Location.ToVector2(); Point tileLocation = position.ToTileCoordinates(); ModTile tile = TileLoader.GetTile(Main.tile[tileLocation.X, tileLocation.Y].type); if (tile == null) { return(false); } switch (tile.soundType & 3) { case 0: hitSound = SoundID.Item11; break; case 1: hitSound = SoundID.Item12; break; case 2: hitSound = SoundID.Item13; break; case 3: hitSound = SoundID.Item14; break; } Main.PlaySound(hitSound, position); return(true); }
private Vector2 DrawWhip(Projectile proj, List <Vector2> controlPoints, SpriteBatch spriteBatch) { Texture2D value = ModContent.GetTexture(Texture); Rectangle rectangle = value.Frame(1, 5); int height = rectangle.Height; rectangle.Height -= 2; Vector2 vector = rectangle.Size() / 2f; Vector2 vector2 = controlPoints[0]; for (int i = 0; i < controlPoints.Count - 1; i++) { bool flag = true; Vector2 origin = vector; switch (i) { case 0: origin.Y -= 4f; break; case 3: rectangle.Y = height; break; case 5: case 7: case 9: case 11: case 13: rectangle.Y = height * 2; break; case 15: case 17: rectangle.Y = height * 3; break; case 19: rectangle.Y = height * 4; break; default: flag = false; break; } Vector2 vector3 = controlPoints[i]; Vector2 vector4 = controlPoints[i + 1] - vector3; if (flag) { float rotation = vector4.ToRotation() - (float)Math.PI / 2f; Color alpha = proj.GetAlpha(GetColor(vector3.ToTileCoordinates())); spriteBatch.Draw(value, vector2 - Main.screenPosition, rectangle, alpha, rotation, origin, 1f, SpriteEffects.None, 0f); handPos = new Rectangle((int)vector2.X, (int)vector2.Y, rectangle.Width, rectangle.Height); ItemCheck_MeleeHitNPCs(player.HeldItem, handPos, (int)(player.HeldItem.damage * player.minionDamage), player.HeldItem.knockBack); } vector2 += vector4; } return(vector2); }
public static void HitGolfBall(Entity entity, Vector2 velocity, float roughLandResistance) { Vector2 bottom = entity.Bottom; ++bottom.Y; Point tileCoordinates = bottom.ToTileCoordinates(); Tile tile = Main.tile[tileCoordinates.X, tileCoordinates.Y]; if (tile != null && tile.active()) { TileMaterial byTileId = TileMaterials.GetByTileId(tile.type); velocity = Vector2.Lerp(velocity * byTileId.GolfPhysics.ClubImpactDampening, velocity, byTileId.GolfPhysics.ImpactDampeningResistanceEfficiency * roughLandResistance); } entity.velocity = velocity; if (!(entity is Projectile golfBall)) { return; } golfBall.timeLeft = 18000; if ((double)golfBall.ai[1] < 0.0) { golfBall.ai[1] = 0.0f; } ++golfBall.ai[1]; golfBall.localAI[1] = 1f; Main.LocalGolfState.RecordSwing(golfBall); }
public static void CheckArenaScore(Vector2 arenaCenter, out Point xLeftEnd, out Point xRightEnd, int walkerWidthInTiles = 5, int walkerHeightInTiles = 10) { bool showDebug = false; Point tileCoordinates = arenaCenter.ToTileCoordinates(); xLeftEnd = xRightEnd = tileCoordinates; int topY; int bottomY; Collision.ExpandVertically((int)tileCoordinates.X, (int)tileCoordinates.Y, out topY, out bottomY, 0, 4); tileCoordinates.Y = (__Null)bottomY; if (showDebug) { Dust.QuickDust(tileCoordinates, Color.get_Blue()).scale = 5f; } int distanceCoveredInTiles1; Point lastIteratedFloorSpot1; StrayMethods.SendWalker(tileCoordinates, walkerHeightInTiles, -1, out distanceCoveredInTiles1, out lastIteratedFloorSpot1, 120, showDebug); int distanceCoveredInTiles2; Point lastIteratedFloorSpot2; StrayMethods.SendWalker(tileCoordinates, walkerHeightInTiles, 1, out distanceCoveredInTiles2, out lastIteratedFloorSpot2, 120, showDebug); // ISSUE: explicit reference operation // ISSUE: variable of a reference type __Null& local1 = @lastIteratedFloorSpot1.X; // ISSUE: cast to a reference type // ISSUE: explicit reference operation int num1 = ^ (int&)local1 + 1;
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { List <Vector2> list = new List <Vector2>(); FillWhipControlPoints(projectile, list); Texture2D value = mod.GetTexture("Projectiles/Whips/WhipTexture"); Microsoft.Xna.Framework.Rectangle value2 = value.Frame(); Vector2 origin = new Vector2(value2.Width / 2, 2f); Microsoft.Xna.Framework.Color originalColor = Microsoft.Xna.Framework.Color.White; Vector2 value3 = list[0]; for (int i = 0; i < list.Count - 1; i++) { Vector2 vector = list[i]; Vector2 vector2 = list[i + 1] - vector; float rotation = vector2.ToRotation() - (float)Math.PI / 2f; Microsoft.Xna.Framework.Color color = GetColor(vector.ToTileCoordinates(), originalColor); Vector2 scale = new Vector2(1f, (vector2.Length() + 2f) / (float)value2.Height); spriteBatch.Draw(value, value3 - Main.screenPosition, value2, color, rotation, origin, scale, SpriteEffects.None, 0f); value3 += vector2; } DrawWhip(projectile, list, spriteBatch); return(false); }
public override void Kill(int timeLeft) { int grav = 1; if (projectile.velocity.Y < 0) { grav = -1; } Vector2 posi = new Vector2(projectile.position.X, projectile.position.Y + 4 * grav); Point pos = posi.ToTileCoordinates(); Tile tileSafely = Framing.GetTileSafely(pos.X, pos.Y); if (tileSafely.active()) { Tile tileSafely2 = Framing.GetTileSafely(pos.X, pos.Y - 1 * grav); if ((!tileSafely2.active() || !Main.tileSolid[(int)tileSafely2.type] || Main.tileSolidTop[(int)tileSafely2.type])) { for (int d = 0; d < 6; d++) { Dust dust = Main.dust[WorldGen.KillTile_MakeTileDust(pos.X, pos.Y, tileSafely)]; dust.velocity.Y = (dust.velocity.Y - 5) * Main.rand.NextFloat() * grav; } Projectile.NewProjectile(projectile.Center.X, (pos.Y * 16) - 8 * grav, projectile.velocity.X * 15, -6 * grav, mod.ProjectileType("DragonToothWave2"), projectile.damage, projectile.knockBack, projectile.owner); } } }
public void TryDigging( Player player, Vector2 trackWorldPosition, int digDirectionX, int digDirectionY) { digDirectionY = 0; Point tileCoordinates = trackWorldPosition.ToTileCoordinates(); if (Framing.GetTileSafely(tileCoordinates).type != (ushort)314 || (double)tileCoordinates.Y < Main.worldSurface) { return; } Point point1 = tileCoordinates; point1.X += digDirectionX; point1.Y += digDirectionY; if (this.AlreadyLeadsIntoWantedTrack(tileCoordinates, point1) || digDirectionY == 0 && (this.AlreadyLeadsIntoWantedTrack(tileCoordinates, new Point(point1.X, point1.Y - 1)) || this.AlreadyLeadsIntoWantedTrack(tileCoordinates, new Point(point1.X, point1.Y + 1)))) { return; } int num = 5; if (digDirectionY != 0) { num = 5; } Point point2 = point1; Point point3 = point2; point3.Y -= num - 1; int x1 = point3.X; for (int y = point3.Y; y <= point2.Y; ++y) { if (!this.CanGetPastTile(x1, y) || !this.HasPickPower(player, x1, y)) { return; } } if (!this.CanConsumeATrackItem(player)) { return; } int x2 = point3.X; for (int y = point3.Y; y <= point2.Y; ++y) { this.MineTheTileIfNecessary(x2, y); } this.ConsumeATrackItem(player); this.PlaceATrack(point1.X, point1.Y); player.velocity.X = MathHelper.Clamp(player.velocity.X, -1f, 1f); if (this.DoTheTracksConnectProperly(tileCoordinates, point1)) { return; } this.CorrectTrackConnections(tileCoordinates, point1); }
private void SetEmberGladesPoint() { Vector2 world = TAZPlayer.GetEmberGladesTeleportPosition(); if (world != Vector2.Zero) { Point point = world.ToTileCoordinates(); } }
private void MakeLightning() { Vector2 start = new Vector2(projectile.Center.X, 0); Point endTile = start.ToTileCoordinates(); Tile tile; do { endTile.Y++; tile = Main.tile[endTile.X, endTile.Y]; }while (tile == null || (Main.tileSolid[tile.type] && !Main.tile[endTile.X, endTile.Y].active()) || TileID.Sets.Platforms[tile.type]); Vector2 end = endTile.ToVector2() * 16f + Vector2.UnitX * 8f; Line line = new Line(start, end); lines = new List <List <Line> >(); lines.Add(new List <Line>()); lines[0].Add(line); for (int steps = 0; steps < 5; steps++) { for (int index = 0; index < lines[0].Count; index += 2) { JitterLine(index, lines[0]); } } int sincePrev = 0; for (int k = 0; k < lines[0].Count - 6; k++) { if (sincePrev <= 0 && Main.rand.Next(7) == 0) { lines.Add(new List <Line>()); int index = lines.Count - 1; Vector2 strandStart = lines[0][k].start; Vector2 strandEnd = strandStart + new Vector2( Main.rand.Next(2) == 0 ? Main.rand.NextFloat(-300f, -40f) : Main.rand.NextFloat(40f, 300f), Main.rand.NextFloat(50f, 300f)); Line strand = new Line(strandStart, strandEnd); lines[index].Add(strand); for (int steps = 0; steps < 3; steps++) { for (int index2 = 0; index2 < lines[index].Count; index2 += 2) { JitterLine(index2, lines[index]); } } sincePrev = Main.rand.Next(3, 7); } sincePrev--; } }
public void NewDustSlowed(Vector2 pos, int w, int h, int type, int interval) { Point tPos = pos.ToTileCoordinates(); if (gameCounter % interval == 0) { int d = Dust.NewDust(pos, w, h, type, 0f, 0f, 0, Color.White, 0.9f); } }
public static Node NodeFromCoordinates(PathGrid grid, Vector2 position) { TileCoordinates coords = position.ToTileCoordinates(); coords.X = Math.Clamp(coords.X, 0, GameWorld.WORLD_WIDTH); coords.Y = Math.Clamp(coords.Y, 0, GameWorld.WORLD_HEIGHT); return(grid.Grid[coords.X, coords.Y]); }
public void AddChumLocation(Vector2 spot) { Point key = spot.ToTileCoordinates(); int value = 0; _chumCountsPendingForThisFrame.TryGetValue(key, out value); value++; _chumCountsPendingForThisFrame[key] = value; }
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints) { Point[] point = new Point[4]; int num = 0; Point tileCoordinates = Center.ToTileCoordinates(); for (int i = -5; i <= 5; i = i + 2) { if (i != -1 && i != 1) { int num1 = -5; while (num1 < 12) { int x = tileCoordinates.X + i * 2; int y = tileCoordinates.Y + num1; if (!WorldGen.SolidTile(x, y) || Collision.SolidTiles(x - 1, x + 1, y - 3, y - 1)) { num1++; } else { int num2 = num; num = num2 + 1; point[num2] = new Point(x, y); break; } } } } if (num != 4) { spawnPoints = null; return false; } spawnPoints = point; return true; }
private static Vector2 FindCollision(Vector2 startPosition, Vector2 stopPosition) { int lastX = 0; int lastY = 0; Utils.PlotLine(startPosition.ToTileCoordinates(), stopPosition.ToTileCoordinates(), delegate(int x, int y) { lastX = x; lastY = y; return !WorldGen.SolidOrSlopedTile(x, y); }, false); return new Vector2((float)lastX * 16f, (float)lastY * 16f); }
public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle) { Point point = portalCenter.ToTileCoordinates(); int num = (int)Math.Round((double)(MathHelper.WrapAngle(portalAngle) / 0.7853982f)); int num2; int num3; if (num == 2 || num == -2) { num2 = ((num == 2) ? -1 : 1); num3 = 0; } else if (num == 0 || num == 4) { num2 = 0; num3 = ((num == 0) ? 1 : -1); } else if (num == -3 || num == 3) { num2 = ((num == -3) ? 1 : -1); num3 = -1; } else { if (num != 1 && num != -1) { Main.NewText(string.Concat(new object[] { "Broken portal! (over4s = ", num, " , ", portalAngle, ")" }), 255, 255, 255, false); return false; } num2 = ((num == -1) ? 1 : -1); num3 = 1; } if (num2 != 0 && num3 != 0) { int num4 = 3; if (num2 == -1 && num3 == 1) { num4 = 5; } if (num2 == 1 && num3 == -1) { num4 = 2; } if (num2 == 1 && num3 == 1) { num4 = 4; } num4--; return PortalHelper.SupportedSlope(point.X, point.Y, num4) && PortalHelper.SupportedSlope(point.X + num2, point.Y - num3, num4) && PortalHelper.SupportedSlope(point.X - num2, point.Y + num3, num4); } if (num2 != 0) { if (num2 == 1) { point.X--; } return PortalHelper.SupportedNormal(point.X, point.Y) && PortalHelper.SupportedNormal(point.X, point.Y - 1) && PortalHelper.SupportedNormal(point.X, point.Y + 1); } if (num3 != 0) { if (num3 == 1) { point.Y--; } return (PortalHelper.SupportedNormal(point.X, point.Y) && PortalHelper.SupportedNormal(point.X + 1, point.Y) && PortalHelper.SupportedNormal(point.X - 1, point.Y)) || (PortalHelper.SupportedHalfbrick(point.X, point.Y) && PortalHelper.SupportedHalfbrick(point.X + 1, point.Y) && PortalHelper.SupportedHalfbrick(point.X - 1, point.Y)); } return true; }
private static Vector2 FindCollision(Vector2 startPosition, Vector2 stopPosition) { int num = 0; int num1 = 0; Utils.PlotLine(startPosition.ToTileCoordinates(), stopPosition.ToTileCoordinates(), (int x, int y) => { num = x; num1 = y; return !WorldGen.SolidOrSlopedTile(x, y); }, false); return new Vector2((float)num * 16f, (float)num1 * 16f); }
public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle) { int num; int num1; Point tileCoordinates = portalCenter.ToTileCoordinates(); int num2 = (int)Math.Round((double)(MathHelper.WrapAngle(portalAngle) / 0.7853982f)); if (num2 == 2 || num2 == -2) { num = (num2 == 2 ? -1 : 1); num1 = 0; } else if (num2 == 0 || num2 == 4) { num = 0; num1 = (num2 == 0 ? 1 : -1); } else if (num2 == -3 || num2 == 3) { num = (num2 == -3 ? 1 : -1); num1 = -1; } else { if (num2 != 1 && num2 != -1) { object[] objArray = new object[] { "Broken portal! (over4s = ", num2, " , ", portalAngle, ")" }; Main.NewText(string.Concat(objArray), 255, 255, 255, false); return false; } num = (num2 == -1 ? 1 : -1); num1 = 1; } if (num != 0 && num1 != 0) { int num3 = 3; if (num == -1 && num1 == 1) { num3 = 5; } if (num == 1 && num1 == -1) { num3 = 2; } if (num == 1 && num1 == 1) { num3 = 4; } num3--; if (!PortalHelper.SupportedSlope(tileCoordinates.X, tileCoordinates.Y, num3) || !PortalHelper.SupportedSlope(tileCoordinates.X + num, tileCoordinates.Y - num1, num3)) { return false; } return PortalHelper.SupportedSlope(tileCoordinates.X - num, tileCoordinates.Y + num1, num3); } if (num != 0) { if (num == 1) { tileCoordinates.X = tileCoordinates.X - 1; } if (!PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) || !PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y - 1)) { return false; } return PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y + 1); } if (num1 == 0) { return true; } if (num1 == 1) { tileCoordinates.Y = tileCoordinates.Y - 1; } if (PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X + 1, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X - 1, tileCoordinates.Y)) { return true; } if (!PortalHelper.SupportedHalfbrick(tileCoordinates.X, tileCoordinates.Y) || !PortalHelper.SupportedHalfbrick(tileCoordinates.X + 1, tileCoordinates.Y)) { return false; } return PortalHelper.SupportedHalfbrick(tileCoordinates.X - 1, tileCoordinates.Y); }