1
0

TabletopParchisSetup.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using JetBrains.Annotations;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  4. namespace Content.Server.Tabletop
  5. {
  6. [UsedImplicitly]
  7. public sealed partial class TabletopParchisSetup : TabletopSetup
  8. {
  9. [DataField("redPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  10. public string RedPiecePrototype { get; private set; } = "RedTabletopPiece";
  11. [DataField("greenPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  12. public string GreenPiecePrototype { get; private set; } = "GreenTabletopPiece";
  13. [DataField("yellowPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  14. public string YellowPiecePrototype { get; private set; } = "YellowTabletopPiece";
  15. [DataField("bluePiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  16. public string BluePiecePrototype { get; private set; } = "BlueTabletopPiece";
  17. public override void SetupTabletop(TabletopSession session, IEntityManager entityManager)
  18. {
  19. var board = entityManager.SpawnEntity(BoardPrototype, session.Position);
  20. const float x1 = 6.25f;
  21. const float x2 = 4.25f;
  22. const float y1 = 6.25f;
  23. const float y2 = 4.25f;
  24. var center = session.Position;
  25. // Red pieces.
  26. EntityUid tempQualifier = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y1));
  27. session.Entities.Add(tempQualifier);
  28. EntityUid tempQualifier1 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y2));
  29. session.Entities.Add(tempQualifier1);
  30. EntityUid tempQualifier2 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y1));
  31. session.Entities.Add(tempQualifier2);
  32. EntityUid tempQualifier3 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y2));
  33. session.Entities.Add(tempQualifier3);
  34. // Green pieces.
  35. EntityUid tempQualifier4 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y1));
  36. session.Entities.Add(tempQualifier4);
  37. EntityUid tempQualifier5 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y2));
  38. session.Entities.Add(tempQualifier5);
  39. EntityUid tempQualifier6 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y1));
  40. session.Entities.Add(tempQualifier6);
  41. EntityUid tempQualifier7 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y2));
  42. session.Entities.Add(tempQualifier7);
  43. // Yellow pieces.
  44. EntityUid tempQualifier8 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y1));
  45. session.Entities.Add(tempQualifier8);
  46. EntityUid tempQualifier9 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y2));
  47. session.Entities.Add(tempQualifier9);
  48. EntityUid tempQualifier10 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y1));
  49. session.Entities.Add(tempQualifier10);
  50. EntityUid tempQualifier11 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y2));
  51. session.Entities.Add(tempQualifier11);
  52. // Blue pieces.
  53. EntityUid tempQualifier12 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y1));
  54. session.Entities.Add(tempQualifier12);
  55. EntityUid tempQualifier13 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y2));
  56. session.Entities.Add(tempQualifier13);
  57. EntityUid tempQualifier14 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y1));
  58. session.Entities.Add(tempQualifier14);
  59. EntityUid tempQualifier15 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y2));
  60. session.Entities.Add(tempQualifier15);
  61. }
  62. }
  63. }