Inline UID

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:53:09 +01:00
parent 2654775bf0
commit 5cd42c9ad6
803 changed files with 3613 additions and 3577 deletions

View File

@@ -17,7 +17,7 @@ namespace Content.Server.Tabletop
{
var chessboard = entityManager.SpawnEntity(ChessBoardPrototype, session.Position.Offset(-1, 0));
session.Entities.Add(chessboard.Uid);
session.Entities.Add(chessboard);
SpawnPieces(session, entityManager, session.Position.Offset(-4.5f, 3.5f));
}
@@ -35,8 +35,10 @@ namespace Content.Server.Tabletop
SpawnPiecesRow(session, entityManager, "White", new MapCoordinates(x, y - 7 * separation, mapId), separation);
// Extra queens
session.Entities.Add(entityManager.SpawnEntity("BlackQueen", new MapCoordinates(x + 9 * separation + 9f / 32, y - 3 * separation, mapId)).Uid);
session.Entities.Add(entityManager.SpawnEntity("WhiteQueen", new MapCoordinates(x + 9 * separation + 9f / 32, y - 4 * separation, mapId)).Uid);
IEntity tempQualifier = entityManager.SpawnEntity("BlackQueen", new MapCoordinates(x + 9 * separation + 9f / 32, y - 3 * separation, mapId));
session.Entities.Add(tempQualifier);
IEntity tempQualifier1 = entityManager.SpawnEntity("WhiteQueen", new MapCoordinates(x + 9 * separation + 9f / 32, y - 4 * separation, mapId));
session.Entities.Add(tempQualifier1);
}
// TODO: refactor to load FEN instead
@@ -51,19 +53,24 @@ namespace Content.Server.Tabletop
switch (piecesRow[i])
{
case 'r':
session.Entities.Add(entityManager.SpawnEntity(color + "Rook", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier = entityManager.SpawnEntity(color + "Rook", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier);
break;
case 'n':
session.Entities.Add(entityManager.SpawnEntity(color + "Knight", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier1 = entityManager.SpawnEntity(color + "Knight", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier1);
break;
case 'b':
session.Entities.Add(entityManager.SpawnEntity(color + "Bishop", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier2 = entityManager.SpawnEntity(color + "Bishop", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier2);
break;
case 'q':
session.Entities.Add(entityManager.SpawnEntity(color + "Queen", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier3 = entityManager.SpawnEntity(color + "Queen", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier3);
break;
case 'k':
session.Entities.Add(entityManager.SpawnEntity(color + "King", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier4 = entityManager.SpawnEntity(color + "King", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier4);
break;
}
}
@@ -76,7 +83,8 @@ namespace Content.Server.Tabletop
for (int i = 0; i < 8; i++)
{
session.Entities.Add(entityManager.SpawnEntity(color + "Pawn", new MapCoordinates(x + i * separation, y, mapId)).Uid);
IEntity tempQualifier = entityManager.SpawnEntity(color + "Pawn", new MapCoordinates(x + i * separation, y, mapId));
session.Entities.Add(tempQualifier);
}
}
}

View File

@@ -35,28 +35,44 @@ namespace Content.Server.Tabletop
var center = session.Position;
// Red pieces.
session.Entities.Add(entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y2)).Uid);
session.Entities.Add(entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y2)).Uid);
IEntity tempQualifier = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y1));
session.Entities.Add(tempQualifier);
IEntity tempQualifier1 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x1, -y2));
session.Entities.Add(tempQualifier1);
IEntity tempQualifier2 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y1));
session.Entities.Add(tempQualifier2);
IEntity tempQualifier3 = entityManager.SpawnEntity(RedPiecePrototype, center.Offset(-x2, -y2));
session.Entities.Add(tempQualifier3);
// Green pieces.
session.Entities.Add(entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y2)).Uid);
session.Entities.Add(entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y2)).Uid);
IEntity tempQualifier4 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y1));
session.Entities.Add(tempQualifier4);
IEntity tempQualifier5 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x1, -y2));
session.Entities.Add(tempQualifier5);
IEntity tempQualifier6 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y1));
session.Entities.Add(tempQualifier6);
IEntity tempQualifier7 = entityManager.SpawnEntity(GreenPiecePrototype, center.Offset(x2, -y2));
session.Entities.Add(tempQualifier7);
// Yellow pieces.
session.Entities.Add(entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y2)).Uid);
session.Entities.Add(entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y2)).Uid);
IEntity tempQualifier8 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y1));
session.Entities.Add(tempQualifier8);
IEntity tempQualifier9 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x1, y2));
session.Entities.Add(tempQualifier9);
IEntity tempQualifier10 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y1));
session.Entities.Add(tempQualifier10);
IEntity tempQualifier11 = entityManager.SpawnEntity(YellowPiecePrototype, center.Offset(x2, y2));
session.Entities.Add(tempQualifier11);
// Blue pieces.
session.Entities.Add(entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y2)).Uid);
session.Entities.Add(entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y1)).Uid);
session.Entities.Add(entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y2)).Uid);
IEntity tempQualifier12 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y1));
session.Entities.Add(tempQualifier12);
IEntity tempQualifier13 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x1, y2));
session.Entities.Add(tempQualifier13);
IEntity tempQualifier14 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y1));
session.Entities.Add(tempQualifier14);
IEntity tempQualifier15 = entityManager.SpawnEntity(BluePiecePrototype, center.Offset(-x2, y2));
session.Entities.Add(tempQualifier15);
}
}
}

View File

@@ -46,13 +46,13 @@ namespace Content.Server.Tabletop
if (!EntityManager.TryGetEntity(msg.MovedEntityUid, out var movedEntity))
return;
if (!EntityManager.HasComponent<TabletopDraggableComponent>(movedEntity.Uid))
if (!EntityManager.HasComponent<TabletopDraggableComponent>(movedEntity))
return;
// TODO: some permission system, disallow movement if you're not permitted to move the item
// Move the entity and dirty it (we use the map ID from the entity so noone can try to be funny and move the item to another map)
var transform = EntityManager.GetComponent<TransformComponent>(movedEntity.Uid);
var transform = EntityManager.GetComponent<TransformComponent>(movedEntity);
var entityCoordinates = new EntityCoordinates(_mapManager.GetMapEntityId(transform.MapID), msg.Coordinates.Position);
transform.Coordinates = entityCoordinates;
}
@@ -61,11 +61,11 @@ namespace Content.Server.Tabletop
{
var draggedEntity = EntityManager.GetEntity(msg.DraggedEntityUid);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<TabletopDraggableComponent?>(draggedEntity.Uid, out var draggableComponent)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<TabletopDraggableComponent?>(draggedEntity, out var draggableComponent)) return;
draggableComponent.DraggingPlayer = msg.DraggingPlayer;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(draggedEntity.Uid, out var appearance)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(draggedEntity, out var appearance)) return;
if (draggableComponent.DraggingPlayer != null)
{

View File

@@ -82,7 +82,7 @@ namespace Content.Server.Tabletop
if (session.Players.ContainsKey(player))
return;
if(IoCManager.Resolve<IEntityManager>().TryGetComponent<TabletopGamerComponent?>(attachedEntity.Uid, out var gamer))
if(IoCManager.Resolve<IEntityManager>().TryGetComponent<TabletopGamerComponent?>(attachedEntity, out var gamer))
CloseSessionFor(player, gamer.Tabletop, false);
// Set the entity as an absolute GAMER.
@@ -111,13 +111,13 @@ namespace Content.Server.Tabletop
if (!session.Players.TryGetValue(player, out var data))
return;
if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Uid, out TabletopGamerComponent? gamer))
if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out TabletopGamerComponent? gamer))
{
// We invalidate this to prevent an infinite feedback from removing the component.
gamer.Tabletop = EntityUid.Invalid;
// You stop being a gamer.......
IoCManager.Resolve<IEntityManager>().RemoveComponent<TabletopGamerComponent>(attachedEntity.Uid);
IoCManager.Resolve<IEntityManager>().RemoveComponent<TabletopGamerComponent>(attachedEntity);
}
session.Players.Remove(player);
@@ -149,9 +149,9 @@ namespace Content.Server.Tabletop
eyeComponent.Zoom = tabletop.CameraZoom;
// Add the user to the view subscribers. If there is no player session, just skip this step
_viewSubscriberSystem.AddViewSubscriber(camera.Uid, player);
_viewSubscriberSystem.AddViewSubscriber(camera, player);
return camera.Uid;
return camera;
}
}
}

View File

@@ -42,7 +42,7 @@ namespace Content.Server.Tabletop
if (!args.CanAccess || !args.CanInteract)
return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.User.Uid, out var actor))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.User, out var actor))
return;
Verb verb = new();
@@ -55,11 +55,11 @@ namespace Content.Server.Tabletop
private void OnTabletopActivate(EntityUid uid, TabletopGameComponent component, ActivateInWorldEvent args)
{
// Check that a player is attached to the entity.
if (!EntityManager.TryGetComponent(args.User.Uid, out ActorComponent? actor))
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
// Check that the entity can interact with the game board.
if(_actionBlockerSystem.CanInteract(args.User.Uid))
if(_actionBlockerSystem.CanInteract(args.User))
OpenSessionFor(actor.PlayerSession, uid);
}
@@ -97,9 +97,9 @@ namespace Content.Server.Tabletop
if (!EntityManager.EntityExists(gamer.Tabletop))
continue;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(gamer.Owner.Uid, out ActorComponent? actor))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(gamer.Owner, out ActorComponent? actor))
{
IoCManager.Resolve<IEntityManager>().RemoveComponent<TabletopGamerComponent>(gamer.Owner.Uid);
IoCManager.Resolve<IEntityManager>().RemoveComponent<TabletopGamerComponent>(gamer.Owner);
return;
};