# Conflicts: # .github/CODEOWNERS # .github/workflows/publish.yml # Content.Client/Administration/UI/BanPanel/BanPanel.xaml # Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs # Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs # Content.Client/Entry/EntryPoint.cs # Content.Client/Hands/Systems/HandsSystem.cs # Content.Client/Humanoid/HumanoidAppearanceSystem.cs # Content.Client/Humanoid/SingleMarkingPicker.xaml.cs # Content.Client/IoC/ClientContentIoC.cs # Content.Client/Lobby/LobbyState.cs # Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs # Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs # Content.Client/Lobby/UI/LobbyGui.xaml # Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml # Content.Client/Options/UI/EscapeMenu.xaml # Content.Client/Stealth/StealthSystem.cs # Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs # Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs # Content.Client/UserInterface/Systems/Emotes/EmotesUIController.cs # Content.Client/Weapons/Ranged/Systems/GunSystem.cs # Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs # Content.IntegrationTests/Tests/Damageable/DamageableTest.cs # Content.IntegrationTests/Tests/PostMapInitTest.cs # Content.Server/Administration/Commands/AdminWhoCommand.cs # Content.Server/Administration/Commands/PardonCommand.cs # Content.Server/Administration/Commands/RoleUnbanCommand.cs # Content.Server/Administration/Commands/SetOutfitCommand.cs # Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs # Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs # Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs # Content.Server/Body/Components/BloodstreamComponent.cs # Content.Server/Body/Systems/BloodstreamSystem.cs # Content.Server/Body/Systems/MetabolizerSystem.cs # Content.Server/Body/Systems/RespiratorSystem.cs # Content.Server/Chat/Managers/ChatSanitizationManager.cs # Content.Server/Chat/Systems/ChatSystem.Emote.cs # Content.Server/Chat/Systems/ChatSystem.cs # Content.Server/CrewManifest/CrewManifestSystem.cs # Content.Server/Emp/EmpSystem.cs # Content.Server/Explosion/EntitySystems/TriggerSystem.cs # Content.Server/Fax/FaxSystem.cs # Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs # Content.Server/GameTicking/Commands/ForceMapCommand.cs # Content.Server/GameTicking/Commands/ForcePresetCommand.cs # Content.Server/GameTicking/Presets/GamePresetPrototype.cs # Content.Server/GameTicking/Rules/ChangelingRuleSystem.cs # Content.Server/GameTicking/Rules/Components/ChangelingRuleComponent.cs # Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs # Content.Server/Ghost/Roles/GhostRoleSystem.cs # Content.Server/Implants/Components/ScramImplantComponent.cs # Content.Server/Implants/SubdermalImplantSystem.cs # Content.Server/Materials/ProduceMaterialExtractorSystem.cs # Content.Server/Medical/HealthAnalyzerSystem.cs # Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs # Content.Server/NPC/Systems/NPCSystem.cs # Content.Server/Polymorph/Systems/PolymorphSystem.cs # Content.Server/Radio/EntitySystems/HeadsetSystem.cs # Content.Server/Repairable/RepairableSystem.cs # Content.Server/Revenant/EntitySystems/RevenantSystem.cs # Content.Server/RoundEnd/RoundEndSystem.cs # Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs # Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs # Content.Server/Speech/EntitySystems/FrontalLispSystem.cs # Content.Server/Speech/EntitySystems/LizardAccentSystem.cs # Content.Server/Speech/EntitySystems/MothAccentSystem.cs # Content.Server/Speech/EntitySystems/OwOAccentSystem.cs # Content.Server/Station/Systems/StationSpawningSystem.cs # Content.Server/StationEvents/Events/MeteorSwarmSystem.cs # Content.Server/Stunnable/Components/StunOnCollideComponent.cs # Content.Server/SurveillanceCamera/Components/SurveillanceCameraRouterComponent.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.Cartridges.cs # Content.Server/Zombies/ZombieSystem.Transform.cs # Content.Server/Zombies/ZombieSystem.cs # Content.Shared/Actions/SharedActionsSystem.cs # Content.Shared/Bed/SharedBedSystem.cs # Content.Shared/Blocking/BlockingSystem.cs # Content.Shared/Body/Systems/SharedBodySystem.Parts.cs # Content.Shared/Chemistry/Components/SolutionRegenerationComponent.cs # Content.Shared/Chemistry/EntitySystems/HypospraySystem.cs # Content.Shared/Construction/Conditions/TileNotBlocked.cs # Content.Shared/Cuffs/SharedCuffableSystem.cs # Content.Shared/Doors/Systems/SharedDoorSystem.cs # Content.Shared/Emoting/EmoteAttemptEvent.cs # Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs # Content.Shared/Eye/VisibilityFlags.cs # Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs # Content.Shared/Humanoid/HumanoidCharacterAppearance.cs # Content.Shared/Interaction/SmartEquipSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs # Content.Shared/Medical/Healing/HealingSystem.cs # Content.Shared/Medical/HealingComponent.cs # Content.Shared/Nutrition/EntitySystems/FoodSystem.cs # Content.Shared/Slippery/SlipperySystem.cs # Content.Shared/SprayPainter/SharedSprayPainterSystem.cs # Content.Shared/Standing/StandingStateComponent.cs # Content.Shared/Standing/StandingStateSystem.cs # Content.Shared/Station/SharedStationSpawningSystem.cs # Content.Shared/Stunnable/SharedStunSystem.cs # Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs # Content.Shared/VendingMachines/VendingMachineComponent.cs # Content.Shared/Warps/WarpPointSystem.cs # Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs # Content.Shared/Wieldable/SharedWieldableSystem.cs # Resources/Audio/Ambience/Antag/attributions.yml # Resources/Audio/Ambience/Antag/changeling_start.ogg # Resources/Audio/Effects/attributions.yml # Resources/Audio/Lobby/attributions.yml # Resources/Audio/Machines/attributions.yml # Resources/Audio/Weapons/Guns/Gunshots/attributions.yml # Resources/Locale/en-US/_strings/administration/antag.ftl # Resources/Locale/en-US/_strings/administration/commands/camera.ftl # Resources/Locale/en-US/_strings/administration/commands/dsay-command.ftl # Resources/Locale/en-US/_strings/administration/commands/follow-command.ftl # Resources/Locale/en-US/_strings/administration/smites.ftl # Resources/Locale/en-US/_strings/administration/ui/admin-camera-window.ftl # Resources/Locale/en-US/_strings/administration/ui/role-bans.ftl # Resources/Locale/en-US/_strings/alerts/alerts.ftl # Resources/Locale/en-US/_strings/atmos/gas-pressure-regulator-system.ftl # Resources/Locale/en-US/_strings/bonk/components/bonkable-component.ftl # Resources/Locale/en-US/_strings/commands/add-body-part-command.ftl # Resources/Locale/en-US/_strings/commands/admin-logs-command.ftl # Resources/Locale/en-US/_strings/commands/admin-who-command.ftl # Resources/Locale/en-US/_strings/commands/asay-command.ftl # Resources/Locale/en-US/_strings/commands/crew-manifest-command.ftl # Resources/Locale/en-US/_strings/commands/deadmin-command.ftl # Resources/Locale/en-US/_strings/commands/delete-component-command.ftl # Resources/Locale/en-US/_strings/commands/destroy-mechanism-command.ftl # Resources/Locale/en-US/_strings/commands/dirty-command.ftl # Resources/Locale/en-US/_strings/commands/dsay-command.ftl # Resources/Locale/en-US/_strings/commands/dump-reagent-guide-text-command.ftl # Resources/Locale/en-US/_strings/commands/eye-commands.ftl # Resources/Locale/en-US/_strings/commands/follow-command.ftl # Resources/Locale/en-US/_strings/commands/force-map-command.ftl # Resources/Locale/en-US/_strings/commands/force-preset-command.ftl # Resources/Locale/en-US/_strings/commands/ghost-kick-command.ftl # Resources/Locale/en-US/_strings/commands/ghost-visibility-commands.ftl # Resources/Locale/en-US/_strings/commands/go-lobby-command.ftl # Resources/Locale/en-US/_strings/commands/grid-drag-command.ftl # Resources/Locale/en-US/_strings/commands/is-afk-command.ftl # Resources/Locale/en-US/_strings/commands/makesentient-command.ftl # Resources/Locale/en-US/_strings/commands/map-commands.ftl # Resources/Locale/en-US/_strings/commands/mapping-client-side-setup-command.ftl # Resources/Locale/en-US/_strings/commands/mappingclientsidesetup-command.ftl # Resources/Locale/en-US/_strings/commands/me-command.ftl # Resources/Locale/en-US/_strings/commands/mind-info-command.ftl # Resources/Locale/en-US/_strings/commands/node-vis-commands.ftl # Resources/Locale/en-US/_strings/commands/npc-command.ftl # Resources/Locale/en-US/_strings/commands/nukecodes-command.ftl # Resources/Locale/en-US/_strings/commands/ooc-command.ftl # Resources/Locale/en-US/_strings/commands/pardon-command.ftl # Resources/Locale/en-US/_strings/commands/powerstat-command.ftl # Resources/Locale/en-US/_strings/commands/promote-host-command.ftl # Resources/Locale/en-US/_strings/commands/radiation-command.ftl # Resources/Locale/en-US/_strings/commands/readmin-command.ftl # Resources/Locale/en-US/_strings/commands/remove-extra-components-command.ftl # Resources/Locale/en-US/_strings/commands/role-commands.ftl # Resources/Locale/en-US/_strings/commands/say-command.ftl # Resources/Locale/en-US/_strings/commands/set-battery-percent-command.ftl # Resources/Locale/en-US/_strings/commands/show-ambient-command.ftl # Resources/Locale/en-US/_strings/commands/show-gun-spread-command.ftl # Resources/Locale/en-US/_strings/commands/show-htn-command.ftl # Resources/Locale/en-US/_strings/commands/showrules-command.ftl # Resources/Locale/en-US/_strings/commands/spawn-entity-list-command.ftl # Resources/Locale/en-US/_strings/commands/start-singularity-command.ftl # Resources/Locale/en-US/_strings/commands/tile-pry-command.ftl # Resources/Locale/en-US/_strings/commands/toggle-decals-command.ftl # Resources/Locale/en-US/_strings/commands/toggle-disallow-late-join-command.ftl # Resources/Locale/en-US/_strings/commands/unlocknode-command.ftl # Resources/Locale/en-US/_strings/commands/whisper-command.ftl # Resources/Locale/en-US/_strings/components/gas-pressure-regulator-component.ftl # Resources/Locale/en-US/_strings/engineer-painter/engineer-painter.ftl # Resources/Locale/en-US/_strings/game-ticking/forcemap-command.ftl # Resources/Locale/en-US/_strings/interaction/interaction-popup-component.ftl # Resources/Locale/en-US/_strings/markings/vox_tattoos.ftl # Resources/Locale/en-US/_strings/materials/material-extractor.ftl # Resources/Locale/en-US/_strings/movement/eye.ftl # Resources/Locale/en-US/_strings/nutrition/components/food-component.ftl # Resources/Locale/en-US/_strings/nutrition/components/ingestion-system.ftl # Resources/Locale/en-US/_strings/nutrition/components/sealable-component.ftl # Resources/Locale/en-US/_strings/radiation/radiation-command.ftl # Resources/Locale/en-US/_strings/reagents/meta/physical-desc.ftl # Resources/Locale/en-US/_strings/research/technologies.ftl # Resources/Locale/en-US/_strings/seeds/seeds.ftl # Resources/Locale/en-US/_strings/weapons/grenades/timer-trigger.ftl # Resources/Locale/en-US/_strings/weapons/grenades/voice-trigger.ftl # Resources/Locale/en-US/commands/mapping-client-side-setup-command.ftl # Resources/Locale/en-US/recipes/tags.ftl # Resources/Maps/_Sunrise/Station/bagel.yml # Resources/Maps/_Sunrise/Station/barratry.yml # Resources/Maps/_Sunrise/Station/box.yml # Resources/Maps/_Sunrise/Station/fland.yml # Resources/Maps/_Sunrise/Station/marathon.yml # Resources/Maps/_Sunrise/Station/oasis.yml # Resources/Maps/_Sunrise/Station/packed.yml # Resources/Maps/_Sunrise/Station/plasma.yml # Resources/Maps/amber.yml # Resources/Maps/centcomm.yml # Resources/Prototypes/Catalog/Fills/Backpacks/duffelbag.yml # Resources/Prototypes/Catalog/Fills/Lockers/security.yml # Resources/Prototypes/Catalog/Fills/Lockers/service.yml # Resources/Prototypes/Catalog/Fills/Lockers/suit_storage.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/coffee.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/sustenance.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/winterdrobe.yml # Resources/Prototypes/Entities/Clothing/Belt/belts.yml # Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml # Resources/Prototypes/Entities/Clothing/Eyes/hud.yml # Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml # Resources/Prototypes/Entities/Clothing/Head/hats.yml # Resources/Prototypes/Entities/Clothing/Head/helmets.yml # Resources/Prototypes/Entities/Clothing/Head/hoods.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/softsuits.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml # Resources/Prototypes/Entities/Mobs/NPCs/animals.yml # Resources/Prototypes/Entities/Mobs/NPCs/carp.yml # Resources/Prototypes/Entities/Mobs/NPCs/pets.yml # Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Entities/Mobs/Player/clone.yml # Resources/Prototypes/Entities/Mobs/Species/base.yml # Resources/Prototypes/Entities/Mobs/Species/dwarf.yml # Resources/Prototypes/Entities/Mobs/base.yml # Resources/Prototypes/Entities/Objects/Fun/pai.yml # Resources/Prototypes/Entities/Objects/Fun/toys.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Shields/shields.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/healing.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml # Resources/Prototypes/Entities/Objects/Tools/access_configurator.yml # Resources/Prototypes/Entities/Objects/Tools/matches.yml # Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml # Resources/Prototypes/Entities/Objects/Weapons/Bombs/spider.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/caseless_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/light_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml # Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml # Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml # Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml # Resources/Prototypes/Entities/Structures/Doors/airlock_groups.yml # Resources/Prototypes/Entities/Structures/Furniture/beds.yml # Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml # Resources/Prototypes/Entities/Structures/Power/debug_power.yml # Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml # Resources/Prototypes/Entities/Structures/Wallmounts/Misc/mirror.yml # Resources/Prototypes/GameRules/subgamemodes.yml # Resources/Prototypes/Reagents/Consumable/Drink/drinks.yml # Resources/Prototypes/Reagents/Consumable/Drink/soda.yml # Resources/Prototypes/Reagents/medicine.yml # Resources/Prototypes/Recipes/Lathes/Packs/tiles.yml # Resources/Prototypes/Recipes/Lathes/categories.yml # Resources/Prototypes/Recipes/Reactions/chemicals.yml # Resources/Prototypes/Roles/Antags/changeling.yml # Resources/Prototypes/name_identifier_groups.yml # Resources/Prototypes/tool_qualities.yml # Resources/ServerInfo/Guidebook/Antagonist/Zombies.xml # Resources/ServerInfo/Guidebook/Cargo/CargoBounties.xml # Resources/ServerInfo/Guidebook/Command.xml # Resources/ServerInfo/Guidebook/Glossary.xml # Resources/ServerInfo/Guidebook/NewPlayer/YourFirstCharacter.xml # Resources/ServerInfo/Guidebook/Science/Robotics.xml # Resources/ServerInfo/Guidebook/Science/ScannersAndVessels.xml # Resources/ServerInfo/Guidebook/Science/Science.xml # Resources/ServerInfo/Guidebook/SpaceStation14.xml # Resources/ServerInfo/Guidebook/Survival.xml # Resources/Textures/Clothing/Head/Hardsuits/atmospherics.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/capspace.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/cybersun.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering-white.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering-white.rsi/on-equipped-HELMET.png # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/icon.png # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/on-equipped-HELMET.png # Resources/Textures/Clothing/Head/Hardsuits/medical.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/rd.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/salvage.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/security.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/spatiohelm.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndicate.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndiecommander.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndieelite.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/wizard.rsi/meta.json # Resources/Textures/Clothing/Head/Helmets/atmos_firehelmet.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Armor/captain_carapace.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Armor/security.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/atmospherics.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/capspace.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/cybersun.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/engineering-white.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/engineering.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/medical.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/paramed.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/rd.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/salvage.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/security.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/spatio.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndicate.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndiecommander.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndieelite.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/wizard.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Suits/atmos_firesuit.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Suits/eva.rsi/meta.json # Resources/Textures/Interface/Misc/job_icons.rsi/meta.json # Resources/Textures/Objects/Misc/Lights/lampgreen.rsi/meta.json # Resources/Textures/Objects/Specific/Janitorial/janitorial_cart.rsi/meta.json # Resources/Textures/Objects/Tools/spray_painter.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/baseball_bat.rsi/meta.json # Resources/engineCommandPerms.yml # Resources/keybinds.yml # Resources/migration.yml
457 lines
20 KiB
C#
457 lines
20 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Text;
|
|
using Robust.Shared;
|
|
using Robust.Shared.Audio.Components;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
|
|
namespace Content.IntegrationTests.Tests
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(EntityUid))]
|
|
public sealed class EntityTest
|
|
{
|
|
private static readonly ProtoId<EntityCategoryPrototype> SpawnerCategory = "Spawner";
|
|
|
|
[Test]
|
|
public async Task SpawnAndDeleteAllEntitiesOnDifferentMaps()
|
|
{
|
|
// This test dirties the pair as it simply deletes ALL entities when done. Overhead of restarting the round
|
|
// is minimal relative to the rest of the test.
|
|
var settings = new PoolSettings { Dirty = true };
|
|
await using var pair = await PoolManager.GetServerClient(settings);
|
|
var server = pair.Server;
|
|
|
|
var entityMan = server.ResolveDependency<IEntityManager>();
|
|
var mapManager = server.ResolveDependency<IMapManager>();
|
|
var prototypeMan = server.ResolveDependency<IPrototypeManager>();
|
|
var mapSystem = entityMan.System<SharedMapSystem>();
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
var protoIds = prototypeMan
|
|
.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
|
.Where(p => !p.Components.ContainsKey("RoomFill")) // This comp can delete all entities, and spawn others
|
|
.Select(p => p.ID)
|
|
.ToList();
|
|
|
|
foreach (var protoId in protoIds)
|
|
{
|
|
mapSystem.CreateMap(out var mapId);
|
|
var grid = mapManager.CreateGridEntity(mapId);
|
|
// TODO: Fix this better in engine.
|
|
mapSystem.SetTile(grid.Owner, grid.Comp, Vector2i.Zero, new Tile(1));
|
|
var coord = new EntityCoordinates(grid.Owner, 0, 0);
|
|
entityMan.SpawnEntity(protoId, coord);
|
|
}
|
|
});
|
|
|
|
await server.WaitRunTicks(450); // 15 seconds, enough to trigger most update loops
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
static IEnumerable<(EntityUid, TComp)> Query<TComp>(IEntityManager entityMan)
|
|
where TComp : Component
|
|
{
|
|
var query = entityMan.AllEntityQueryEnumerator<TComp>();
|
|
while (query.MoveNext(out var uid, out var meta))
|
|
{
|
|
yield return (uid, meta);
|
|
}
|
|
}
|
|
|
|
var entityMetas = Query<MetaDataComponent>(entityMan).ToList();
|
|
foreach (var (uid, meta) in entityMetas)
|
|
{
|
|
if (!meta.EntityDeleted)
|
|
entityMan.DeleteEntity(uid);
|
|
}
|
|
|
|
Assert.That(entityMan.EntityCount, Is.Zero);
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
|
|
[Test]
|
|
public async Task SpawnAndDeleteAllEntitiesInTheSameSpot()
|
|
{
|
|
// This test dirties the pair as it simply deletes ALL entities when done. Overhead of restarting the round
|
|
// is minimal relative to the rest of the test.
|
|
var settings = new PoolSettings { Dirty = true };
|
|
await using var pair = await PoolManager.GetServerClient(settings);
|
|
var server = pair.Server;
|
|
var map = await pair.CreateTestMap();
|
|
|
|
var entityMan = server.ResolveDependency<IEntityManager>();
|
|
var prototypeMan = server.ResolveDependency<IPrototypeManager>();
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
|
|
var protoIds = prototypeMan
|
|
.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
|
.Where(p => !p.Components.ContainsKey("RoomFill")) // This comp can delete all entities, and spawn others
|
|
.Select(p => p.ID)
|
|
.ToList();
|
|
foreach (var protoId in protoIds)
|
|
{
|
|
// Sunrise-Start
|
|
if (protoId == "Envelope")
|
|
continue;
|
|
// Sunrise-End
|
|
|
|
entityMan.SpawnEntity(protoId, map.GridCoords);
|
|
}
|
|
});
|
|
await server.WaitRunTicks(450); // 15 seconds, enough to trigger most update loops
|
|
await server.WaitPost(() =>
|
|
{
|
|
static IEnumerable<(EntityUid, TComp)> Query<TComp>(IEntityManager entityMan)
|
|
where TComp : Component
|
|
{
|
|
var query = entityMan.AllEntityQueryEnumerator<TComp>();
|
|
while (query.MoveNext(out var uid, out var meta))
|
|
{
|
|
yield return (uid, meta);
|
|
}
|
|
}
|
|
|
|
var entityMetas = Query<MetaDataComponent>(entityMan).ToList();
|
|
foreach (var (uid, meta) in entityMetas)
|
|
{
|
|
if (!meta.EntityDeleted)
|
|
entityMan.DeleteEntity(uid);
|
|
}
|
|
|
|
Assert.That(entityMan.EntityCount, Is.Zero);
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Variant of <see cref="SpawnAndDeleteAllEntitiesOnDifferentMaps"/> that also launches a client and dirties
|
|
/// all components on every entity.
|
|
/// </summary>
|
|
[Test]
|
|
public async Task SpawnAndDirtyAllEntities()
|
|
{
|
|
// This test dirties the pair as it simply deletes ALL entities when done. Overhead of restarting the round
|
|
// is minimal relative to the rest of the test.
|
|
var settings = new PoolSettings { Connected = true, Dirty = true };
|
|
await using var pair = await PoolManager.GetServerClient(settings);
|
|
var server = pair.Server;
|
|
var client = pair.Client;
|
|
|
|
var cfg = server.ResolveDependency<IConfigurationManager>();
|
|
var prototypeMan = server.ResolveDependency<IPrototypeManager>();
|
|
var mapManager = server.ResolveDependency<IMapManager>();
|
|
var sEntMan = server.ResolveDependency<IEntityManager>();
|
|
var mapSys = server.System<SharedMapSystem>();
|
|
|
|
Assert.That(cfg.GetCVar(CVars.NetPVS), Is.False);
|
|
|
|
var protoIds = prototypeMan
|
|
.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
|
.Select(p => p.ID)
|
|
.ToList();
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
foreach (var protoId in protoIds)
|
|
{
|
|
mapSys.CreateMap(out var mapId);
|
|
var grid = mapManager.CreateGridEntity(mapId);
|
|
var ent = sEntMan.SpawnEntity(protoId, new EntityCoordinates(grid.Owner, 0.5f, 0.5f));
|
|
foreach (var (_, component) in sEntMan.GetNetComponents(ent))
|
|
{
|
|
sEntMan.Dirty(ent, component);
|
|
}
|
|
}
|
|
});
|
|
|
|
await pair.RunTicksSync(15);
|
|
|
|
// Make sure the client actually received the entities
|
|
// 500 is completely arbitrary. Note that the client & sever entity counts aren't expected to match.
|
|
Assert.That(client.ResolveDependency<IEntityManager>().EntityCount, Is.GreaterThan(500));
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
static IEnumerable<(EntityUid, TComp)> Query<TComp>(IEntityManager entityMan)
|
|
where TComp : Component
|
|
{
|
|
var query = entityMan.AllEntityQueryEnumerator<TComp>();
|
|
while (query.MoveNext(out var uid, out var meta))
|
|
{
|
|
yield return (uid, meta);
|
|
}
|
|
}
|
|
|
|
var entityMetas = Query<MetaDataComponent>(sEntMan).ToList();
|
|
foreach (var (uid, meta) in entityMetas)
|
|
{
|
|
if (!meta.EntityDeleted)
|
|
sEntMan.DeleteEntity(uid);
|
|
}
|
|
|
|
Assert.That(sEntMan.EntityCount, Is.Zero);
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// This test checks that spawning and deleting an entity doesn't somehow create other unrelated entities.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Unless an entity is intentionally designed to spawn other entities (e.g., mob spawners), they should
|
|
/// generally not spawn unrelated / detached entities. Any entities that do get spawned should be parented to
|
|
/// the spawned entity (e.g., in a container). If an entity needs to spawn an entity somewhere in null-space,
|
|
/// it should delete that entity when it is no longer required. This test mainly exists to prevent "entity leak"
|
|
/// bugs, where spawning some entity starts spawning unrelated entities in null space that stick around after
|
|
/// the original entity is gone.
|
|
///
|
|
/// Note that this isn't really a strict requirement, and there are probably quite a few edge cases. Its a pretty
|
|
/// crude test to try catch issues like this, and possibly should just be disabled.
|
|
/// </remarks>
|
|
[Test]
|
|
public async Task SpawnAndDeleteEntityCountTest()
|
|
{
|
|
var settings = new PoolSettings { Connected = true, Dirty = true };
|
|
await using var pair = await PoolManager.GetServerClient(settings);
|
|
var mapSys = pair.Server.System<SharedMapSystem>();
|
|
var server = pair.Server;
|
|
var client = pair.Client;
|
|
|
|
var excluded = new[]
|
|
{
|
|
"MapGrid",
|
|
"StationEvent",
|
|
"TimedDespawn",
|
|
|
|
// makes an announcement on mapInit.
|
|
"AnnounceOnSpawn",
|
|
};
|
|
|
|
Assert.That(server.CfgMan.GetCVar(CVars.NetPVS), Is.False);
|
|
|
|
var protoIds = server.ProtoMan
|
|
.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => !excluded.Any(p.Components.ContainsKey))
|
|
.Where(p => p.Categories.All(x => x.ID != SpawnerCategory))
|
|
.Select(p => p.ID)
|
|
.ToList();
|
|
|
|
protoIds.Sort();
|
|
var mapId = MapId.Nullspace;
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
mapSys.CreateMap(out mapId);
|
|
});
|
|
|
|
var coords = new MapCoordinates(Vector2.Zero, mapId);
|
|
|
|
await pair.RunTicksSync(3);
|
|
|
|
// We consider only non-audio entities, as some entities will just play sounds when they spawn.
|
|
int Count(IEntityManager ent) => ent.EntityCount - ent.Count<AudioComponent>();
|
|
IEnumerable<EntityUid> Entities(IEntityManager entMan) => entMan.GetEntities().Where(entMan.HasComponent<AudioComponent>);
|
|
|
|
await Assert.MultipleAsync(async () =>
|
|
{
|
|
foreach (var protoId in protoIds)
|
|
{
|
|
var count = Count(server.EntMan);
|
|
var clientCount = Count(client.EntMan);
|
|
var serverEntities = new HashSet<EntityUid>(Entities(server.EntMan));
|
|
var clientEntities = new HashSet<EntityUid>(Entities(client.EntMan));
|
|
EntityUid uid = default;
|
|
await server.WaitPost(() => uid = server.EntMan.SpawnEntity(protoId, coords));
|
|
await pair.RunTicksSync(3);
|
|
|
|
// If the entity deleted itself, check that it didn't spawn other entities
|
|
if (!server.EntMan.EntityExists(uid))
|
|
{
|
|
Assert.That(Count(server.EntMan), Is.EqualTo(count), $"Server prototype {protoId} failed on deleting itself\n" +
|
|
BuildDiffString(serverEntities, Entities(server.EntMan), server.EntMan));
|
|
Assert.That(Count(client.EntMan), Is.EqualTo(clientCount), $"Client prototype {protoId} failed on deleting itself\n" +
|
|
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
|
|
$"Server count was {count}.\n" +
|
|
BuildDiffString(clientEntities, Entities(client.EntMan), client.EntMan));
|
|
continue;
|
|
}
|
|
|
|
// Check that the number of entities has increased.
|
|
Assert.That(Count(server.EntMan), Is.GreaterThan(count), $"Server prototype {protoId} failed on spawning as entity count didn't increase\n" +
|
|
BuildDiffString(serverEntities, Entities(server.EntMan), server.EntMan));
|
|
Assert.That(Count(client.EntMan), Is.GreaterThan(clientCount), $"Client prototype {protoId} failed on spawning as entity count didn't increase\n" +
|
|
$"Expected at least {clientCount} and found {client.EntMan.EntityCount}. " +
|
|
$"Server count was {count}.\n" +
|
|
BuildDiffString(clientEntities, Entities(client.EntMan), client.EntMan));
|
|
|
|
await server.WaitPost(() => server.EntMan.DeleteEntity(uid));
|
|
await pair.RunTicksSync(3);
|
|
|
|
// Check that the number of entities has gone back to the original value.
|
|
Assert.That(Count(server.EntMan), Is.EqualTo(count), $"Server prototype {protoId} failed on deletion: count didn't reset properly\n" +
|
|
BuildDiffString(serverEntities, Entities(server.EntMan), server.EntMan));
|
|
Assert.That(client.EntMan.EntityCount, Is.EqualTo(clientCount), $"Client prototype {protoId} failed on deletion: count didn't reset properly:\n" +
|
|
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
|
|
$"Server count was {count}.\n" +
|
|
BuildDiffString(clientEntities, Entities(client.EntMan), client.EntMan));
|
|
}
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
|
|
private static string BuildDiffString(IEnumerable<EntityUid> oldEnts, IEnumerable<EntityUid> newEnts, IEntityManager entMan)
|
|
{
|
|
var sb = new StringBuilder();
|
|
var addedEnts = newEnts.Except(oldEnts);
|
|
var removedEnts = oldEnts.Except(newEnts);
|
|
if (addedEnts.Any())
|
|
sb.AppendLine("Listing new entities:");
|
|
foreach (var addedEnt in addedEnts)
|
|
{
|
|
sb.AppendLine(entMan.ToPrettyString(addedEnt));
|
|
}
|
|
if (removedEnts.Any())
|
|
sb.AppendLine("Listing removed entities:");
|
|
foreach (var removedEnt in removedEnts)
|
|
{
|
|
sb.AppendLine("\t" + entMan.ToPrettyString(removedEnt));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
|
|
private static bool HasRequiredDataField(Component component)
|
|
{
|
|
foreach (var field in component.GetType().GetFields())
|
|
{
|
|
foreach (var attribute in field.GetCustomAttributes(true))
|
|
{
|
|
if (attribute is not DataFieldAttribute dataField)
|
|
continue;
|
|
|
|
if (dataField.Required)
|
|
return true;
|
|
}
|
|
}
|
|
foreach (var property in component.GetType().GetProperties())
|
|
{
|
|
foreach (var attribute in property.GetCustomAttributes(true))
|
|
{
|
|
if (attribute is not DataFieldAttribute dataField)
|
|
continue;
|
|
|
|
if (dataField.Required)
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
[Test]
|
|
public async Task AllComponentsOneToOneDeleteTest()
|
|
{
|
|
var skipComponents = new[]
|
|
{
|
|
"DebugExceptionOnAdd", // Debug components that explicitly throw exceptions
|
|
"DebugExceptionExposeData",
|
|
"DebugExceptionInitialize",
|
|
"DebugExceptionStartup",
|
|
"GridFill",
|
|
"RoomFill",
|
|
"Map", // We aren't testing a map entity in this test
|
|
"MapGrid",
|
|
"Broadphase",
|
|
"StationData", // errors when removed mid-round
|
|
"StationJobs",
|
|
"Actor", // We aren't testing actor components, those need their player session set.
|
|
"BlobFloorPlanBuilder", // Implodes if unconfigured.
|
|
"DebrisFeaturePlacerController", // Above.
|
|
"LoadedChunk", // Worldgen chunk loading malding.
|
|
"BiomeSelection", // Whaddya know, requires config.
|
|
"ActivatableUI", // Requires enum key
|
|
};
|
|
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
var server = pair.Server;
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var componentFactory = server.ResolveDependency<IComponentFactory>();
|
|
var logmill = server.ResolveDependency<ILogManager>().GetSawmill("EntityTest");
|
|
|
|
await pair.CreateTestMap();
|
|
await server.WaitRunTicks(5);
|
|
var testLocation = pair.TestMap.GridCoords;
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
|
|
foreach (var type in componentFactory.AllRegisteredTypes)
|
|
{
|
|
var component = (Component)componentFactory.GetComponent(type);
|
|
var name = componentFactory.GetComponentName(type);
|
|
|
|
if (HasRequiredDataField(component))
|
|
continue;
|
|
|
|
// If this component is ignored
|
|
if (skipComponents.Contains(name))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var entity = entityManager.SpawnEntity(null, testLocation);
|
|
|
|
Assert.That(entityManager.GetComponent<MetaDataComponent>(entity).EntityInitialized);
|
|
|
|
// The component may already exist if it is a mandatory component
|
|
// such as MetaData or Transform
|
|
if (entityManager.HasComponent(entity, type))
|
|
{
|
|
entityManager.DeleteEntity(entity);
|
|
continue;
|
|
}
|
|
|
|
logmill.Debug($"Adding component: {name}");
|
|
|
|
Assert.DoesNotThrow(() =>
|
|
{
|
|
entityManager.AddComponent(entity, component);
|
|
}, "Component '{0}' threw an exception.",
|
|
name);
|
|
|
|
entityManager.DeleteEntity(entity);
|
|
}
|
|
});
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|
|
}
|