forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request space-wizards#1341 from space-syndicate/upstream-sync
Upstream sync
- Loading branch information
Showing
194 changed files
with
50,524 additions
and
54,469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using Content.Shared.Chasm; | ||
using Robust.Client.Animations; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Animations; | ||
|
||
namespace Content.Client.Chasm; | ||
|
||
/// <summary> | ||
/// Handles the falling animation for entities that fall into a chasm. | ||
/// </summary> | ||
public sealed class ChasmFallingVisualsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly AnimationPlayerSystem _anim = default!; | ||
|
||
private readonly string _chasmFallAnimationKey = "chasm_fall"; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ChasmFallingComponent, ComponentInit>(OnComponentInit); | ||
SubscribeLocalEvent<ChasmFallingComponent, ComponentRemove>(OnComponentRemove); | ||
} | ||
|
||
private void OnComponentInit(EntityUid uid, ChasmFallingComponent component, ComponentInit args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
component.OriginalScale = sprite.Scale; | ||
|
||
var player = EnsureComp<AnimationPlayerComponent>(uid); | ||
if (_anim.HasRunningAnimation(player, _chasmFallAnimationKey)) | ||
return; | ||
|
||
_anim.Play(player, GetFallingAnimation(component), _chasmFallAnimationKey); | ||
} | ||
|
||
private void OnComponentRemove(EntityUid uid, ChasmFallingComponent component, ComponentRemove args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
var player = EnsureComp<AnimationPlayerComponent>(uid); | ||
if (_anim.HasRunningAnimation(player, _chasmFallAnimationKey)) | ||
_anim.Stop(player, _chasmFallAnimationKey); | ||
|
||
sprite.Scale = component.OriginalScale; | ||
} | ||
|
||
private Animation GetFallingAnimation(ChasmFallingComponent component) | ||
{ | ||
var length = component.AnimationTime; | ||
|
||
return new Animation() | ||
{ | ||
Length = length, | ||
AnimationTracks = | ||
{ | ||
new AnimationTrackComponentProperty() | ||
{ | ||
ComponentType = typeof(SpriteComponent), | ||
Property = nameof(SpriteComponent.Scale), | ||
KeyFrames = | ||
{ | ||
new AnimationTrackProperty.KeyFrame(component.OriginalScale, 0.0f), | ||
new AnimationTrackProperty.KeyFrame(component.AnimationScale, length.Seconds), | ||
}, | ||
InterpolationMode = AnimationInterpolationMode.Cubic | ||
} | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Linq; | ||
using Content.Shared.Actions; | ||
using Content.Shared.Actions.ActionTypes; | ||
using Content.Shared.CombatMode; | ||
using Robust.Server.Player; | ||
using Robust.Shared.GameObjects; | ||
|
||
namespace Content.IntegrationTests.Tests.Actions; | ||
|
||
/// <summary> | ||
/// This tests checks that actions properly get added to an entity's actions component.. | ||
/// </summary> | ||
[TestFixture] | ||
public sealed class ActionsAddedTest | ||
{ | ||
// TODO add magboot test (inventory action) | ||
// TODO add ghost toggle-fov test (client-side action) | ||
|
||
[Test] | ||
public async Task TestCombatActionsAdded() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false}); | ||
var server = pair.Server; | ||
var client = pair.Client; | ||
var sEntMan = server.ResolveDependency<IEntityManager>(); | ||
var cEntMan = client.ResolveDependency<IEntityManager>(); | ||
var session = server.ResolveDependency<IPlayerManager>().ServerSessions.Single(); | ||
|
||
// Dummy ticker is disabled - client should be in control of a normal mob. | ||
Assert.NotNull(session.AttachedEntity); | ||
var ent = session.AttachedEntity!.Value; | ||
Assert.That(sEntMan.EntityExists(ent)); | ||
Assert.That(cEntMan.EntityExists(ent)); | ||
Assert.That(sEntMan.HasComponent<ActionsComponent>(ent)); | ||
Assert.That(cEntMan.HasComponent<ActionsComponent>(ent)); | ||
Assert.That(sEntMan.HasComponent<CombatModeComponent>(ent)); | ||
Assert.That(cEntMan.HasComponent<CombatModeComponent>(ent)); | ||
|
||
var sComp = sEntMan.GetComponent<ActionsComponent>(ent); | ||
var cComp = cEntMan.GetComponent<ActionsComponent>(ent); | ||
|
||
// Mob should have a combat-mode action. | ||
// This action should have a non-null event both on the server & client. | ||
var evType = typeof(ToggleCombatActionEvent); | ||
|
||
var sActions = sComp!.Actions.Where( | ||
x => x is InstantAction act && act.Event?.GetType() == evType).ToArray(); | ||
var cActions = cComp!.Actions.Where( | ||
x => x is InstantAction act && act.Event?.GetType() == evType).ToArray(); | ||
|
||
Assert.That(sActions.Length, Is.EqualTo(1)); | ||
Assert.That(cActions.Length, Is.EqualTo(1)); | ||
|
||
var sAct = (InstantAction) sActions[0]; | ||
var cAct = (InstantAction) cActions[0]; | ||
|
||
// Finally, these two actions are not the same object | ||
// required, because integration tests do not respect the [NonSerialized] attribute and will simply events by reference. | ||
Assert.That(ReferenceEquals(sAct, cAct), Is.False); | ||
Assert.That(ReferenceEquals(sAct.Event, cAct.Event), Is.False); | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Linq; | ||
using Content.Server.Salvage; | ||
using Content.Shared.CCVar; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.IntegrationTests.Tests; | ||
|
||
[TestFixture] | ||
public sealed class SalvageTest | ||
{ | ||
/// <summary> | ||
/// Asserts that all salvage maps have been saved as grids and are loadable. | ||
/// </summary> | ||
[Test] | ||
public async Task AllSalvageMapsLoadableTest() | ||
{ | ||
await using var pairTracker = await PoolManager.GetServerClient(); | ||
var server = pairTracker.Pair.Server; | ||
|
||
var entManager = server.ResolveDependency<IEntityManager>(); | ||
var mapLoader = entManager.System<MapLoaderSystem>(); | ||
var mapManager = server.ResolveDependency<IMapManager>(); | ||
var prototypeManager = server.ResolveDependency<IPrototypeManager>(); | ||
var cfg = server.ResolveDependency<IConfigurationManager>(); | ||
Assert.That(cfg.GetCVar(CCVars.GridFill), Is.False); | ||
|
||
await server.WaitPost(() => | ||
{ | ||
foreach (var salvage in prototypeManager.EnumeratePrototypes<SalvageMapPrototype>()) | ||
{ | ||
var mapFile = salvage.MapPath; | ||
|
||
var mapId = mapManager.CreateMap(); | ||
try | ||
{ | ||
Assert.That(mapLoader.TryLoad(mapId, mapFile.ToString(), out var roots)); | ||
Assert.That(roots.Where(uid => entManager.HasComponent<MapGridComponent>(uid)), Is.Not.Empty); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new Exception($"Failed to load salvage map {salvage.ID}, was it saved as a map instead of a grid?", ex); | ||
} | ||
|
||
try | ||
{ | ||
mapManager.DeleteMap(mapId); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new Exception($"Failed to delete salvage map {salvage.ID}", ex); | ||
} | ||
} | ||
}); | ||
await server.WaitRunTicks(1); | ||
|
||
await pairTracker.CleanReturnAsync(); | ||
} | ||
} |
Oops, something went wrong.