TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ TryPlacingPortal()

static int Terraria.GameContent.PortalHelper.TryPlacingPortal ( Projectile theBolt,
Vector2 velocity,
Vector2 theCrashVelocity )
inlinestatic

Definition at line 319 of file PortalHelper.cs.

320 {
321 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
322 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
323 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
324 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
325 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
326 //IL_001a: Unknown result type (might be due to invalid IL or missing references)
327 //IL_001b: Unknown result type (might be due to invalid IL or missing references)
328 //IL_0020: Unknown result type (might be due to invalid IL or missing references)
329 //IL_0026: Unknown result type (might be due to invalid IL or missing references)
330 //IL_002b: Unknown result type (might be due to invalid IL or missing references)
331 //IL_0030: Unknown result type (might be due to invalid IL or missing references)
332 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
333 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
334 //IL_0040: Unknown result type (might be due to invalid IL or missing references)
335 //IL_0046: Unknown result type (might be due to invalid IL or missing references)
336 //IL_0054: Unknown result type (might be due to invalid IL or missing references)
337 //IL_0060: Unknown result type (might be due to invalid IL or missing references)
338 //IL_009c: Unknown result type (might be due to invalid IL or missing references)
339 //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
340 //IL_00b1: Unknown result type (might be due to invalid IL or missing references)
341 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
342 //IL_01a6: Unknown result type (might be due to invalid IL or missing references)
343 //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
344 //IL_01aa: Unknown result type (might be due to invalid IL or missing references)
345 //IL_01ab: Unknown result type (might be due to invalid IL or missing references)
346 //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
347 //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
348 //IL_010a: Unknown result type (might be due to invalid IL or missing references)
349 //IL_0112: Unknown result type (might be due to invalid IL or missing references)
350 //IL_01bf: Unknown result type (might be due to invalid IL or missing references)
351 //IL_01f2: Unknown result type (might be due to invalid IL or missing references)
352 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
353 //IL_0212: Unknown result type (might be due to invalid IL or missing references)
354 //IL_0213: Unknown result type (might be due to invalid IL or missing references)
355 //IL_021b: Unknown result type (might be due to invalid IL or missing references)
356 //IL_0127: Unknown result type (might be due to invalid IL or missing references)
357 //IL_012c: Unknown result type (might be due to invalid IL or missing references)
358 Vector2 vector = velocity / ((Vector2)(ref velocity)).Length();
359 Point position = FindCollision(theBolt.position, theBolt.position + velocity + vector * 32f).ToTileCoordinates();
360 Tile tile = Main.tile[position.X, position.Y];
361 Vector2 vector2 = default(Vector2);
362 ((Vector2)(ref vector2))._002Ector((float)(position.X * 16 + 8), (float)(position.Y * 16 + 8));
363 if (!WorldGen.SolidOrSlopedTile(tile))
364 {
365 return -1;
366 }
367 int num = tile.slope();
368 bool flag = tile.halfBrick();
369 for (int i = 0; i < (flag ? 2 : EDGES.Length); i++)
370 {
371 if (Vector2.Dot(EDGES[i], vector) > 0f && FindValidLine(position, (int)EDGES[i].Y, (int)(0f - EDGES[i].X), out var bestPosition))
372 {
373 ((Vector2)(ref vector2))._002Ector((float)(bestPosition.X * 16 + 8), (float)(bestPosition.Y * 16 + 8));
374 return AddPortal(theBolt, vector2 - EDGES[i] * (flag ? 0f : 8f), (float)Math.Atan2(EDGES[i].Y, EDGES[i].X) + (float)Math.PI / 2f, (int)theBolt.ai[0], theBolt.direction);
375 }
376 }
377 if (num != 0)
378 {
379 Vector2 value = SLOPE_EDGES[num - 1];
380 if (Vector2.Dot(value, -vector) > 0f && FindValidLine(position, -SLOPE_OFFSETS[num - 1].Y, SLOPE_OFFSETS[num - 1].X, out var bestPosition2))
381 {
382 ((Vector2)(ref vector2))._002Ector((float)(bestPosition2.X * 16 + 8), (float)(bestPosition2.Y * 16 + 8));
383 return AddPortal(theBolt, vector2, (float)Math.Atan2(value.Y, value.X) - (float)Math.PI / 2f, (int)theBolt.ai[0], theBolt.direction);
384 }
385 }
386 return -1;
387 }
static readonly Point[] SLOPE_OFFSETS
static int AddPortal(Projectile sourceProjectile, Vector2 position, float angle, int form, int direction)
static Vector2 FindCollision(Vector2 startPosition, Vector2 stopPosition)
static readonly Vector2[] EDGES
static bool FindValidLine(Point position, int xOffset, int yOffset, out Point bestPosition)
static readonly Vector2[] SLOPE_EDGES

References Terraria.GameContent.PortalHelper.AddPortal(), Terraria.GameContent.PortalHelper.EDGES, Terraria.GameContent.PortalHelper.FindCollision(), Terraria.GameContent.PortalHelper.FindValidLine(), Terraria.Tile.halfBrick(), Terraria.Tile.slope(), Terraria.GameContent.PortalHelper.SLOPE_EDGES, Terraria.GameContent.PortalHelper.SLOPE_OFFSETS, Terraria.WorldGen.SolidOrSlopedTile(), and Terraria.Main.tile.

Referenced by Terraria.Projectile.HandleMovement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: