Skip to content

Commit

Permalink
Merge branch 'master-ru' into upstream-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MilenVolf committed Aug 16, 2023
2 parents 99f1cd2 + 127b6c8 commit ebd40c3
Show file tree
Hide file tree
Showing 239 changed files with 28,416 additions and 28,043 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml @EmoGarbage404
/Resources/Prototypes/Research/ @EmoGarbage404

/Content.*/Forensics/ @ficcialfaint

/Content.YAMLLinter @PaulRitter @DrSmugleaf
/Content.*/Inventory @PaulRitter
/Content.*/Arcade @PaulRitter
Expand Down
3 changes: 0 additions & 3 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ protected override void AddActionInternal(ActionsComponent comp, ActionType acti

public override void AddAction(EntityUid uid, ActionType action, EntityUid? provider, ActionsComponent? comp = null, bool dirty = true)
{
if (GameTiming.ApplyingState && !action.ClientExclusive)
return;

if (!Resolve(uid, ref comp, false))
return;

Expand Down
74 changes: 74 additions & 0 deletions Content.Client/Chasm/ChasmFallingVisualsSystem.cs
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
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private void AppendAction(ActionType action)

private void OnActionAdded(ActionType action)
{
// if the action is toggled when we add it, start targetting
// if the action is toggled when we add it, start targeting
if (action is TargetedAction targetAction && action.Toggled)
StartTargeting(targetAction);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Client.Alerts;
using Content.Client.Gameplay;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
Expand All @@ -15,7 +14,7 @@
namespace Content.Client.UserInterface.Systems.DamageOverlays;

[UsedImplicitly]
public sealed class DamageOverlayUiController : UIController, IOnStateChanged<GameplayState>
public sealed class DamageOverlayUiController : UIController
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
Expand All @@ -33,16 +32,6 @@ public override void Initialize()
SubscribeLocalEvent<MobThresholdChecked>(OnThresholdCheck);
}

public void OnStateEntered(GameplayState state)
{
_overlayManager.AddOverlay(_overlay);
}

public void OnStateExited(GameplayState state)
{
_overlayManager.RemoveOverlay(_overlay);
}

private void OnPlayerAttach(PlayerAttachedEvent args)
{
ClearOverlay();
Expand Down
64 changes: 64 additions & 0 deletions Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs
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();
}
}
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/RoundEndTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ await server.WaitAssertion(() =>
config.SetCVar(CCVars.GameLobbyEnabled, true);
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f);
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
config.SetCVar(CCVars.RoundRestartTime, 1f);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(300);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMilliseconds(100);
});

await server.WaitAssertion(() =>
Expand Down Expand Up @@ -131,10 +131,10 @@ await server.WaitAssertion(() =>
config.SetCVar(CCVars.GameLobbyEnabled, false);
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, CCVars.EmergencyShuttleMinTransitTime.DefaultValue);
config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue);
config.SetCVar(CCVars.RoundRestartTime, CCVars.RoundRestartTime.DefaultValue);
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMinutes(1);
ticker.RestartRound();
});
await PoolManager.ReallyBeIdle(pairTracker.Pair, 10);
Expand Down
63 changes: 63 additions & 0 deletions Content.IntegrationTests/Tests/SalvageTest.cs
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();
}
}
Loading

0 comments on commit ebd40c3

Please sign in to comment.