using System.Collections;
using Ashfall.Core;
using Ashfall.Runtime;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Ashfall.Tests
{
public sealed class FloorIsolationTests
{
[UnityTest]
public IEnumerator SameCoordinatesOnDifferentFloorsUseIsolatedPhysics()
{
var sim = new GameSimulation(WorldFactory.Create(), ContentCatalog.CreateDefault());
var a = sim.Connect("a", "一楼", Species.Human); var b = sim.Connect("b", "二楼", Species.Brood);
a.location = WorldFactory.At("lab", 0, new V2()); b.location = WorldFactory.At("lab", 1, new V2());
sim.World.Space("lab").floors[0].walls.Add(new WallState { id = "test.wall", bounds = new Box2(new V2(), new V2(2, 2)), height = 3 });
using (var physics = new FloorPhysics())
{
physics.Synchronize(sim.World, 1); yield return null; physics.Simulate(.05f);
Assert.That(physics.Blocked(a.location, .2f), Is.True);
Assert.That(physics.Blocked(b.location, .2f), Is.False);
}
yield return null;
}
[UnityTest]
public IEnumerator RuntimeBootsAndWormCanStartOffline()
{
yield return null;
var session = Object.FindFirstObjectByType<GameSession>();
Assert.That(session, Is.Not.Null);
session.UseTestSave(System.IO.Path.Combine(Application.temporaryCachePath, "AshfallTests", System.Guid.NewGuid().ToString("N") + ".sav"));
session.StartOffline(Species.Brood, "test", false);
yield return null;
Assert.That(session.LocalPlayer.IsWorm, Is.True);
Assert.That(Object.FindFirstObjectByType<WorldView>().Camera.orthographic, Is.True);
session.Stop(); session.UseTestSave(null);
}
}
}
using System.Collections;
using Ashfall.Core;
using Ashfall.Runtime;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Ashfall.Tests
{
public sealed class FloorIsolationTests
{
[UnityTest]
public IEnumerator SameCoordinatesOnDifferentFloorsUseIsolatedPhysics()
{
var sim = new GameSimulation(WorldFactory.Create(), ContentCatalog.CreateDefault());
var a = sim.Connect("a", "一楼", Species.Human); var b = sim.Connect("b", "二楼", Species.Brood);
a.location = WorldFactory.At("lab", 0, new V2()); b.location = WorldFactory.At("lab", 1, new V2());
sim.World.Space("lab").floors[0].walls.Add(new WallState { id = "test.wall", bounds = new Box2(new V2(), new V2(2, 2)), height = 3 });
using (var physics = new FloorPhysics())
{
physics.Synchronize(sim.World, 1); yield return null; physics.Simulate(.05f);
Assert.That(physics.Blocked(a.location, .2f), Is.True);
Assert.That(physics.Blocked(b.location, .2f), Is.False);
}
yield return null;
}
[UnityTest]
public IEnumerator RuntimeBootsAndWormCanStartOffline()
{
yield return null;
var session = Object.FindFirstObjectByType<GameSession>();
Assert.That(session, Is.Not.Null);
session.UseTestSave(System.IO.Path.Combine(Application.temporaryCachePath, "AshfallTests", System.Guid.NewGuid().ToString("N") + ".sav"));
session.StartOffline(Species.Brood, "test", false);
yield return null;
Assert.That(session.LocalPlayer.IsWorm, Is.True);
Assert.That(Object.FindFirstObjectByType<WorldView>().Camera.orthographic, Is.True);
session.Stop(); session.UseTestSave(null);
}
}
}