Merge branch 'master' into replace-sounds-with-sound-specifier

# Conflicts:
#	Content.Server/Kitchen/Components/ReagentGrinderComponent.cs
#	Content.Server/Storage/Components/SecureEntityStorageComponent.cs
This commit is contained in:
Galactic Chimp
2021-07-30 20:26:22 +02:00
117 changed files with 1807 additions and 1851 deletions

View File

@@ -142,6 +142,28 @@ namespace Content.Shared.Atmos
{
return (direction & other) == other;
}
public static Vector2i CardinalToIntVec(this Direction dir)
{
switch (dir)
{
case Direction.North:
return new Vector2i(0, 1);
case Direction.East:
return new Vector2i(1, 0);
case Direction.South:
return new Vector2i(0, -1);
case Direction.West:
return new Vector2i(-1, 0);
default:
throw new ArgumentException($"Direction dir {dir} is not a cardinal direction", nameof(dir));
}
}
public static Vector2i Offset(this Vector2i pos, Direction dir)
{
return pos + dir.CardinalToIntVec();
}
}
public sealed class AtmosDirectionFlags { }

View File

@@ -1,6 +1,7 @@
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using System;
// ReSharper disable InconsistentNaming
namespace Content.Shared.Atmos
{

View File

@@ -175,6 +175,12 @@ namespace Content.Shared.CCVar
* Physics
*/
/// <summary>
/// When a mob is walking should its X / Y movement be relative to its parent (true) or the map (false).
/// </summary>
public static readonly CVarDef<bool> RelativeMovement =
CVarDef.Create("physics.relative_movement", true, CVar.ARCHIVE | CVar.REPLICATED);
public static readonly CVarDef<float> TileFrictionModifier =
CVarDef.Create("physics.tile_friction", 40.0f);
@@ -285,7 +291,6 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> AtmosGridImpulse =
CVarDef.Create("atmos.grid_impulse", false, CVar.SERVERONLY);
/// <summary>
/// Whether atmos superconduction is enabled.
/// </summary>
@@ -293,10 +298,17 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> Superconduction =
CVarDef.Create("atmos.superconduction", false, CVar.SERVERONLY);
/// <summary>
/// Whether excited groups will be processed and created.
/// </summary>
public static readonly CVarDef<bool> ExcitedGroups =
CVarDef.Create("atmos.excited_groups", true, CVar.SERVERONLY);
/// <summary>
/// Whether all tiles in an excited group will clear themselves once being exposed to space.
/// Similar to <see cref="MonstermosDepressurization"/>, without none of the tile ripping or
/// things being thrown around very violently.
/// Needs <see cref="ExcitedGroups"/> to be enabled to work.
/// </summary>
public static readonly CVarDef<bool> ExcitedGroupsSpaceIsAllConsuming =
CVarDef.Create("atmos.excited_groups_space_is_all_consuming", false, CVar.SERVERONLY);

View File

@@ -4,6 +4,7 @@ using Content.Shared.Notification.Managers;
using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Physics;
@@ -17,6 +18,8 @@ namespace Content.Shared.Interaction
[UsedImplicitly]
public class SharedInteractionSystem : EntitySystem
{
[Dependency] private readonly SharedBroadphaseSystem _sharedBroadphaseSystem = default!;
public const float InteractionRange = 2;
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
@@ -46,7 +49,7 @@ namespace Content.Shared.Interaction
predicate ??= _ => false;
var ray = new CollisionRay(origin.Position, dir.Normalized, collisionMask);
var rayResults = Get<SharedBroadphaseSystem>().IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
if (rayResults.Count == 0) return dir.Length;
return (rayResults[0].HitPos - origin.Position).Length;
@@ -122,7 +125,7 @@ namespace Content.Shared.Interaction
predicate ??= _ => false;
var ray = new CollisionRay(origin.Position, dir.Normalized, (int) collisionMask);
var rayResults = Get<SharedBroadphaseSystem>().IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
if (rayResults.Count == 0) return true;

View File

@@ -51,16 +51,6 @@ namespace Content.Shared.Kitchen.Components
}
}
[Serializable, NetSerializable]
public class ReagentGrinderVaporizeReagentIndexedMessage : BoundUserInterfaceMessage
{
public Solution.ReagentQuantity ReagentQuantity;
public ReagentGrinderVaporizeReagentIndexedMessage(Solution.ReagentQuantity reagentQuantity)
{
ReagentQuantity = reagentQuantity;
}
}
[Serializable, NetSerializable]
public class ReagentGrinderWorkStartedMessage : BoundUserInterfaceMessage
{

View File

@@ -1,7 +1,9 @@
using Content.Shared.ActionBlocker;
using Content.Shared.CCVar;
using Content.Shared.MobState;
using Content.Shared.Movement.Components;
using Content.Shared.Pulling.Components;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
@@ -9,6 +11,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Broadphase;
using Robust.Shared.Physics.Controllers;
using Robust.Shared.Utility;
namespace Content.Shared.Movement
{
@@ -22,10 +25,14 @@ namespace Content.Shared.Movement
private SharedBroadphaseSystem _broadPhaseSystem = default!;
private bool _relativeMovement;
public override void Initialize()
{
base.Initialize();
_broadPhaseSystem = EntitySystem.Get<SharedBroadphaseSystem>();
var configManager = IoCManager.Resolve<IConfigurationManager>();
configManager.OnValueChanged(CCVars.RelativeMovement, value => _relativeMovement = value, true);
}
/// <summary>
@@ -39,12 +46,14 @@ namespace Content.Shared.Movement
// Target velocity.
var total = (walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed);
if (total != Vector2.Zero)
var worldTotal = _relativeMovement ? new Angle(mover.Owner.Transform.Parent!.WorldRotation.Theta).RotateVec(total) : total;
if (worldTotal != Vector2.Zero)
{
mover.Owner.Transform.LocalRotation = total.GetDir().ToAngle();
mover.Owner.Transform.WorldRotation = worldTotal.GetDir().ToAngle();
}
physicsComponent.LinearVelocity = total;
physicsComponent.LinearVelocity = worldTotal;
}
/// <summary>
@@ -53,7 +62,8 @@ namespace Content.Shared.Movement
/// <param name="mover"></param>
/// <param name="physicsComponent"></param>
/// <param name="mobMover"></param>
protected void HandleMobMovement(IMoverComponent mover, PhysicsComponent physicsComponent, IMobMoverComponent mobMover)
protected void HandleMobMovement(IMoverComponent mover, PhysicsComponent physicsComponent,
IMobMoverComponent mobMover)
{
// TODO: Look at https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/CharacterControllers.html?highlight=controller as it has some adviceo n kinematic controllersx
if (!UseMobMovement(_broadPhaseSystem, physicsComponent, _mapManager))
@@ -74,30 +84,37 @@ namespace Content.Shared.Movement
if (!touching)
{
transform.LocalRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
transform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
return;
}
}
// Regular movement.
// Target velocity.
// This is relative to the map / grid we're on.
var total = (walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed);
var worldTotal = _relativeMovement ?
new Angle(transform.Parent!.WorldRotation.Theta).RotateVec(total) :
total;
DebugTools.Assert(MathHelper.CloseTo(total.Length, worldTotal.Length));
if (weightless)
{
total *= mobMover.WeightlessStrength;
worldTotal *= mobMover.WeightlessStrength;
}
if (total != Vector2.Zero)
if (worldTotal != Vector2.Zero)
{
// This should have its event run during island solver soooo
transform.DeferUpdates = true;
transform.LocalRotation = total.GetDir().ToAngle();
transform.WorldRotation = worldTotal.GetDir().ToAngle();
transform.DeferUpdates = false;
HandleFootsteps(mover, mobMover);
}
physicsComponent.LinearVelocity = total;
physicsComponent.LinearVelocity = worldTotal;
}
public static bool UseMobMovement(SharedBroadphaseSystem broadPhaseSystem, PhysicsComponent body, IMapManager mapManager)

View File

@@ -1,28 +0,0 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Nutrition.Components
{
public abstract class SharedFoodContainerComponent : Component
{
}
[NetSerializable, Serializable]
public enum FoodContainerVisualMode
{
/// <summary>
/// Discrete: 50 eggs in a carton -> down to 25, will show 12/12 until it gets below max
/// Rounded: 50 eggs in a carton -> down to 25, will round it to 6 of 12
/// </summary>
Discrete,
Rounded,
}
[NetSerializable, Serializable]
public enum FoodContainerVisuals
{
Capacity,
Current,
}
}

View File

@@ -1,4 +1,6 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.SubFloor
{
@@ -13,5 +15,12 @@ namespace Content.Shared.SubFloor
{
/// <inheritdoc />
public override string Name => "SubFloorHide";
/// <summary>
/// This entity needs to be anchored to be hid in the subfloor.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("requireAnchored")]
public bool RequireAnchored { get; set; } = true;
}
}

View File

@@ -68,8 +68,7 @@ namespace Content.Shared.SubFloor
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
// We do this directly instead of calling UpdateEntity.
if(_mapManager.TryGetGrid(transform.GridID, out var grid))
UpdateTile(grid, grid.TileIndicesFor(transform.Coordinates));
UpdateEntity(uid);
}
private void MapManagerOnTileChanged(object? sender, TileChangedEventArgs e)
@@ -113,6 +112,7 @@ namespace Content.Shared.SubFloor
private void UpdateEntity(EntityUid uid)
{
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
if (!_mapManager.TryGetGrid(transform.GridID, out var grid))
{
// Not being on a grid counts as no subfloor, unhide this.
@@ -134,6 +134,18 @@ namespace Content.Shared.SubFloor
if (subFloorHideEvent.Handled)
return;
// This might look weird, but basically we only need to query the SubFloorHide and Transform components
// if we are gonna hide the entity and we require it to be anchored to be hidden. Because getting components
// is "expensive", we have a slow path where we query them, and a fast path where we don't.
if (!subFloor
&& ComponentManager.TryGetComponent(uid, out SubFloorHideComponent? subFloorHideComponent) &&
subFloorHideComponent.RequireAnchored
&& ComponentManager.TryGetComponent(uid, out ITransformComponent? transformComponent))
{
// If we require the entity to be anchored but it's not, this will set subfloor to true, unhiding it.
subFloor = !transformComponent.Anchored;
}
// Show sprite
if (ComponentManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
{