Rotate DefaultGrid on round start (#4957)
* Rotate DefaultGrid on round start Not ideal long-term but good for bugspotting short-term. * Fix buckle test Because gridtraversal was being triggered the pos was being fucked when moving back * Fix buckle * Buckle offset
This commit is contained in:
@@ -103,7 +103,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
|||||||
Assert.False(actionBlocker.CanMove(human));
|
Assert.False(actionBlocker.CanMove(human));
|
||||||
Assert.False(actionBlocker.CanChangeDirection(human));
|
Assert.False(actionBlocker.CanChangeDirection(human));
|
||||||
Assert.False(EffectBlockerSystem.CanFall(human));
|
Assert.False(EffectBlockerSystem.CanFall(human));
|
||||||
Assert.That(human.Transform.WorldPosition, Is.EqualTo(chair.Transform.WorldPosition));
|
Assert.That((human.Transform.WorldPosition - chair.Transform.WorldPosition).Length, Is.LessThanOrEqualTo(buckle.BuckleOffset.Length));
|
||||||
|
|
||||||
// Side effects of buckling for the strap
|
// Side effects of buckling for the strap
|
||||||
Assert.That(strap.BuckledEntities, Does.Contain(human));
|
Assert.That(strap.BuckledEntities, Does.Contain(human));
|
||||||
@@ -333,7 +333,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
|||||||
Assert.True(buckle.Buckled);
|
Assert.True(buckle.Buckled);
|
||||||
|
|
||||||
// Move the buckled entity away
|
// Move the buckled entity away
|
||||||
human.Transform.LocalPosition += (100, 0);
|
human.Transform.WorldPosition += (100, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
await WaitUntil(server, () => !buckle.Buckled, 10);
|
await WaitUntil(server, () => !buckle.Buckled, 10);
|
||||||
@@ -343,7 +343,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
// Move the now unbuckled entity back onto the chair
|
// Move the now unbuckled entity back onto the chair
|
||||||
human.Transform.LocalPosition -= (100, 0);
|
human.Transform.WorldPosition -= (100, 0);
|
||||||
|
|
||||||
// Buckle
|
// Buckle
|
||||||
Assert.True(buckle.TryBuckle(human, chair));
|
Assert.True(buckle.TryBuckle(human, chair));
|
||||||
|
|||||||
@@ -122,33 +122,21 @@ namespace Content.Server.Buckle.Components
|
|||||||
var strapTransform = strap.Owner.Transform;
|
var strapTransform = strap.Owner.Transform;
|
||||||
|
|
||||||
ownTransform.AttachParent(strapTransform);
|
ownTransform.AttachParent(strapTransform);
|
||||||
|
ownTransform.LocalRotation = Angle.Zero;
|
||||||
|
|
||||||
switch (strap.Position)
|
switch (strap.Position)
|
||||||
{
|
{
|
||||||
case StrapPosition.None:
|
case StrapPosition.None:
|
||||||
ownTransform.WorldRotation = strapTransform.WorldRotation;
|
|
||||||
break;
|
break;
|
||||||
case StrapPosition.Stand:
|
case StrapPosition.Stand:
|
||||||
EntitySystem.Get<StandingStateSystem>().Stand(Owner.Uid);
|
EntitySystem.Get<StandingStateSystem>().Stand(Owner.Uid);
|
||||||
ownTransform.WorldRotation = strapTransform.WorldRotation;
|
|
||||||
break;
|
break;
|
||||||
case StrapPosition.Down:
|
case StrapPosition.Down:
|
||||||
EntitySystem.Get<StandingStateSystem>().Down(Owner.Uid, false, false);
|
EntitySystem.Get<StandingStateSystem>().Down(Owner.Uid, false, false);
|
||||||
ownTransform.LocalRotation = Angle.Zero;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign BuckleOffset first, before causing a MoveEvent to fire
|
ownTransform.LocalPosition = Vector2.Zero + BuckleOffset;
|
||||||
if (strapTransform.WorldRotation.GetCardinalDir() == Direction.North)
|
|
||||||
{
|
|
||||||
BuckleOffset = (0, 0.15f);
|
|
||||||
ownTransform.WorldPosition = strapTransform.WorldPosition + BuckleOffset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BuckleOffset = Vector2.Zero;
|
|
||||||
ownTransform.WorldPosition = strapTransform.WorldPosition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanBuckle(IEntity? user, IEntity to, [NotNullWhen(true)] out StrapComponent? strap)
|
public bool CanBuckle(IEntity? user, IEntity to, [NotNullWhen(true)] out StrapComponent? strap)
|
||||||
@@ -403,7 +391,7 @@ namespace Content.Server.Buckle.Components
|
|||||||
int? drawDepth = null;
|
int? drawDepth = null;
|
||||||
|
|
||||||
if (BuckledTo != null &&
|
if (BuckledTo != null &&
|
||||||
Owner.Transform.WorldRotation.GetCardinalDir() == Direction.North &&
|
BuckledTo.Owner.Transform.LocalRotation.GetCardinalDir() == Direction.North &&
|
||||||
BuckledTo.SpriteComponent != null)
|
BuckledTo.SpriteComponent != null)
|
||||||
{
|
{
|
||||||
drawDepth = BuckledTo.SpriteComponent.DrawDepth - 1;
|
drawDepth = BuckledTo.SpriteComponent.DrawDepth - 1;
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ namespace Content.Server.GameTicking
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool StationOffset { get; private set; } = false;
|
public bool StationOffset { get; private set; } = false;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public bool StationRotation { get; private set; } = false;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public float MaxStationOffset { get; private set; } = 0f;
|
public float MaxStationOffset { get; private set; } = 0f;
|
||||||
|
|
||||||
@@ -36,6 +39,7 @@ namespace Content.Server.GameTicking
|
|||||||
_configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins,
|
_configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins,
|
||||||
value => { DisallowLateJoin = value; UpdateLateJoinStatus(); UpdateJobsAvailable(); }, true);
|
value => { DisallowLateJoin = value; UpdateLateJoinStatus(); UpdateJobsAvailable(); }, true);
|
||||||
_configurationManager.OnValueChanged(CCVars.StationOffset, value => StationOffset = value, true);
|
_configurationManager.OnValueChanged(CCVars.StationOffset, value => StationOffset = value, true);
|
||||||
|
_configurationManager.OnValueChanged(CCVars.StationRotation, value => StationRotation = value, true);
|
||||||
_configurationManager.OnValueChanged(CCVars.MaxStationOffset, value => MaxStationOffset = value, true);
|
_configurationManager.OnValueChanged(CCVars.MaxStationOffset, value => MaxStationOffset = value, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Content.Shared.GameTicking;
|
|||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Prometheus;
|
using Prometheus;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
@@ -63,12 +64,19 @@ namespace Content.Server.GameTicking
|
|||||||
throw new InvalidOperationException($"No grid found for map {map}");
|
throw new InvalidOperationException($"No grid found for map {map}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stationXform = EntityManager.GetComponent<ITransformComponent>(grid.GridEntityId);
|
||||||
|
|
||||||
if (StationOffset)
|
if (StationOffset)
|
||||||
{
|
{
|
||||||
// Apply a random offset to the station grid entity.
|
// Apply a random offset to the station grid entity.
|
||||||
var x = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
var x = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
||||||
var y = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
var y = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
||||||
EntityManager.GetEntity(grid.GridEntityId).Transform.LocalPosition = new Vector2(x, y);
|
stationXform.LocalPosition = new Vector2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StationRotation)
|
||||||
|
{
|
||||||
|
stationXform.LocalRotation = _robustRandom.NextFloat(MathF.Tau);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultGridId = grid.Index;
|
DefaultGridId = grid.Index;
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<float> MaxStationOffset =
|
public static readonly CVarDef<float> MaxStationOffset =
|
||||||
CVarDef.Create("game.maxstationoffset", 1000.0f);
|
CVarDef.Create("game.maxstationoffset", 1000.0f);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a random rotation will be applied to the station on roundstart.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> StationRotation =
|
||||||
|
CVarDef.Create("game.station_rotation", true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
|
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user