Files
crystall-punk-14/Content.IntegrationTests/Tests/Payload/ModularGrenadeTests.cs

75 lines
2.4 KiB
C#
Raw Permalink Normal View History

2023-04-15 07:41:25 +12:00
using Content.IntegrationTests.Tests.Interaction;
using Content.Server.Explosion.Components;
Move grenade components to shared (#22691) * Moves FlashComponent.cs, FlashOnTriggerComponent.cs, and SmokeOnTriggerComponent.cs to Shared * Moves ExplodeOnTriggerComponent.cs, OnUseTimerTriggerComponent.cs, ActiveTimerTriggerComponent.cs, and SmokeOnTriggerComponent.cs to Shared * Delete .run/Content Server+Client.run.xml HOW DID THIS GET IN HERE ITS NOT AHHHH * Update Content.Client/Explosion/SmokeOnTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/ActiveTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/OnUseTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/OnUseTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/EntitySystems/SharedTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/EntitySystems/SharedSmokeOnTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update ExplodeOnTriggerComponent.cs * Revert "Delete .run/Content Server+Client.run.xml" This reverts commit 29ee05f57de60eab5c92158d8eba5e3acba483c2. * Fix? * cannot figure out how to get this to go back please forgive * Fixes a network issue * leftovers * Fixes --------- Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-02-01 07:29:01 -06:00
using Content.Shared.Explosion.Components;
2023-04-15 07:41:25 +12:00
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Payload;
public sealed class ModularGrenadeTests : InteractionTest
{
public const string Trigger = "TimerTrigger";
public const string Payload = "ExplosivePayload";
/// <summary>
/// Test that a modular grenade can be fully crafted and detonated.
/// </summary>
[Test]
public async Task AssembleAndDetonateGrenade()
{
await PlaceInHands(Steel, 5);
await CraftItem("ModularGrenadeRecipe");
Target = SEntMan.GetNetEntity(await FindEntity("ModularGrenade"));
2023-04-15 07:41:25 +12:00
await Drop();
2024-06-04 09:05:51 +12:00
await InteractUsing(Cable);
2023-04-15 07:41:25 +12:00
// Insert & remove trigger
AssertComp<OnUseTimerTriggerComponent>(false);
2024-06-04 09:05:51 +12:00
await InteractUsing(Trigger);
2023-04-15 07:41:25 +12:00
AssertComp<OnUseTimerTriggerComponent>();
await FindEntity(Trigger, LookupFlags.Uncontained, shouldSucceed: false);
2024-06-04 09:05:51 +12:00
await InteractUsing(Pry);
2023-04-15 07:41:25 +12:00
AssertComp<OnUseTimerTriggerComponent>(false);
// Trigger was dropped to floor, not deleted.
await FindEntity(Trigger, LookupFlags.Uncontained);
// Re-insert
2024-06-04 09:05:51 +12:00
await InteractUsing(Trigger);
2023-04-15 07:41:25 +12:00
AssertComp<OnUseTimerTriggerComponent>();
// Insert & remove payload.
2024-06-04 09:05:51 +12:00
await InteractUsing(Payload);
2023-04-15 07:41:25 +12:00
await FindEntity(Payload, LookupFlags.Uncontained, shouldSucceed: false);
2024-06-04 09:05:51 +12:00
await InteractUsing(Pry);
2023-04-15 07:41:25 +12:00
var ent = await FindEntity(Payload, LookupFlags.Uncontained);
await Delete(ent);
// successfully insert a second time
2024-06-04 09:05:51 +12:00
await InteractUsing(Payload);
2023-04-15 07:41:25 +12:00
ent = await FindEntity(Payload);
var sys = SEntMan.System<SharedContainerSystem>();
Assert.That(sys.IsEntityInContainer(ent));
// Activate trigger.
await Pickup();
AssertComp<ActiveTimerTriggerComponent>(false);
await UseInHand();
// So uhhh grenades in hands don't destroy themselves when exploding. Maybe that will be fixed eventually.
await Drop();
// Wait until grenade explodes
var timer = Comp<ActiveTimerTriggerComponent>();
while (timer.TimeRemaining >= 0)
{
await RunTicks(10);
}
// Grenade has exploded.
await RunTicks(30);
2023-04-15 07:41:25 +12:00
AssertDeleted();
}
}