1
0

WallmountLight.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Numerics;
  2. using Robust.Client.Placement;
  3. using Robust.Shared.Map;
  4. using Robust.Shared.Maths;
  5. namespace Content.Client.Placement.Modes
  6. {
  7. public sealed class WallmountLight : PlacementMode
  8. {
  9. public WallmountLight(PlacementManager pMan) : base(pMan)
  10. {
  11. }
  12. public override void AlignPlacementMode(ScreenCoordinates mouseScreen)
  13. {
  14. MouseCoords = ScreenToCursorGrid(mouseScreen);
  15. CurrentTile = GetTileRef(MouseCoords);
  16. if (pManager.CurrentPermission!.IsTile)
  17. {
  18. return;
  19. }
  20. var tileCoordinates = new EntityCoordinates(MouseCoords.EntityId, CurrentTile.GridIndices);
  21. Vector2 offset;
  22. switch (pManager.Direction)
  23. {
  24. case Direction.North:
  25. offset = new Vector2(0.5f, 1f);
  26. break;
  27. case Direction.South:
  28. offset = new Vector2(0.5f, 0f);
  29. break;
  30. case Direction.East:
  31. offset = new Vector2(1f, 0.5f);
  32. break;
  33. case Direction.West:
  34. offset = new Vector2(0f, 0.5f);
  35. break;
  36. default:
  37. return;
  38. }
  39. tileCoordinates = tileCoordinates.Offset(offset);
  40. MouseCoords = tileCoordinates;
  41. }
  42. public override bool IsValidPosition(EntityCoordinates position)
  43. {
  44. if (pManager.CurrentPermission!.IsTile)
  45. {
  46. return false;
  47. }
  48. else if (!RangeCheck(position))
  49. {
  50. return false;
  51. }
  52. return true;
  53. }
  54. }
  55. }