mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
d42adbf05d
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
247 lines
8.4 KiB
C#
247 lines
8.4 KiB
C#
#nullable enable annotations
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Content.Server.Disposal.Unit;
|
|
using Content.Server.Power.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared.Disposal.Components;
|
|
using Content.Shared.Disposal.Tube;
|
|
using Content.Shared.Disposal.Unit;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Reflection;
|
|
|
|
namespace Content.IntegrationTests.Tests.Disposal
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(DisposalHolderComponent))]
|
|
[TestOf(typeof(DisposalEntryComponent))]
|
|
[TestOf(typeof(DisposalUnitComponent))]
|
|
public sealed class DisposalUnitTest : GameTest
|
|
{
|
|
[Reflect(false)]
|
|
private sealed class DisposalUnitTestSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DoInsertDisposalUnitEvent>(ev =>
|
|
{
|
|
var (_, toInsert, unit) = ev;
|
|
var insertTransform = Comp<TransformComponent>(toInsert);
|
|
// Not in a tube yet
|
|
Assert.That(insertTransform.ParentUid, Is.EqualTo(unit));
|
|
}, after: new[] { typeof(SharedDisposalUnitSystem) });
|
|
}
|
|
}
|
|
|
|
private static void UnitInsert(EntityUid uid, DisposalUnitComponent unit, bool result, DisposalUnitSystem disposalSystem, params EntityUid[] entities)
|
|
{
|
|
foreach (var entity in entities)
|
|
{
|
|
Assert.That(disposalSystem.CanInsert(uid, unit, entity), Is.EqualTo(result));
|
|
disposalSystem.TryInsert(uid, entity, null);
|
|
}
|
|
}
|
|
|
|
private static void UnitContains(DisposalUnitComponent unit, bool result, params EntityUid[] entities)
|
|
{
|
|
foreach (var entity in entities)
|
|
{
|
|
Assert.That(unit.Container.ContainedEntities.Contains(entity), Is.EqualTo(result));
|
|
}
|
|
}
|
|
|
|
private static void UnitInsertContains(EntityUid uid, DisposalUnitComponent unit, bool result, DisposalUnitSystem disposalSystem, params EntityUid[] entities)
|
|
{
|
|
UnitInsert(uid, unit, result, disposalSystem, entities);
|
|
UnitContains(unit, result, entities);
|
|
}
|
|
|
|
private static void Flush(EntityUid unitEntity, DisposalUnitComponent unit, bool result, DisposalUnitSystem disposalSystem, params EntityUid[] entities)
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(unit.Container.ContainedEntities, Is.SupersetOf(entities));
|
|
Assert.That(entities, Has.Length.EqualTo(unit.Container.ContainedEntities.Count));
|
|
|
|
Assert.That(result, Is.EqualTo(disposalSystem.TryFlush(unitEntity, unit)));
|
|
Assert.That(result || entities.Length == 0, Is.EqualTo(unit.Container.ContainedEntities.Count == 0));
|
|
});
|
|
}
|
|
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: HumanDisposalDummy
|
|
id: HumanDisposalDummy
|
|
components:
|
|
- type: Body
|
|
prototype: Human
|
|
- type: MobState
|
|
- type: MobThresholds
|
|
thresholds:
|
|
0: Alive
|
|
200: Dead
|
|
- type: Damageable
|
|
damageContainer: Biological
|
|
- type: Physics
|
|
bodyType: KinematicController
|
|
- type: Fixtures
|
|
fixtures:
|
|
fix1:
|
|
shape:
|
|
!type:PhysShapeCircle
|
|
radius: 0.35
|
|
- type: DoAfter
|
|
|
|
- type: entity
|
|
name: WrenchDummy
|
|
id: WrenchDummy
|
|
components:
|
|
- type: Item
|
|
- type: Tool
|
|
qualities:
|
|
- Anchoring
|
|
- type: Physics
|
|
bodyType: Dynamic
|
|
- type: Fixtures
|
|
fixtures:
|
|
fix1:
|
|
shape:
|
|
!type:PhysShapeCircle
|
|
radius: 0.35
|
|
- type: DoAfter
|
|
|
|
- type: entity
|
|
name: DisposalUnitDummy
|
|
id: DisposalUnitDummy
|
|
components:
|
|
- type: DisposalUnit
|
|
entryDelay: 0
|
|
draggedEntryDelay: 0
|
|
flushTime: 0
|
|
- type: Anchorable
|
|
- type: ApcPowerReceiver
|
|
- type: Physics
|
|
bodyType: Static
|
|
- type: Fixtures
|
|
fixtures:
|
|
fix1:
|
|
shape:
|
|
!type:PhysShapeCircle
|
|
radius: 0.35
|
|
|
|
- type: entity
|
|
name: DisposalTrunkDummy
|
|
id: DisposalTrunkDummy
|
|
components:
|
|
- type: DisposalEntry
|
|
- type: DisposalTube
|
|
- type: Transform
|
|
anchored: true
|
|
";
|
|
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
|
|
var testMap = await pair.CreateTestMap();
|
|
|
|
EntityUid human = default!;
|
|
EntityUid wrench = default!;
|
|
EntityUid disposalUnit = default!;
|
|
EntityUid disposalTrunk = default!;
|
|
|
|
EntityUid unitUid = default;
|
|
DisposalUnitComponent unitComponent = default!;
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var xformSystem = entityManager.System<SharedTransformSystem>();
|
|
var disposalSystem = entityManager.System<DisposalUnitSystem>();
|
|
var power = entityManager.System<PowerReceiverSystem>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
// Spawn the entities
|
|
var coordinates = testMap.GridCoords;
|
|
human = entityManager.SpawnEntity("HumanDisposalDummy", coordinates);
|
|
wrench = entityManager.SpawnEntity("WrenchDummy", coordinates);
|
|
disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates);
|
|
disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", coordinates);
|
|
|
|
// Test for components existing
|
|
unitUid = disposalUnit;
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(entityManager.TryGetComponent(disposalUnit, out unitComponent));
|
|
Assert.That(entityManager.HasComponent<DisposalEntryComponent>(disposalTrunk));
|
|
});
|
|
|
|
// Can't insert, unanchored and unpowered
|
|
xformSystem.Unanchor(unitUid, entityManager.GetComponent<TransformComponent>(unitUid));
|
|
UnitInsertContains(disposalUnit, unitComponent, false, disposalSystem, human, wrench, disposalUnit, disposalTrunk);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
// Anchor the disposal unit
|
|
xformSystem.AnchorEntity(unitUid, entityManager.GetComponent<TransformComponent>(unitUid));
|
|
|
|
// No power
|
|
Assert.That(power.IsPowered(unitUid), Is.False);
|
|
|
|
// Can't insert the trunk or the unit into itself
|
|
UnitInsertContains(unitUid, unitComponent, false, disposalSystem, disposalUnit, disposalTrunk);
|
|
|
|
// Can insert mobs and items
|
|
UnitInsertContains(unitUid, unitComponent, true, disposalSystem, human, wrench);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var worldPos = xformSystem.GetWorldPosition(disposalTrunk);
|
|
|
|
// Move the disposal trunk away
|
|
xformSystem.SetWorldPosition(disposalTrunk, worldPos + new Vector2(1, 0));
|
|
|
|
// Fail to flush with a mob and an item
|
|
Flush(disposalUnit, unitComponent, false, disposalSystem, human, wrench);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var xform = entityManager.GetComponent<TransformComponent>(disposalTrunk);
|
|
var worldPos = xformSystem.GetWorldPosition(disposalUnit);
|
|
|
|
// Move the disposal trunk back
|
|
xformSystem.SetWorldPosition(disposalTrunk, worldPos);
|
|
xformSystem.AnchorEntity((disposalTrunk, xform));
|
|
|
|
// Fail to flush with a mob and an item, no power
|
|
Flush(disposalUnit, unitComponent, false, disposalSystem, human, wrench);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
// Remove power need
|
|
Assert.That(entityManager.TryGetComponent(disposalUnit, out ApcPowerReceiverComponent powerComp));
|
|
power.SetNeedsPower(disposalUnit, false);
|
|
powerComp.Powered = true;
|
|
|
|
// Flush with a mob and an item
|
|
Flush(disposalUnit, unitComponent, true, disposalSystem, human, wrench);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
// Re-pressurizing
|
|
Flush(disposalUnit, unitComponent, false, disposalSystem);
|
|
});
|
|
}
|
|
}
|
|
}
|