mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 15:22:27 +02:00
* Broadphase refactor * Stuff * Working * TODO * Changes * Which fucking madman came up with this shit * Known gud state * Kinda shitcodey but it works so fuck it doin it live * Shuttle jankiness * Refactor entitylookups to be 30% more based * Refactor gucci * Done? * Fix most tests * nothing suss * Vera single-handedly saving shuttles * fex * Fix renderingtreecomp for relativity * Fix IEntityLookup * Fixes * Testing jank please revert some of it before merging * Fix the remaining bugs * Fix crash * Fix grid physics initialization * Shuttle collisions working * Fixes * Fixes * Velocity on transfers * Velocity on parent change * Fixes * world angular velocity too * Slightly faster map velocities * showbb revert * Sketch grids kinda workin * Fix PVS contact crash * Cleanup gridfixture updates 0.1% * Grid fixtures * AAAAAAAAAAAAAAA * a * termp * Fixes * Test reversion reversion? * Tests * Fix Equals * Slight box2i cleanup * Better initializer * Fix merge issues * Shuttles go BRRT * Remove MoveProxy from DynamicTreeBroadphase * Optimise a shit tonne * Approx * fix showbb * clean * Slightly more optimised * My almonds are activating * Contact transform caching * Avoid duplicates * Typo * Logger * Jitter 1% better * Okay shit maybe that's not it. * Contact fixes * Move check thingy up front * Revert some jank caching * Contact filtering * Fix master merge * Test fixes * Re-fix MapLoaderTest * Use proxies instead * uhh wtf? * Woops * Fix collisions * Fix grid fixture generation * Fix deserializing * Tile window fix * Cleanup broadphase * Bit more cleanup Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
129 lines
3.8 KiB
C#
129 lines
3.8 KiB
C#
using System.Linq;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Maps;
|
|
using Robust.Server.Physics;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.ContentPack;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Broadphase;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.UnitTesting.Server.Maps
|
|
{
|
|
[TestFixture]
|
|
public class MapLoaderTest : RobustUnitTest
|
|
{
|
|
private const string MapData = @"
|
|
meta:
|
|
format: 2
|
|
name: DemoStation
|
|
author: Space-Wizards
|
|
postmapinit: false
|
|
grids:
|
|
- settings:
|
|
chunksize: 16
|
|
tilesize: 1
|
|
snapsize: 1
|
|
chunks: []
|
|
tilemap: {}
|
|
entities:
|
|
- uid: 0
|
|
components:
|
|
- parent: null
|
|
type: Transform
|
|
- index: 0
|
|
type: MapGrid
|
|
- uid: 1
|
|
type: MapDeserializeTest
|
|
components:
|
|
- type: MapDeserializeTest
|
|
foo: 3
|
|
- parent: 0
|
|
type: Transform
|
|
";
|
|
|
|
private const string Prototype = @"
|
|
- type: entity
|
|
id: MapDeserializeTest
|
|
components:
|
|
- type: MapDeserializeTest
|
|
foo: 1
|
|
bar: 2
|
|
|
|
";
|
|
|
|
protected override void OverrideIoC()
|
|
{
|
|
base.OverrideIoC();
|
|
//var mockFormat = new Mock<ICustomFormatManager>();
|
|
var mock = new Mock<IEntitySystemManager>();
|
|
var broady = new BroadPhaseSystem();
|
|
var physics = new PhysicsSystem();
|
|
var gridFixtures = new GridFixtureSystem();
|
|
mock.Setup(m => m.GetEntitySystem<SharedBroadphaseSystem>()).Returns(broady);
|
|
mock.Setup(m => m.GetEntitySystem<SharedPhysicsSystem>()).Returns(physics);
|
|
mock.Setup(m => m.GetEntitySystem<GridFixtureSystem>()).Returns(gridFixtures);
|
|
|
|
IoCManager.RegisterInstance<IEntitySystemManager>(mock.Object, true);
|
|
//IoCManager.RegisterInstance<ICustomFormatManager>(mockFormat.Object, true);
|
|
}
|
|
|
|
|
|
[OneTimeSetUp]
|
|
public void Setup()
|
|
{
|
|
var compFactory = IoCManager.Resolve<IComponentFactory>();
|
|
compFactory.RegisterClass<MapDeserializeTestComponent>();
|
|
compFactory.GenerateNetIds();
|
|
IoCManager.Resolve<ISerializationManager>().Initialize();
|
|
|
|
var resourceManager = IoCManager.Resolve<IResourceManagerInternal>();
|
|
resourceManager.Initialize(null);
|
|
resourceManager.MountString("/TestMap.yml", MapData);
|
|
resourceManager.MountString("/Prototypes/TestMapEntity.yml", Prototype);
|
|
|
|
IoCManager.Resolve<IPrototypeManager>().LoadDirectory(new ResourcePath("/Prototypes"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDataLoadPriority()
|
|
{
|
|
// TODO: Fix after serv3
|
|
var map = IoCManager.Resolve<IMapManager>();
|
|
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
|
|
|
var mapId = map.CreateMap();
|
|
var mapLoad = IoCManager.Resolve<IMapLoader>();
|
|
var grid = mapLoad.LoadBlueprint(mapId, "/TestMap.yml");
|
|
|
|
Assert.That(grid, NUnit.Framework.Is.Not.Null);
|
|
|
|
var entity = entMan.GetEntity(grid!.GridEntityId).Transform.Children.Single().Owner;
|
|
var c = entity.GetComponent<MapDeserializeTestComponent>();
|
|
|
|
Assert.That(c.Bar, Is.EqualTo(2));
|
|
Assert.That(c.Foo, Is.EqualTo(3));
|
|
Assert.That(c.Baz, Is.EqualTo(-1));
|
|
}
|
|
|
|
[DataDefinition]
|
|
private sealed class MapDeserializeTestComponent : Component
|
|
{
|
|
public override string Name => "MapDeserializeTest";
|
|
|
|
[DataField("foo")] public int Foo { get; set; } = -1;
|
|
[DataField("bar")] public int Bar { get; set; } = -1;
|
|
[DataField("baz")] public int Baz { get; set; } = -1;
|
|
}
|
|
}
|
|
}
|