public GridStartupEvent(EntityUid uid, GridId gridId) { EntityUid = uid; GridId = gridId; }
public async Task BuckledDyingDropItemsTest() { var server = StartServer(); IEntity human = null; IEntity chair = null; BuckleComponent buckle = null; StrapComponent strap = null; HandsComponent hands = null; IDamageableComponent humanDamageable = null; server.Assert(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var mapId = new MapId(1); mapManager.CreateNewMapEntity(mapId); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.CreateGrid(mapId, gridId); var coordinates = grid.GridEntityId.ToCoordinates(); var tileManager = IoCManager.Resolve <ITileDefinitionManager>(); var tileId = tileManager["underplating"].TileId; var tile = new Tile(tileId); grid.SetTile(coordinates, tile); human = entityManager.SpawnEntity("HumanMob_Content", coordinates); chair = entityManager.SpawnEntity("ChairWood", coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.TryGetComponent(out strap)); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out humanDamageable)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity("RifleAk", coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); server.RunTicks(10); server.Assert(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.Hands) { Assert.NotNull(hands.GetItem(slot)); } // Banish our guy into the shadow realm humanDamageable.ChangeDamage(DamageClass.Brute, 1000000, true); }); server.RunTicks(10); server.Assert(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.Hands) { Assert.Null(hands.GetItem(slot)); } }); await server.WaitIdleAsync(); }
public IMapGrid getgrid(GridId mapId) { return(map.GetGrid(mapId)); }
public async Task BuckleUnbuckleCooldownRangeTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes }; var server = StartServer(options); IEntity human = null; IEntity chair = null; BuckleComponent buckle = null; StrapComponent strap = null; await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.GetGrid(gridId); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Default state, unbuckled Assert.True(human.TryGetComponent(out buckle)); Assert.NotNull(buckle); Assert.Null(buckle.BuckledTo); Assert.False(buckle.Buckled); Assert.True(ActionBlockerSystem.CanMove(human)); Assert.True(ActionBlockerSystem.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Default state, no buckled entities, strap Assert.True(chair.TryGetComponent(out strap)); Assert.NotNull(strap); Assert.IsEmpty(strap.BuckledEntities); Assert.Zero(strap.OccupiedSize); // Side effects of buckling Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); Assert.True(((BuckleComponentState)buckle.GetComponentState()).Buckled); Assert.False(ActionBlockerSystem.CanMove(human)); Assert.False(ActionBlockerSystem.CanChangeDirection(human)); Assert.False(EffectBlockerSystem.CanFall(human)); Assert.That(human.Transform.WorldPosition, Is.EqualTo(chair.Transform.WorldPosition)); // Side effects of buckling for the strap Assert.That(strap.BuckledEntities, Does.Contain(human)); Assert.That(strap.OccupiedSize, Is.EqualTo(buckle.Size)); Assert.Positive(strap.OccupiedSize); // Trying to buckle while already buckled fails Assert.False(buckle.TryBuckle(human, chair)); // Trying to unbuckle too quickly fails Assert.False(buckle.TryUnbuckle(human)); Assert.False(buckle.ToggleBuckle(human, chair)); Assert.True(buckle.Buckled); }); // Wait enough ticks for the unbuckling cooldown to run out await server.WaitRunTicks(60); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Unbuckle Assert.True(buckle.TryUnbuckle(human)); Assert.Null(buckle.BuckledTo); Assert.False(buckle.Buckled); Assert.True(ActionBlockerSystem.CanMove(human)); Assert.True(ActionBlockerSystem.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Unbuckle, strap Assert.IsEmpty(strap.BuckledEntities); Assert.Zero(strap.OccupiedSize); // Re-buckling has no cooldown Assert.True(buckle.TryBuckle(human, chair)); Assert.True(buckle.Buckled); // On cooldown Assert.False(buckle.TryUnbuckle(human)); Assert.True(buckle.Buckled); Assert.False(buckle.ToggleBuckle(human, chair)); Assert.True(buckle.Buckled); Assert.False(buckle.ToggleBuckle(human, chair)); Assert.True(buckle.Buckled); }); // Wait enough ticks for the unbuckling cooldown to run out await server.WaitRunTicks(60); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Unbuckle Assert.True(buckle.TryUnbuckle(human)); Assert.False(buckle.Buckled); // Move away from the chair human.Transform.WorldPosition += (1000, 1000); // Out of range Assert.False(buckle.TryBuckle(human, chair)); Assert.False(buckle.TryUnbuckle(human)); Assert.False(buckle.ToggleBuckle(human, chair)); // Move near the chair human.Transform.WorldPosition = chair.Transform.WorldPosition + (0.5f, 0); // In range Assert.True(buckle.TryBuckle(human, chair)); Assert.True(buckle.Buckled); Assert.False(buckle.TryUnbuckle(human)); Assert.True(buckle.Buckled); Assert.False(buckle.ToggleBuckle(human, chair)); Assert.True(buckle.Buckled); // Force unbuckle Assert.True(buckle.TryUnbuckle(human, true)); Assert.False(buckle.Buckled); Assert.True(ActionBlockerSystem.CanMove(human)); Assert.True(ActionBlockerSystem.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Re-buckle Assert.True(buckle.TryBuckle(human, chair)); // Move away from the chair human.Transform.WorldPosition += (1, 0); }); await server.WaitRunTicks(1); await server.WaitAssertion(() => { // No longer buckled Assert.False(buckle.Buckled); Assert.Null(buckle.BuckledTo); Assert.IsEmpty(strap.BuckledEntities); }); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (galaxy != null) { SolidBrush red = new SolidBrush(Color.Gray); SolidBrush sel = new SolidBrush(Color.FromArgb(128, Color.Red)); Pen pen = new Pen(red); Rectangle imagesourceregion = GetSourceImageRegion(); // This is what we are displaying Point lypostop = galaxy.LYPos(new Point(imagesourceregion.Left, imagesourceregion.Top)); // convert the top of what displayed to lys. int lywidth = imagesourceregion.Width * galaxy.LYWidth / galaxy.PixelWidth; // work out the width of the displayed in ly. int lyheight = imagesourceregion.Height * galaxy.LYHeight / galaxy.PixelHeight; Rectangle imageviewport = GetImageViewPort(); // these are the pixels on the screen in which imagesourceregion is squashed into int[] xpos = new int[xlines.Length]; int[] zpos = new int[zlines.Length]; for (int x = 0; x < xlines.Length; x++) { int xly = xlines[x]; int pos = xly - lypostop.X; // where it is relative to left of image float offset = (float)pos / lywidth; // fraction across the image int px = imageviewport.Left + (int)(imageviewport.Width * offset); // shift to image viewport pixels xpos[x] = px; e.Graphics.DrawLine(pen, new Point(px, imageviewport.Top), new Point(px, imageviewport.Bottom)); } for (int z = 0; z < zlines.Length; z++) // in numberic order, so bottom of map first { int zly = zlines[z]; int pos = lypostop.Y - zly; // where it is relative to top of image, remembering top is highest float offset = (float)pos / lyheight; // fraction across the image int px = imageviewport.Top + (int)(imageviewport.Height * offset); // shift to image viewport pixels zpos[z] = px; e.Graphics.DrawLine(pen, new Point(imageviewport.Left, px), new Point(imageviewport.Right, px)); } //for (int x = -40000; x < 40000; x += 250) System.Diagnostics.Debug.WriteLine("{0} {1}", x, GridId.Id(x, 0)); for (int x = 0; x < xlines.Length - 1; x++) { for (int z = 0; z < zlines.Length - 1; z++) { int id = GridId.IdFromComponents(x, z); if (!includedgridid.Contains(id)) { int width = xpos[x + 1] - xpos[x] - 2; int height = zpos[z] - zpos[z + 1] - 2; // from bottom of map upwards //System.Diagnostics.Debug.WriteLine("{0},{1} => {2} {3} {4} {5}", x, z, xpos[x], zpos[z], width, height); e.Graphics.FillRectangle(sel, xpos[x] + 1, zpos[z + 1] + 1, width, height); } } } sel.Dispose(); pen.Dispose(); red.Dispose(); } }
/// <summary> /// Constructs a new instance of <see cref="MapGridComponentState"/>. /// </summary> /// <param name="gridIndex">Index of the grid this component is linked to.</param> public MapGridComponentState(GridId gridIndex, bool hasGravity) : base(NetIDs.MAP_GRID) { GridIndex = gridIndex; HasGravity = hasGravity; }
public GridInitializeEvent(EntityUid uid, GridId gridId) { EntityUid = uid; GridId = gridId; }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length < 5) { return; } if (!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) || !int.TryParse(args[2], out var id) || !float.TryParse(args[3], out var amount) || !bool.TryParse(args[4], out var ratio)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new MapIndices(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.SendText(player, "Invalid coordinates."); return; } if (tile.Air == null) { shell.SendText(player, "Can't remove gas from that tile."); return; } if (ratio) { tile.Air.RemoveRatio(amount); } else { tile.Air.Remove(amount); } gam.Invalidate(indices); }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length < 4) { return; } if (!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) || !int.TryParse(args[2], out var id) || !float.TryParse(args[3], out var temperature)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (temperature < Atmospherics.TCMB) { shell.SendText(player, "Invalid temperature."); return; } if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new MapIndices(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.SendText(player, "Invalid coordinates."); return; } if (tile.Air == null) { shell.SendText(player, "Can't change that tile's temperature."); return; } tile.Air.Temperature = temperature; gam.Invalidate(indices); }
public bool IsGridPaused(GridId gridId) { var grid = _mapManager.GetGrid(gridId); return(IsGridPaused(grid)); }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { var gasId = -1; var gas = (Gas)(-1); if (args.Length < 5) { return; } if (!int.TryParse(args[0], out var x) || !int.TryParse(args[1], out var y) || !int.TryParse(args[2], out var id) || !(int.TryParse(args[3], out gasId) || Enum.TryParse(args[3], true, out gas)) || !float.TryParse(args[4], out var moles)) { return; } if (gas != (Gas)(-1)) { gasId = (int)gas; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new MapIndices(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.SendText(player, "Invalid coordinates."); return; } if (tile.Air == null) { shell.SendText(player, "Can't add gas to that tile."); return; } if (gasId != -1) { tile.Air.AdjustMoles(gasId, moles); gam.Invalidate(indices); return; } tile.Air.AdjustMoles(gas, moles); gam.Invalidate(indices); }
public async Task ForceUnbuckleBuckleTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = PROTOTYPES }; var server = StartServer(options); IEntity human = null; IEntity chair = null; BuckleComponent buckle = null; await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var mapId = new MapId(1); mapManager.CreateNewMapEntity(mapId); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.CreateGrid(mapId, gridId); var coordinates = grid.GridEntityId.ToCoordinates(); var tileManager = IoCManager.Resolve <ITileDefinitionManager>(); var tileId = tileManager["underplating"].TileId; var tile = new Tile(tileId); grid.SetTile(coordinates, tile); human = entityManager.SpawnEntity("BuckleDummy", coordinates); chair = entityManager.SpawnEntity("StrapDummy", coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.HasComponent <StrapComponent>()); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Move the buckled entity away human.Transform.LocalPosition += (100, 0); }); await WaitUntil(server, () => !buckle.Buckled, 10); Assert.False(buckle.Buckled); await server.WaitAssertion(() => { // Move the now unbuckled entity back onto the chair human.Transform.LocalPosition -= (100, 0); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); }); await server.WaitRunTicks(60); await server.WaitAssertion(() => { // Still buckled Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); }); }
public void Execute(IConsoleShell shell, string argsOther, string[] args) { var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve <IEntityManager>(); GridId gridId; switch (args.Length) { case 0: if (player?.AttachedEntity is not { Valid : true } playerEntity) { shell.WriteLine("Only a player can run this command."); return; } gridId = entityManager.GetComponent <TransformComponent>(playerEntity).GridID; break; case 1: if (!int.TryParse(args[0], out var id)) { shell.WriteLine($"{args[0]} is not a valid integer."); return; } gridId = new GridId(id); break; default: shell.WriteLine(Help); return; } var mapManager = IoCManager.Resolve <IMapManager>(); if (!mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } if (!entityManager.EntityExists(grid.GridEntityId)) { shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity."); return; } var changed = 0; foreach (var child in entityManager.GetComponent <TransformComponent>(grid.GridEntityId).ChildEntities) { if (!entityManager.EntityExists(child)) { continue; } var valid = false; // Occluders should only count if the state of it right now is enabled. // This prevents issues with edge firelocks. if (entityManager.TryGetComponent <OccluderComponent>(child, out var occluder)) { valid |= occluder.Enabled; } // low walls & grilles valid |= entityManager.HasComponent <SharedCanBuildWindowOnTopComponent>(child); // cables valid |= entityManager.HasComponent <CableComponent>(child); // anything else that might need this forced valid |= child.HasTag("ForceFixRotations"); // override valid &= !child.HasTag("ForceNoFixRotations"); if (!valid) { continue; } if (entityManager.GetComponent <TransformComponent>(child).LocalRotation != Angle.Zero) { entityManager.GetComponent <TransformComponent>(child).LocalRotation = Angle.Zero; changed++; } } shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect."); }
public GridRemovalEvent(EntityUid uid, GridId gridId) { EntityUid = uid; GridId = gridId; }
public GasOverlayMessage(GridId gridIndices, List <(MapIndices, GasOverlayData)> overlayData)
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { GridId gridId; Gas? gas = null; switch (args.Length) { case 0: if (player == null) { shell.SendText(player, "A grid must be specified when the command isn't used by a player."); return; } if (player.AttachedEntity == null) { shell.SendText(player, "You have no entity to get a grid from."); return; } gridId = player.AttachedEntity.Transform.GridID; if (gridId == GridId.Invalid) { shell.SendText(player, "You aren't on a grid to delete gas from."); return; } break; case 1: { if (!int.TryParse(args[0], out var number)) { // Argument is a gas if (player == null) { shell.SendText(player, "A grid id must be specified if not using this command as a player."); return; } if (player.AttachedEntity == null) { shell.SendText(player, "You have no entity from which to get a grid id."); return; } gridId = player.AttachedEntity.Transform.GridID; if (gridId == GridId.Invalid) { shell.SendText(player, "You aren't on a grid to delete gas from."); return; } if (!Enum.TryParse <Gas>(args[0], true, out var parsedGas)) { shell.SendText(player, $"{args[0]} is not a valid gas name."); return; } gas = parsedGas; break; } // Argument is a grid gridId = new GridId(number); if (gridId == GridId.Invalid) { shell.SendText(player, $"{gridId} is not a valid grid id."); return; } break; } case 2: { if (!int.TryParse(args[0], out var first)) { shell.SendText(player, $"{args[0]} is not a valid integer for a grid id."); return; } gridId = new GridId(first); if (gridId == GridId.Invalid) { shell.SendText(player, $"{gridId} is not a valid grid id."); return; } if (!Enum.TryParse <Gas>(args[1], true, out var parsedGas)) { shell.SendText(player, $"{args[1]} is not a valid gas."); return; } gas = parsedGas; break; } default: shell.SendText(player, Help); return; } var mapManager = IoCManager.Resolve <IMapManager>(); if (!mapManager.TryGetGrid(gridId, out var grid)) { shell.SendText(player, $"No grid exists with id {gridId}"); return; } var entityManager = IoCManager.Resolve <IEntityManager>(); if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) { shell.SendText(player, $"Grid {gridId} has no entity."); return; } if (!gridEntity.TryGetComponent(out GridAtmosphereComponent? atmosphere)) { shell.SendText(player, $"Grid {gridId} has no {nameof(GridAtmosphereComponent)}"); return; } var tiles = 0; var moles = 0f; if (gas == null) { foreach (var tile in atmosphere) { if (tile.Air == null || tile.Air.Immutable) { continue; } tiles++; moles += tile.Air.TotalMoles; tile.Air.Clear(); atmosphere.Invalidate(tile.GridIndices); } } else { foreach (var tile in atmosphere) { if (tile.Air == null || tile.Air.Immutable) { continue; } tiles++; moles += tile.Air.TotalMoles; tile.Air.SetMoles(gas.Value, 0); atmosphere.Invalidate(tile.GridIndices); } } if (gas == null) { shell.SendText(player, $"Removed {moles} moles from {tiles} tiles."); return; } shell.SendText(player, $"Removed {moles} moles of gas {gas} from {tiles} tiles."); }
public GridCoordinates gpos(double x, double y, GridId gridId) { return(new GridCoordinates((float)x, (float)y, gridId)); }
public ReachableChunkRegionsDebugMessage(GridId gridId, Dictionary <int, Dictionary <int, List <Vector2> > > regions) { GridId = gridId; Regions = regions; }
public void Execute(IConsoleShell shell, string argsOther, string[] args) { var player = shell.Player as IPlayerSession; GridId gridId; switch (args.Length) { case 0: if (player?.AttachedEntity == null) { shell.WriteLine("Only a player can run this command."); return; } gridId = player.AttachedEntity.Transform.GridID; break; case 1: if (!int.TryParse(args[0], out var id)) { shell.WriteLine($"{args[0]} is not a valid integer."); return; } gridId = new GridId(id); break; default: shell.WriteLine(Help); return; } var mapManager = IoCManager.Resolve <IMapManager>(); if (!mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } var entityManager = IoCManager.Resolve <IEntityManager>(); if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) { shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity."); return; } var changed = 0; foreach (var childUid in gridEntity.Transform.ChildEntityUids) { if (!entityManager.TryGetEntity(childUid, out var childEntity)) { continue; } var valid = false; valid |= childEntity.HasComponent <OccluderComponent>(); valid |= childEntity.HasComponent <SharedCanBuildWindowOnTopComponent>(); valid |= childEntity.HasComponent <WindowComponent>(); if (!valid) { continue; } if (childEntity.Transform.LocalRotation != Angle.Zero) { childEntity.Transform.LocalRotation = Angle.Zero; changed++; } } shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect."); }
public ReachableCacheDebugMessage(GridId gridId, Dictionary <int, List <Vector2> > regions, bool cached) { GridId = gridId; Regions = regions; Cached = cached; }
public async Task BuckledDyingDropItemsTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes }; var server = StartServer(options); IEntity human = null; BuckleComponent buckle = null; HandsComponent hands = null; IBody body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.GetGrid(gridId); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); IEntity chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.HasComponent <StrapComponent>()); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.Hands) { Assert.NotNull(hands.GetItem(slot)); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.Hands) { Assert.Null(hands.GetItem(slot)); } buckle.TryUnbuckle(human, true); }); }
/// <summary> /// Attempts to get the turf at map indices with grid id or null if no such turf is found. /// </summary> public static TileRef GetTileRef(this Vector2i vector2i, GridId gridId, IMapManager?mapManager = null) { if (!gridId.IsValid()) { return(default);
public GasOverlayChunk(GridId gridIndices, Vector2i vector2i) { GridIndices = gridIndices; Vector2i = vector2i; }
public OccluderTreeRemoveOccluderMessage(OccluderComponent occluder, MapId mapId, GridId gridId) { Occluder = occluder; MapId = mapId; GridId = gridId; }
public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve <IEntityManager>(); GridId gridId; switch (args.Length) { case 0: if (player?.AttachedEntity is not { Valid : true } playerEntity) { shell.WriteLine("Only a player can run this command."); return; } gridId = entityManager.GetComponent <TransformComponent>(playerEntity).GridID; break; case 1: if (!int.TryParse(args[0], out var id)) { shell.WriteLine($"{args[0]} is not a valid integer."); return; } gridId = new GridId(id); break; default: shell.WriteLine(Help); return; } var mapManager = IoCManager.Resolve <IMapManager>(); if (!mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } if (!entityManager.EntityExists(grid.GridEntityId)) { shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity."); return; } var tileDefinitionManager = IoCManager.Resolve <ITileDefinitionManager>(); var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); var underplating = tileDefinitionManager["underplating"]; var underplatingTile = new Tile(underplating.TileId); var changed = 0; foreach (var child in entityManager.GetComponent <TransformComponent>(grid.GridEntityId).ChildEntities) { if (!entityManager.EntityExists(child)) { continue; } var prototype = entityManager.GetComponent <MetaDataComponent>(child).EntityPrototype; while (true) { if (prototype?.Parent == null) { break; } prototype = prototypeManager.Index <EntityPrototype>(prototype.Parent); } if (prototype?.ID != "base_wall") { continue; } var childTransform = entityManager.GetComponent <TransformComponent>(child); if (!childTransform.Anchored) { continue; } var tile = grid.GetTileRef(childTransform.Coordinates); var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.Tile.TypeId]; if (tileDef.Name == "underplating") { continue; } grid.SetTile(childTransform.Coordinates, underplatingTile); changed++; } shell.WriteLine($"Changed {changed} tiles."); }
public RequestGridTileLookupMessage(GridId gridId, Vector2i indices) { GridId = gridId; Indices = indices; }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 2) { return; } if (!int.TryParse(args[0], out var id) || !float.TryParse(args[1], out var temperature)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (temperature < Atmospherics.TCMB) { shell.WriteLine("Invalid temperature."); return; } if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.WriteLine("Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.WriteLine("Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var tiles = 0; foreach (var tile in gam) { if (tile.Air == null) { continue; } tiles++; tile.Air.Temperature = temperature; tile.Invalidate(); } shell.WriteLine($"Changed the temperature of {tiles} tiles."); }
public SendGridTileLookupMessage(GridId gridId, Vector2i indices, List <EntityUid> entities) { Entities = entities; }
public override int GetHashCode() { return(EntityId.GetHashCode() + (GridId.GetHashCode() << 8) + ((Position.HasValue ? Position.Value.GetHashCode() : 0) << 16) + ((Box.HasValue ? Box.Value.GetHashCode() : 0) << 24)); }
public static IEnumerable <IEntity> GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem?gridTileLookup = null) { gridTileLookup ??= EntitySystem.Get <GridTileLookupSystem>(); return(gridTileLookup.GetEntitiesIntersecting(gridId, indices)); }