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

◆ DragBounds()

void Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.DragBounds ( Vector2 mouse)
inlineprivate

Definition at line 367 of file CaptureInterface.cs.

368 {
369 if (!EdgeAPinned || !EdgeBPinned)
370 {
371 bool flag = false;
372 if (Main.mouseLeft)
373 {
374 flag = true;
375 }
376 if (flag)
377 {
378 bool flag2 = true;
379 Point result;
380 if (!Main.mapFullscreen)
381 {
382 result = (Main.screenPosition + mouse).ToTileCoordinates();
383 }
384 else
385 {
386 flag2 = GetMapCoords((int)mouse.X, (int)mouse.Y, 0, out result);
387 }
388 if (flag2)
389 {
390 if (!EdgeAPinned)
391 {
392 EdgeAPinned = true;
393 EdgeA = result;
394 }
395 if (!EdgeBPinned)
396 {
397 EdgeBPinned = true;
398 EdgeB = result;
399 }
400 }
401 currentAim = 3;
402 caughtEdge = 1;
403 }
404 }
405 int num = Math.Min(EdgeA.X, EdgeB.X);
406 int num2 = Math.Min(EdgeA.Y, EdgeB.Y);
407 int num3 = Math.Abs(EdgeA.X - EdgeB.X);
408 int num4 = Math.Abs(EdgeA.Y - EdgeB.Y);
409 bool value = Main.player[Main.myPlayer].gravDir == -1f;
410 int num5 = 1 - value.ToInt();
411 int num6 = value.ToInt();
415 if (!Main.mapFullscreen)
416 {
417 value2 = Main.ReverseGravitySupport(new Rectangle(num * 16, num2 * 16, (num3 + 1) * 16, (num4 + 1) * 16));
418 value3 = Main.ReverseGravitySupport(new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth + 1, Main.screenHeight + 1));
420 if (result2.Width == 0 || result2.Height == 0)
421 {
422 return;
423 }
424 result2.Offset(-value3.X, -value3.Y);
425 }
426 else
427 {
428 GetMapCoords(num, num2, 1, out var result3);
429 GetMapCoords(num + num3 + 1, num2 + num4 + 1, 1, out var result4);
430 value2 = new Rectangle(result3.X, result3.Y, result4.X - result3.X, result4.Y - result3.Y);
431 value3 = new Rectangle(0, 0, Main.screenWidth + 1, Main.screenHeight + 1);
433 if (result2.Width == 0 || result2.Height == 0)
434 {
435 return;
436 }
437 result2.Offset(-value3.X, -value3.Y);
438 }
439 dragging = false;
440 if (!Main.mouseLeft)
441 {
442 currentAim = -1;
443 }
444 if (currentAim != -1)
445 {
446 dragging = true;
447 Point point = default(Point);
448 if (!Main.mapFullscreen)
449 {
450 point = Main.MouseWorld.ToTileCoordinates();
451 }
452 else
453 {
454 if (!GetMapCoords((int)mouse.X, (int)mouse.Y, 0, out var result5))
455 {
456 return;
457 }
458 point = result5;
459 }
460 switch (currentAim)
461 {
462 case 0:
463 case 1:
464 if (caughtEdge == 0)
465 {
466 EdgeA.Y = point.Y;
467 }
468 if (caughtEdge == 1)
469 {
470 EdgeB.Y = point.Y;
471 }
472 break;
473 case 2:
474 case 3:
475 if (caughtEdge == 0)
476 {
477 EdgeA.X = point.X;
478 }
479 if (caughtEdge == 1)
480 {
481 EdgeB.X = point.X;
482 }
483 break;
484 }
485 }
486 else
487 {
488 caughtEdge = -1;
490 drawbox.Offset(-value3.X, -value3.Y);
491 inMap = drawbox.Contains(mouse.ToPoint());
492 for (int i = 0; i < 4; i++)
493 {
495 bound.Inflate(8, 8);
496 if (!bound.Contains(mouse.ToPoint()))
497 {
498 continue;
499 }
500 currentAim = i;
501 switch (i)
502 {
503 case 0:
504 if (EdgeA.Y < EdgeB.Y)
505 {
507 }
508 else
509 {
511 }
512 break;
513 case 1:
514 if (EdgeA.Y >= EdgeB.Y)
515 {
517 }
518 else
519 {
521 }
522 break;
523 case 2:
524 if (EdgeA.X < EdgeB.X)
525 {
526 caughtEdge = 0;
527 }
528 else
529 {
530 caughtEdge = 1;
531 }
532 break;
533 case 3:
534 if (EdgeA.X >= EdgeB.X)
535 {
536 caughtEdge = 0;
537 }
538 else
539 {
540 caughtEdge = 1;
541 }
542 break;
543 }
544 break;
545 }
546 }
548 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Abs(double value)
Rectangle GetBound(Rectangle drawbox, int boundIndex)
static bool GetMapCoords(int PinX, int PinY, int Goal, out Point result)
static Rectangle Intersect(Rectangle value1, Rectangle value2)
Definition Rectangle.cs:143

References System.Math.Abs(), Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.caughtEdge, Terraria.Graphics.Capture.CaptureInterface.ConstraintPoints(), System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.currentAim, Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.dragging, Terraria.Graphics.Capture.CaptureInterface.EdgeA, Terraria.Graphics.Capture.CaptureInterface.EdgeAPinned, Terraria.Graphics.Capture.CaptureInterface.EdgeB, Terraria.Graphics.Capture.CaptureInterface.EdgeBPinned, Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.GetBound(), Terraria.Graphics.Capture.CaptureInterface.GetMapCoords(), Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.inMap, Microsoft.Xna.Framework.Rectangle.Intersect(), Terraria.Main.mapFullscreen, System.Math.Min(), Terraria.Main.mouseLeft, Terraria.Main.MouseWorld, Terraria.Main.myPlayer, Terraria.Main.player, Terraria.Main.ReverseGravitySupport(), Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, System.value, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.Graphics.Capture.CaptureInterface.ModeDragBounds.Update().