Add test pooling (#4961)
* Add test pooling * WIP test pooling changes * Fix Destructible tests * Don't pool unpooled or dummy ticker instances * Change ServerPathfindingDebugSystem to replace existing entries * Fix SaveLoadSaveTest comment * Don't pool StartTest * Comment out global setup * Fix puddle tests * Move SolarPanelComponent initialize to PowerSolarSystem OnMapInit * Update RobustToolbox * Finish fixing tests, make test threads background threads * Bring back pooling * Fix nullable * Update RobustToolbox * Set cvars on server return * Un-pool tests with custom cvars * Update RobustToolbox * Update RobustToolbox * Change where the main tile coordinates are * Remove DisposalUnitTest grid check * Fix test pooling being a fickle bitch * Fix EntitySystemExtensionsTest * Update RobustToolbox * Update RobustToolbox * Make nullable pool settings true * Update RobustToolbox * Wait other way around * We are unitystation now * Update RobustToolbox * Create global setup * Pool some more tests * Fix not properly disconnecting clients before restarting the round * Give more info on ran tests * Standardize default test cvars * Update RobustToolbox * Update RobustToolbox * Pool clients * Fix test order issue * Fix cvars in character creation test not being set properly * Update RobustToolbox * Update RobustToolbox * Rider shut * Update RobustToolbox * Format tests ran better * Update RobustToolbox * Reset RobustToolbox * Reset RobustToolbox harder * Fix one instance of test order causing destructible tests to fail
This commit is contained in:
committed by
GitHub
parent
4b5168e1fe
commit
1508efff54
@@ -1,31 +1,56 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Entry;
|
||||
using Content.Client.IoC;
|
||||
using Content.Client.Parallax.Managers;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.IoC;
|
||||
using Content.Shared.CCVar;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client;
|
||||
using Robust.Server;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.UnitTesting;
|
||||
using EntryPoint = Content.Client.Entry.EntryPoint;
|
||||
|
||||
namespace Content.IntegrationTests
|
||||
{
|
||||
[Parallelizable(ParallelScope.All)]
|
||||
public abstract class ContentIntegrationTest : RobustIntegrationTest
|
||||
{
|
||||
private static readonly (string cvar, string value, bool)[] ServerTestCvars = {
|
||||
// Avoid funny race conditions with the database.
|
||||
(CCVars.DatabaseSynchronous.Name, "true", false),
|
||||
|
||||
// Disable holidays as some of them might mess with the map at round start.
|
||||
(CCVars.HolidaysEnabled.Name, "false", false),
|
||||
|
||||
// Avoid loading a large map by default for integration tests if none has been specified.
|
||||
(CCVars.GameMap.Name, "Maps/Test/empty.yml", true)
|
||||
};
|
||||
|
||||
private static void SetServerTestCvars(IntegrationOptions options)
|
||||
{
|
||||
foreach (var (cvar, value, tryAdd) in ServerTestCvars)
|
||||
{
|
||||
if (tryAdd)
|
||||
{
|
||||
options.CVarOverrides.TryAdd(cvar, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
options.CVarOverrides[cvar] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected sealed override ClientIntegrationInstance StartClient(ClientIntegrationOptions options = null)
|
||||
{
|
||||
options ??= new ClientContentIntegrationOption()
|
||||
@@ -33,6 +58,8 @@ namespace Content.IntegrationTests
|
||||
FailureLogLevel = LogLevel.Warning
|
||||
};
|
||||
|
||||
options.Pool = ShouldPool(options, false);
|
||||
|
||||
// Load content resources, but not config and user data.
|
||||
options.Options = new GameControllerOptions()
|
||||
{
|
||||
@@ -71,11 +98,14 @@ namespace Content.IntegrationTests
|
||||
|
||||
protected override ServerIntegrationInstance StartServer(ServerIntegrationOptions options = null)
|
||||
{
|
||||
options ??= new ServerContentIntegrationOption()
|
||||
options ??= new ServerContentIntegrationOption
|
||||
{
|
||||
FailureLogLevel = LogLevel.Warning
|
||||
FailureLogLevel = LogLevel.Warning,
|
||||
};
|
||||
|
||||
SetServerTestCvars(options);
|
||||
options.Pool = ShouldPool(options, true);
|
||||
|
||||
// Load content resources, but not config and user data.
|
||||
options.Options = new ServerOptions()
|
||||
{
|
||||
@@ -108,16 +138,6 @@ namespace Content.IntegrationTests
|
||||
IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
|
||||
};
|
||||
|
||||
// Avoid funny race conditions with the database.
|
||||
options.CVarOverrides[CCVars.DatabaseSynchronous.Name] = "true";
|
||||
|
||||
// Disable holidays as some of them might mess with the map at round start.
|
||||
options.CVarOverrides[CCVars.HolidaysEnabled.Name] = "false";
|
||||
|
||||
// Avoid loading a large map by default for integration tests if none has been specified.
|
||||
if(!options.CVarOverrides.ContainsKey(CCVars.GameMap.Name))
|
||||
options.CVarOverrides[CCVars.GameMap.Name] = "Maps/Test/empty.yml";
|
||||
|
||||
return base.StartServer(options);
|
||||
}
|
||||
|
||||
@@ -150,7 +170,6 @@ namespace Content.IntegrationTests
|
||||
return (client, server);
|
||||
}
|
||||
|
||||
|
||||
protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)>
|
||||
StartConnectedServerDummyTickerClientPair(ClientIntegrationOptions clientOptions = null,
|
||||
ServerIntegrationOptions serverOptions = null)
|
||||
@@ -163,30 +182,129 @@ namespace Content.IntegrationTests
|
||||
return (client, server);
|
||||
}
|
||||
|
||||
protected async Task<IMapGrid> InitializeMap(ServerIntegrationInstance server, string mapPath)
|
||||
private bool ShouldPool(IntegrationOptions options, bool server)
|
||||
{
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var pauseManager = server.ResolveDependency<IPauseManager>();
|
||||
var mapLoader = server.ResolveDependency<IMapLoader>();
|
||||
|
||||
IMapGrid grid = null;
|
||||
|
||||
server.Post(() =>
|
||||
if (options.Pool == false)
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
return false;
|
||||
}
|
||||
|
||||
pauseManager.AddUninitializedMap(mapId);
|
||||
if (server)
|
||||
{
|
||||
if (options.CVarOverrides.Count != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
grid = mapLoader.LoadBlueprint(mapId, mapPath);
|
||||
foreach (var (cvar, value, _) in ServerTestCvars)
|
||||
{
|
||||
if (!options.CVarOverrides.TryGetValue(cvar, out var actualValue) ||
|
||||
actualValue != value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pauseManager.DoMapInitialize(mapId);
|
||||
if (options.CVarOverrides.TryGetValue(CCVars.GameDummyTicker.Name, out var dummy) &&
|
||||
dummy == "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.CVarOverrides.TryGetValue(CCVars.GameLobbyEnabled.Name, out var lobby) &&
|
||||
lobby == "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options is ClientContentIntegrationOption {ContentBeforeIoC: { }}
|
||||
or ServerContentIntegrationOption {ContentBeforeIoC: { }})
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return options.InitIoC == null &&
|
||||
options.BeforeStart == null &&
|
||||
options.ContentAssemblies == null;
|
||||
}
|
||||
|
||||
protected override async Task OnClientReturn(ClientIntegrationInstance client)
|
||||
{
|
||||
await base.OnClientReturn(client);
|
||||
|
||||
await client.WaitIdleAsync();
|
||||
|
||||
var net = client.ResolveDependency<IClientNetManager>();
|
||||
var prototypes = client.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await client.WaitPost(() =>
|
||||
{
|
||||
net.ClientDisconnect("Test pooling disconnect");
|
||||
|
||||
if (client.PreviousOptions?.ExtraPrototypes is { } oldExtra)
|
||||
{
|
||||
prototypes.RemoveString(oldExtra);
|
||||
}
|
||||
|
||||
if (client.Options?.ExtraPrototypes is { } extra)
|
||||
{
|
||||
prototypes.LoadString(extra, true);
|
||||
prototypes.Resync();
|
||||
}
|
||||
});
|
||||
|
||||
await WaitUntil(client, () => !net.IsConnected);
|
||||
}
|
||||
|
||||
protected override async Task OnServerReturn(ServerIntegrationInstance server)
|
||||
{
|
||||
await base.OnServerReturn(server);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
return grid;
|
||||
if (server.Options != null)
|
||||
{
|
||||
SetServerTestCvars(server.Options);
|
||||
}
|
||||
|
||||
var systems = server.ResolveDependency<IEntitySystemManager>();
|
||||
var prototypes = server.ResolveDependency<IPrototypeManager>();
|
||||
var net = server.ResolveDependency<IServerNetManager>();
|
||||
var players = server.ResolveDependency<IPlayerManager>();
|
||||
|
||||
var gameTicker = systems.GetEntitySystem<GameTicker>();
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
foreach (var channel in net.Channels)
|
||||
{
|
||||
net.DisconnectChannel(channel, "Test pooling disconnect");
|
||||
}
|
||||
});
|
||||
|
||||
await WaitUntil(server, () => players.PlayerCount == 0);
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
gameTicker.RestartRound();
|
||||
|
||||
if (server.PreviousOptions?.ExtraPrototypes is { } oldExtra)
|
||||
{
|
||||
prototypes.RemoveString(oldExtra);
|
||||
}
|
||||
|
||||
if (server.Options?.ExtraPrototypes is { } extra)
|
||||
{
|
||||
prototypes.LoadString(extra, true);
|
||||
prototypes.Resync();
|
||||
}
|
||||
});
|
||||
|
||||
if (!gameTicker.DummyTicker)
|
||||
{
|
||||
await WaitUntil(server, () => gameTicker.RunLevel == GameRunLevel.InRound);
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int maxTicks = 600,
|
||||
@@ -211,6 +329,12 @@ namespace Content.IntegrationTests
|
||||
ticksAwaited += ticksToRun;
|
||||
}
|
||||
|
||||
if (!passed)
|
||||
{
|
||||
Assert.Fail($"Condition did not pass after {maxTicks} ticks.\n" +
|
||||
$"Tests ran ({instance.TestsRan.Count}):\n" +
|
||||
$"{string.Join('\n', instance.TestsRan)}");
|
||||
}
|
||||
Assert.That(passed);
|
||||
}
|
||||
|
||||
@@ -239,6 +363,30 @@ namespace Content.IntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
protected MapId GetMainMapId(IMapManager manager)
|
||||
{
|
||||
// TODO a heuristic that is not this bad
|
||||
return manager.GetAllMapIds().Last();
|
||||
}
|
||||
|
||||
protected IMapGrid GetMainGrid(IMapManager manager)
|
||||
{
|
||||
// TODO a heuristic that is not this bad
|
||||
return manager.GetAllGrids().First();
|
||||
}
|
||||
|
||||
protected TileRef GetMainTile(IMapGrid grid)
|
||||
{
|
||||
// TODO a heuristic that is not this bad
|
||||
return grid.GetAllTiles().First();
|
||||
}
|
||||
|
||||
protected EntityCoordinates GetMainEntityCoordinates(IMapManager manager)
|
||||
{
|
||||
var gridId = GetMainGrid(manager).GridEntityId;
|
||||
return new EntityCoordinates(gridId, -0.5f, -0.5f);
|
||||
}
|
||||
|
||||
protected sealed class ClientContentIntegrationOption : ClientIntegrationOptions
|
||||
{
|
||||
public ClientContentIntegrationOption()
|
||||
|
||||
15
Content.IntegrationTests/ContentIntegrationTestSetup.cs
Normal file
15
Content.IntegrationTests/ContentIntegrationTestSetup.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
[SetUpFixture]
|
||||
// ReSharper disable once CheckNamespace
|
||||
public class ContentIntegrationTestSetup
|
||||
{
|
||||
[OneTimeTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
var robustSetup = new RobustIntegrationTestSetup();
|
||||
|
||||
robustSetup.Shutdown();
|
||||
robustSetup.PrintTestPoolingInfo();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ using Content.Server.AI.Utility.AiLogic;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.AI
|
||||
{
|
||||
@@ -18,8 +17,7 @@ namespace Content.IntegrationTests.Tests.AI
|
||||
[Test]
|
||||
public async Task TestBehaviorSets()
|
||||
{
|
||||
var options = new ServerIntegrationOptions();
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Tests.Server.GameObjects.Components.Access
|
||||
[Test]
|
||||
public async Task TestTags()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var system = EntitySystem.Get<AccessReaderSystem>();
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
[Test]
|
||||
public async Task TotalGasesTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
[Test]
|
||||
public async Task TestMerge()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
[TestCase(Atmospherics.BreathPercentage)]
|
||||
public async Task RemoveRatio(float ratio)
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
public async Task RemoveLegsFallTest()
|
||||
{
|
||||
var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
AppearanceComponent appearance = null;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
public async Task AirConsistencyTest()
|
||||
{
|
||||
var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
@@ -139,7 +139,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
public async Task NoSuffocationTest()
|
||||
{
|
||||
var options = new ServerContentIntegrationOption{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
public async Task EventsTest()
|
||||
{
|
||||
var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Standing;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Player;
|
||||
@@ -73,8 +71,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
var standingState = EntitySystem.Get<StandingStateSystem>();
|
||||
|
||||
var gridId = new GridId(1);
|
||||
var grid = mapManager.GetGrid(gridId);
|
||||
var grid = GetMainGrid(mapManager);
|
||||
var coordinates = grid.GridEntityId.ToCoordinates();
|
||||
|
||||
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
|
||||
@@ -235,8 +232,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var gridId = new GridId(1);
|
||||
var grid = mapManager.GetGrid(gridId);
|
||||
var grid = GetMainGrid(mapManager);
|
||||
var coordinates = grid.GridEntityId.ToCoordinates();
|
||||
|
||||
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
|
||||
@@ -321,8 +317,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var gridId = new GridId(1);
|
||||
var grid = mapManager.GetGrid(gridId);
|
||||
var grid = GetMainGrid(mapManager);
|
||||
var coordinates = grid.GridEntityId.ToCoordinates();
|
||||
|
||||
human = entityManager.SpawnEntity(BuckleDummyId, coordinates);
|
||||
|
||||
@@ -19,13 +19,14 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
[Test]
|
||||
public async Task TryAllTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var coordinates = GetMainEntityCoordinates(mapManager);
|
||||
|
||||
foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes<ReactionPrototype>())
|
||||
{
|
||||
@@ -37,9 +38,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
mapManager.CreateNewMapEntity(MapId.Nullspace);
|
||||
|
||||
beaker = entityManager.SpawnEntity("BluespaceBeaker", MapCoordinates.Nullspace);
|
||||
beaker = entityManager.SpawnEntity("BluespaceBeaker", coordinates);
|
||||
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(beaker.Uid, "beaker", out component));
|
||||
foreach (var (id, reactant) in reactionPrototype.Reactants)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
public async Task RejuvenateDeadTest()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task ConstructionGraphSpawnPrototypeValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task ConstructionGraphNodeEntityPrototypeValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task ConstructionGraphEdgeValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using NUnit.Framework;
|
||||
@@ -12,7 +11,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task TestStartIsValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -30,7 +29,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task TestTargetIsValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -48,7 +47,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
[Test]
|
||||
public async Task TestStartReachesTarget()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
||||
@@ -20,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task AndTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
@@ -39,13 +38,15 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var coordinates = new MapCoordinates(0, 0, mapId);
|
||||
sMapManager.CreateMap(mapId);
|
||||
var gridId = GetMainGrid(sMapManager).GridEntityId;
|
||||
var coordinates = new EntityCoordinates(gridId, 0, 0);
|
||||
|
||||
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates);
|
||||
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
|
||||
|
||||
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
@@ -37,9 +37,8 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var coordinates = new MapCoordinates(0, 0, mapId);
|
||||
sMapManager.CreateMap(mapId);
|
||||
var gridId = GetMainGrid(sMapManager).GridEntityId;
|
||||
var coordinates = new EntityCoordinates(gridId, 0, 0);
|
||||
|
||||
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates);
|
||||
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
@@ -36,9 +36,8 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var coordinates = new MapCoordinates(0, 0, mapId);
|
||||
sMapManager.CreateMap(mapId);
|
||||
var gridId = GetMainGrid(sMapManager).GridEntityId;
|
||||
var coordinates = new EntityCoordinates(gridId, 0, 0);
|
||||
|
||||
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates);
|
||||
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
|
||||
|
||||
@@ -9,7 +9,6 @@ using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
||||
@@ -24,7 +23,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
@@ -44,14 +43,16 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var coordinates = new MapCoordinates(0, 0, mapId);
|
||||
sMapManager.CreateMap(mapId);
|
||||
var gridId = GetMainGrid(sMapManager).GridEntityId;
|
||||
var coordinates = new EntityCoordinates(gridId, 0, 0);
|
||||
|
||||
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleEntityId, coordinates);
|
||||
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
|
||||
sDestructibleComponent = sDestructibleEntity.GetComponent<DestructibleComponent>();
|
||||
|
||||
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
|
||||
sTestThresholdListenerSystem.ThresholdsReached.Clear();
|
||||
|
||||
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Destructible;
|
||||
using Robust.Shared.GameObjects;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
@@ -10,10 +11,13 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
/// </summary>
|
||||
public class TestDestructibleListenerSystem : EntitySystem
|
||||
{
|
||||
public readonly List<DamageThresholdReached> ThresholdsReached = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<DestructibleComponent, DamageThresholdReached>(AddThresholdsToList);
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||
}
|
||||
|
||||
public void AddThresholdsToList(EntityUid _, DestructibleComponent comp, DamageThresholdReached args)
|
||||
@@ -21,6 +25,9 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
ThresholdsReached.Add(args);
|
||||
}
|
||||
|
||||
public List<DamageThresholdReached> ThresholdsReached = new();
|
||||
private void OnRoundRestart(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
ThresholdsReached.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
@@ -5,7 +6,6 @@ using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
}
|
||||
};
|
||||
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
}
|
||||
};
|
||||
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
}
|
||||
};
|
||||
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@ using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.Disposal;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Disposal
|
||||
{
|
||||
@@ -122,7 +120,7 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes };
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
IEntity human = default!;
|
||||
@@ -130,48 +128,19 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
IEntity disposalUnit = default!;
|
||||
IEntity disposalTrunk = default!;
|
||||
DisposalUnitComponent unit = default!;
|
||||
EntityCoordinates coordinates = default!;
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var pauseManager = server.ResolveDependency<IPauseManager>();
|
||||
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
|
||||
// Build up test environment
|
||||
server.Post(() =>
|
||||
{
|
||||
// Create a one tile grid to anchor our disposal unit to.
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
pauseManager.AddUninitializedMap(mapId);
|
||||
|
||||
var gridId = new GridId(1);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
grid = mapManager.CreateGrid(mapId, gridId);
|
||||
}
|
||||
|
||||
var tileDefinition = tileDefinitionManager["underplating"];
|
||||
var tile = new Tile(tileDefinition.TileId);
|
||||
coordinates = grid.ToCoordinates();
|
||||
|
||||
grid.SetTile(coordinates, tile);
|
||||
|
||||
pauseManager.DoMapInitialize(mapId);
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
// Spawn the entities
|
||||
var coordinates = GetMainEntityCoordinates(mapManager);
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
wrench = entityManager.SpawnEntity("WrenchDummy", coordinates);
|
||||
disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates);
|
||||
disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalUnit.Transform.MapPosition);
|
||||
|
||||
// Check that we have a grid, so that we can anchor our unit
|
||||
Assert.That(mapManager.TryFindGridAt(disposalUnit.Transform.MapPosition, out var _));
|
||||
|
||||
// Test for components existing
|
||||
Assert.True(disposalUnit.TryGetComponent(out unit!));
|
||||
Assert.True(disposalTrunk.HasComponent<DisposalEntryComponent>());
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.GameObjects.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -27,7 +26,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
{
|
||||
Task<DoAfterStatus> task = null;
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
// That it finishes successfully
|
||||
server.Post(() =>
|
||||
@@ -51,7 +50,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
{
|
||||
Task<DoAfterStatus> task = null;
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
server.Post(() =>
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
public async Task OpenCloseDestroyTest()
|
||||
{
|
||||
var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.PowerCell.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Coordinates;
|
||||
using NUnit.Framework;
|
||||
@@ -27,7 +25,7 @@ namespace Content.IntegrationTests.Tests
|
||||
CVarOverrides = {{CCVars.AIMaxUpdates.Name, int.MaxValue.ToString()}}
|
||||
};
|
||||
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -118,7 +116,7 @@ namespace Content.IntegrationTests.Tests
|
||||
- type: entity
|
||||
id: AllComponentsOneToOneDeleteTestEntity";
|
||||
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = testEntity,
|
||||
FailureLogLevel = LogLevel.Error
|
||||
@@ -221,10 +219,11 @@ namespace Content.IntegrationTests.Tests
|
||||
- type: entity
|
||||
id: AllComponentsOneEntityDeleteTestEntity";
|
||||
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ExtraPrototypes = testEntity,
|
||||
FailureLogLevel = LogLevel.Error
|
||||
FailureLogLevel = LogLevel.Error,
|
||||
Pool = false
|
||||
});
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.FixedPoint;
|
||||
using NUnit.Framework;
|
||||
@@ -19,46 +18,20 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
[Test]
|
||||
public async Task TilePuddleTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var pauseManager = server.ResolveDependency<IPauseManager>();
|
||||
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
|
||||
EntityCoordinates coordinates = default;
|
||||
|
||||
// Build up test environment
|
||||
server.Post(() =>
|
||||
{
|
||||
// Create a one tile grid to spill onto
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
pauseManager.AddUninitializedMap(mapId);
|
||||
|
||||
var gridId = new GridId(1);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
grid = mapManager.CreateGrid(mapId, gridId);
|
||||
}
|
||||
|
||||
var tileDefinition = tileDefinitionManager["underplating"];
|
||||
var tile = new Tile(tileDefinition.TileId);
|
||||
coordinates = grid.ToCoordinates();
|
||||
|
||||
grid.SetTile(coordinates, tile);
|
||||
|
||||
pauseManager.DoMapInitialize(mapId);
|
||||
});
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
var solution = new Solution("water", FixedPoint2.New(20));
|
||||
var grid = GetMainGrid(mapManager);
|
||||
var (x, y) = GetMainTile(grid).GridIndices;
|
||||
var coordinates = new EntityCoordinates(grid.GridEntityId, x, y);
|
||||
var puddle = solution.SpillAt(coordinates, "PuddleSmear");
|
||||
|
||||
Assert.NotNull(puddle);
|
||||
});
|
||||
|
||||
@@ -68,25 +41,22 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
[Test]
|
||||
public async Task SpaceNoPuddleTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var pauseManager = server.ResolveDependency<IPauseManager>();
|
||||
|
||||
IMapGrid grid = null;
|
||||
|
||||
// Build up test environment
|
||||
// Remove all tiles
|
||||
server.Post(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
grid = GetMainGrid(mapManager);
|
||||
|
||||
pauseManager.AddUninitializedMap(mapId);
|
||||
|
||||
var gridId = new GridId(1);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out grid))
|
||||
foreach (var tile in grid.GetAllTiles())
|
||||
{
|
||||
grid = mapManager.CreateGrid(mapId, gridId);
|
||||
grid.SetTile(tile.GridIndices, Tile.Empty);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
IEntity human;
|
||||
IEntity otherHuman;
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Actions;
|
||||
using Content.Client.Actions.UI;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
@@ -13,11 +12,11 @@ using Content.Shared.Actions.Prototypes;
|
||||
using Content.Shared.Cooldown;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using IPlayerManager = Robust.Server.Player.IPlayerManager;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
{
|
||||
@@ -244,7 +243,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
|
||||
// spawn and give them an item that has actions
|
||||
serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight",
|
||||
new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
new EntityCoordinates(serverPlayerEnt.Uid, (0, 0)));
|
||||
Assert.That(serverFlashlight.TryGetComponent<ItemActionsComponent>(out var itemActions));
|
||||
// we expect this only to have a toggle light action initially
|
||||
var actionConfigs = itemActions.ActionConfigs.ToList();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Climbing.Components;
|
||||
using Content.Shared.Physics;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -36,7 +35,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
IEntity human;
|
||||
IEntity table;
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Gravity.EntitySystems;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.Gravity;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -49,14 +48,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var gridId = new GridId(1);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
grid = mapManager.CreateGrid(mapId, gridId);
|
||||
}
|
||||
|
||||
var grid = GetMainGrid(mapManager);
|
||||
var coordinates = grid.ToCoordinates();
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Content.IntegrationTests.Tests
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
IEntity generator = null;
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
mapMan.CreateMap(new MapId(1));
|
||||
grid1 = mapMan.CreateGrid(new MapId(1));
|
||||
grid2 = mapMan.CreateGrid(new MapId(1));
|
||||
var mapId = GetMainMapId(mapMan);
|
||||
grid1 = mapMan.CreateGrid(mapId);
|
||||
grid2 = mapMan.CreateGrid(mapId);
|
||||
|
||||
var entityMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.IntegrationTests.Tests
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Content.IntegrationTests.Tests
|
||||
public async Task Test()
|
||||
{
|
||||
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
IEntity human = null;
|
||||
IEntity uniform = null;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -5,13 +12,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Hands.Components;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[Test]
|
||||
public async Task InteractionTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
@@ -107,7 +107,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[Test]
|
||||
public async Task InteractionObstructionTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
@@ -179,7 +179,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[Test]
|
||||
public async Task InteractionInRangeTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
@@ -249,7 +249,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[Test]
|
||||
public async Task InteractionOutOfRangeTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
@@ -318,7 +318,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[Test]
|
||||
public async Task InsideContainerInteractionBlockTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Content.IntegrationTests.Tests.Interaction
|
||||
[Test]
|
||||
public async Task EntityEntityTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ using Content.Server.Inventory;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Shared.Stunnable;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -50,7 +48,7 @@ namespace Content.IntegrationTests.Tests
|
||||
public async Task SpawnItemInSlotTest()
|
||||
{
|
||||
var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
IEntity human = null;
|
||||
InventoryComponent inventory = null;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Kitchen;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Kitchen
|
||||
@@ -14,7 +12,7 @@ namespace Content.IntegrationTests.Tests.Kitchen
|
||||
[Test]
|
||||
public async Task TestRecipesValid()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Client.Preferences;
|
||||
using Content.Client.State;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Preferences;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Shared;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Preferences;
|
||||
using NUnit.Framework;
|
||||
@@ -25,7 +21,16 @@ namespace Content.IntegrationTests.Tests.Lobby
|
||||
[Test]
|
||||
public async Task CreateDeleteCreateTest()
|
||||
{
|
||||
var (client, server) = await StartConnectedServerClientPair();
|
||||
var serverOptions = new ServerContentIntegrationOption
|
||||
{
|
||||
CVarOverrides =
|
||||
{
|
||||
[CCVars.GameDummyTicker.Name] = "false",
|
||||
[CCVars.GameLobbyEnabled.Name] = "true"
|
||||
}
|
||||
};
|
||||
|
||||
var (client, server) = await StartConnectedServerClientPair(serverOptions: serverOptions);
|
||||
|
||||
var clientNetManager = client.ResolveDependency<IClientNetManager>();
|
||||
var clientStateManager = client.ResolveDependency<IStateManager>();
|
||||
@@ -50,7 +55,7 @@ namespace Content.IntegrationTests.Tests.Lobby
|
||||
// Need to run them in sync to receive the messages.
|
||||
await RunTicksSync(client, server, 1);
|
||||
|
||||
await WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, maxTicks: 60);
|
||||
await WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, 600);
|
||||
|
||||
Assert.NotNull(clientNetManager.ServerChannel);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.IntegrationTests.Tests.Networking
|
||||
public async Task TestConnect()
|
||||
{
|
||||
var client = StartClient();
|
||||
var server = StartServer();
|
||||
var server = StartServer(new ServerContentIntegrationOption {Pool = false});
|
||||
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.IntegrationTests.Tests.Pathfinding
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
@@ -24,17 +24,15 @@ namespace Content.IntegrationTests.Tests.Pathfinding
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
// Setup
|
||||
var mapId = mapMan.CreateMap(new MapId(1));
|
||||
var gridId = new GridId(2);
|
||||
mapMan.CreateGrid(mapId, gridId);
|
||||
var chunkTile = mapMan.GetGrid(gridId).GetTileRef(new Vector2i(0, 0));
|
||||
var grid = GetMainGrid(mapMan);
|
||||
var chunkTile = grid.GetTileRef(new Vector2i(0, 0));
|
||||
var chunk = pathfindingSystem.GetChunk(chunkTile);
|
||||
Assert.That(chunk.Nodes.Length == PathfindingChunk.ChunkSize * PathfindingChunk.ChunkSize);
|
||||
|
||||
// Neighbors
|
||||
var chunkNeighbors = chunk.GetNeighbors().ToList();
|
||||
Assert.That(chunkNeighbors.Count == 0);
|
||||
var neighborChunkTile = mapMan.GetGrid(gridId).GetTileRef(new Vector2i(PathfindingChunk.ChunkSize, PathfindingChunk.ChunkSize));
|
||||
var neighborChunkTile = grid.GetTileRef(new Vector2i(PathfindingChunk.ChunkSize, PathfindingChunk.ChunkSize));
|
||||
var neighborChunk = pathfindingSystem.GetChunk(neighborChunkTile);
|
||||
chunkNeighbors = chunk.GetNeighbors().ToList();
|
||||
Assert.That(chunkNeighbors.Count == 1);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task NoSavedPostMapInitTest()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
public async Task Setup()
|
||||
{
|
||||
var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes};
|
||||
_server = StartServerDummyTicker(options);
|
||||
_server = StartServer(options);
|
||||
|
||||
await _server.WaitIdleAsync();
|
||||
_mapManager = _server.ResolveDependency<IMapManager>();
|
||||
|
||||
@@ -3,7 +3,6 @@ using NUnit.Framework;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -34,7 +33,8 @@ namespace Content.IntegrationTests.Tests
|
||||
var dir = new ResourcePath(mapPath).Directory;
|
||||
resManager.UserData.CreateDir(dir);
|
||||
|
||||
var mapId = mapManager.CreateMap(new MapId(5));
|
||||
var nextMapId = mapManager.NextMapId();
|
||||
var mapId = mapManager.CreateMap(nextMapId);
|
||||
|
||||
{
|
||||
var mapGrid = mapManager.CreateGrid(mapId);
|
||||
@@ -51,7 +51,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
mapLoader.SaveMap(mapId, mapPath);
|
||||
|
||||
mapManager.DeleteMap(new MapId(5));
|
||||
mapManager.DeleteMap(nextMapId);
|
||||
});
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task SaveLoadSave()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new ServerContentIntegrationOption {Pool = false});
|
||||
await server.WaitIdleAsync();
|
||||
var mapLoader = server.ResolveDependency<IMapLoader>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -86,7 +86,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
IMapGrid grid = default;
|
||||
|
||||
// Load stationstation.yml as uninitialized map, and save it to ensure it's up to date.
|
||||
// Load saltern.yml as uninitialized map, and save it to ensure it's up to date.
|
||||
server.Post(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Dispenser;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using NUnit.Framework;
|
||||
@@ -14,7 +13,7 @@ namespace Content.IntegrationTests.Tests.Solutions
|
||||
[Test]
|
||||
public async Task TestReagentDispenserInventory()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestServerStart()
|
||||
{
|
||||
var server = StartServer();
|
||||
var server = StartServer(new ServerContentIntegrationOption
|
||||
{
|
||||
Pool = false
|
||||
});
|
||||
server.RunTicks(5);
|
||||
await server.WaitIdleAsync();
|
||||
Assert.That(server.IsAlive);
|
||||
@@ -30,7 +33,10 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestClientStart()
|
||||
{
|
||||
var client = StartClient();
|
||||
var client = StartClient(new ClientContentIntegrationOption
|
||||
{
|
||||
Pool = false
|
||||
});
|
||||
await client.WaitIdleAsync();
|
||||
Assert.That(client.IsAlive);
|
||||
client.RunTicks(5);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.IntegrationTests.Tests.StationEvents
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@ using System.Threading.Tasks;
|
||||
using Content.Server.Storage.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -14,7 +12,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestStorageFillPrototypes()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
await server.WaitIdleAsync();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Content.IntegrationTests.Tests.Tag
|
||||
public async Task TagComponentTest()
|
||||
{
|
||||
var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes};
|
||||
var server = StartServerDummyTicker(options);
|
||||
var server = StartServer(options);
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@ using Content.Shared.Spawning;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Utility
|
||||
{
|
||||
@@ -45,18 +43,17 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var grid = sMapManager.GetGrid(new GridId(1));
|
||||
grid.SetTile(new Vector2i(0, 0), new Tile(1));
|
||||
var grid = GetMainGrid(sMapManager);
|
||||
var gridEnt = sEntityManager.GetEntity(grid.GridEntityId);
|
||||
var gridPos = gridEnt.Transform.WorldPosition;
|
||||
var entityCoordinates = new EntityCoordinates(grid.GridEntityId, 0, 0);
|
||||
var entityCoordinates = GetMainEntityCoordinates(sMapManager);
|
||||
|
||||
// Nothing blocking it, only entity is the grid
|
||||
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));
|
||||
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity));
|
||||
Assert.NotNull(entity);
|
||||
|
||||
var mapId = GetMainMapId(sMapManager);
|
||||
var mapCoordinates = new MapCoordinates(gridPos.X, gridPos.Y, mapId);
|
||||
|
||||
// Nothing blocking it, only entity is the grid
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Whitelist;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -70,7 +69,7 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = new MapId(1);
|
||||
var mapId = GetMainMapId(mapManager);
|
||||
var mapCoordinates = new MapCoordinates(0, 0, mapId);
|
||||
|
||||
var validComponent = entityManager.SpawnEntity("ValidComponentDummy", mapCoordinates);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
var server = StartServer();
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
|
||||
@@ -45,14 +45,14 @@ namespace Content.Server.AI.Pathfinding
|
||||
var tileOneWorld = tileOneGrid.ToMapPos(EntityManager);
|
||||
var tileTwoGrid = mapManager.GetGrid(to.GridIndex).GridTileToLocal(to.GridIndices);
|
||||
var tileTwoWorld = tileTwoGrid.ToMapPos(EntityManager);
|
||||
cameFrom.Add(tileOneWorld, tileTwoWorld);
|
||||
cameFrom[tileOneWorld] = tileTwoWorld;
|
||||
}
|
||||
|
||||
var gScores = new Dictionary<Vector2, float>();
|
||||
foreach (var (tile, score) in routeDebug.GScores)
|
||||
{
|
||||
var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices);
|
||||
gScores.Add(tileGrid.ToMapPos(EntityManager), score);
|
||||
gScores[tileGrid.ToMapPos(EntityManager)] = score;
|
||||
}
|
||||
|
||||
var systemMessage = new SharedAiDebug.AStarRouteMessage(
|
||||
|
||||
@@ -70,15 +70,6 @@ namespace Content.Server.Solar.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Owner.EnsureComponentWarn<PowerSupplierComponent>();
|
||||
|
||||
UpdateSupply();
|
||||
}
|
||||
|
||||
public void OnBreak(BreakageEventArgs args)
|
||||
{
|
||||
if (!Owner.TryGetComponent<SpriteComponent>(out var sprite))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Solar.Components;
|
||||
using Content.Shared.Physics;
|
||||
using JetBrains.Annotations;
|
||||
@@ -7,7 +8,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -71,11 +71,18 @@ namespace Content.Server.Solar.EntitySystems
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<SolarPanelComponent, MapInitEvent>(OnMapInit);
|
||||
|
||||
// Initialize the sun to something random
|
||||
TowardsSun = MathHelper.TwoPi * _robustRandom.NextDouble();
|
||||
SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05));
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, SolarPanelComponent component, MapInitEvent args)
|
||||
{
|
||||
UpdateSupply(uid, component);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
TowardsSun += SunAngularVelocity * frameTime;
|
||||
@@ -145,5 +152,18 @@ namespace Content.Server.Solar.EntitySystems
|
||||
// Total coverage calculated; apply it to the panel.
|
||||
panel.Coverage = coverage;
|
||||
}
|
||||
|
||||
private void UpdateSupply(
|
||||
EntityUid uid,
|
||||
SolarPanelComponent? solar = null,
|
||||
PowerSupplierComponent? supplier = null)
|
||||
{
|
||||
if (!Resolve(uid, ref solar, ref supplier))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
supplier.MaxSupply = (int) (solar.MaxSupply * solar.Coverage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user