Merge branch 'master' into replace-sounds-with-sound-specifier
# Conflicts: # Content.Server/Actions/Actions/DisarmAction.cs # Content.Server/Actions/Actions/ScreamAction.cs # Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs # Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs # Content.Server/Explosion/Components/FlashExplosiveComponent.cs # Content.Server/Physics/Controllers/MoverController.cs # Content.Server/Portal/Components/PortalComponent.cs # Content.Server/Portal/Components/TeleporterComponent.cs # Content.Server/Projectiles/Components/ProjectileComponent.cs # Content.Server/Singularity/Components/EmitterComponent.cs # Content.Server/Sound/EmitSoundSystem.cs # Content.Server/Stunnable/Components/StunbatonComponent.cs # Content.Server/Tools/Components/MultitoolComponent.cs # Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs # Content.Shared/Gravity/GravityComponent.cs # Content.Shared/Light/Component/SharedExpendableLightComponent.cs # Content.Shared/Maps/ContentTileDefinition.cs # Content.Shared/Slippery/SlipperyComponent.cs # Content.Shared/Standing/StandingStateComponent.cs # Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Conveyor;
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Movement.Components;
|
||||
using Content.Server.Shuttle;
|
||||
using Content.Server.Shuttles;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Shuttles;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
@@ -39,12 +43,17 @@ namespace Content.Server.Physics.Controllers
|
||||
private const float StepSoundMoveDistanceRunning = 2;
|
||||
private const float StepSoundMoveDistanceWalking = 1.5f;
|
||||
|
||||
private float _shuttleDockSpeedCap;
|
||||
|
||||
private HashSet<EntityUid> _excludedMobs = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_audioSystem = EntitySystem.Get<AudioSystem>();
|
||||
|
||||
var configManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
configManager.OnValueChanged(CCVars.ShuttleDockSpeedCap, value => _shuttleDockSpeedCap = value, true);
|
||||
}
|
||||
|
||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
||||
@@ -58,8 +67,9 @@ namespace Content.Server.Physics.Controllers
|
||||
HandleMobMovement(mover, physics, mobMover);
|
||||
}
|
||||
|
||||
foreach (var mover in ComponentManager.EntityQuery<ShuttleControllerComponent>())
|
||||
foreach (var (pilot, mover) in ComponentManager.EntityQuery<PilotComponent, SharedPlayerInputMoverComponent>())
|
||||
{
|
||||
if (pilot.Console == null) continue;
|
||||
_excludedMobs.Add(mover.Owner.Uid);
|
||||
HandleShuttleMovement(mover);
|
||||
}
|
||||
@@ -78,24 +88,70 @@ namespace Content.Server.Physics.Controllers
|
||||
* The reason for this is that vehicles change direction very slowly compared to players so you don't really have the requirement for quick movement anyway
|
||||
* As such could probably just look at applying a force / impulse to the shuttle server-side only so it controls like the titanic.
|
||||
*/
|
||||
private void HandleShuttleMovement(ShuttleControllerComponent mover)
|
||||
private void HandleShuttleMovement(SharedPlayerInputMoverComponent mover)
|
||||
{
|
||||
var gridId = mover.Owner.Transform.GridID;
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid) || !EntityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) return;
|
||||
|
||||
//TODO: Switch to shuttle component
|
||||
if (!gridEntity.TryGetComponent(out PhysicsComponent? physics))
|
||||
if (!gridEntity.TryGetComponent(out ShuttleComponent? shuttleComponent) ||
|
||||
!gridEntity.TryGetComponent(out PhysicsComponent? physicsComponent))
|
||||
{
|
||||
physics = gridEntity.AddComponent<PhysicsComponent>();
|
||||
physics.BodyStatus = BodyStatus.InAir;
|
||||
physics.CanCollide = true;
|
||||
physics.AddFixture(new Fixture(physics, new PhysShapeGrid(grid)));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Uhh this probably doesn't work but I still need to rip out the entity tree and make RenderingTreeSystem use grids so I'm not overly concerned about breaking shuttles.
|
||||
physics.ApplyForce(mover.VelocityDir.walking + mover.VelocityDir.sprinting);
|
||||
mover.VelocityDir = (Vector2.Zero, Vector2.Zero);
|
||||
// Depending whether you have "cruise" mode on (tank controls, higher speed) or "docking" mode on (strafing, lower speed)
|
||||
// inputs will do different things.
|
||||
// TODO: Do that
|
||||
float speedCap;
|
||||
// This is comically fast for debugging
|
||||
var angularSpeed = 20000f;
|
||||
|
||||
// ShuttleSystem has already worked out the ratio so we'll just multiply it back by the mass.
|
||||
var movement = (mover.VelocityDir.walking + mover.VelocityDir.sprinting);
|
||||
|
||||
switch (shuttleComponent.Mode)
|
||||
{
|
||||
case ShuttleMode.Docking:
|
||||
if (movement.Length != 0f)
|
||||
physicsComponent.ApplyLinearImpulse(physicsComponent.Owner.Transform.WorldRotation.RotateVec(movement) * shuttleComponent.SpeedMultipler * physicsComponent.Mass);
|
||||
|
||||
speedCap = _shuttleDockSpeedCap;
|
||||
break;
|
||||
case ShuttleMode.Cruise:
|
||||
if (movement.Length != 0.0f)
|
||||
{
|
||||
// Currently this is slow BUT we'd have a separate multiplier for docking and cruising or whatever.
|
||||
physicsComponent.ApplyLinearImpulse((physicsComponent.Owner.Transform.WorldRotation + new Angle(MathF.PI / 2)).ToVec() *
|
||||
shuttleComponent.SpeedMultipler *
|
||||
physicsComponent.Mass *
|
||||
movement.Y *
|
||||
10);
|
||||
physicsComponent.ApplyAngularImpulse(-movement.X * angularSpeed);
|
||||
}
|
||||
|
||||
// TODO WHEN THIS ACTUALLY WORKS
|
||||
speedCap = _shuttleDockSpeedCap * 10;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
// Look don't my ride ass on this stuff most of the PR was just getting the thing working, we can
|
||||
// ideaguys the shit out of it later.
|
||||
|
||||
var velocity = physicsComponent.LinearVelocity;
|
||||
|
||||
if (velocity.Length < 0.1f && movement.Length == 0f)
|
||||
{
|
||||
physicsComponent.LinearVelocity = Vector2.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
if (velocity.Length > speedCap)
|
||||
{
|
||||
physicsComponent.LinearVelocity = velocity.Normalized * speedCap;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void HandleFootsteps(IMoverComponent mover, IMobMoverComponent mobMover)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Pulling;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Singularity.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -35,7 +35,6 @@ using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.Physics
|
||||
{
|
||||
@@ -51,7 +50,7 @@ namespace Content.Server.Physics
|
||||
public class TestbedCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "testbed";
|
||||
public string Description => "Loads a physics testbed and teleports your player there";
|
||||
public string Description => "Loads a physics testbed on the specified map.";
|
||||
public string Help => $"{Command} <mapid> <test>";
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -128,7 +127,10 @@ namespace Content.Server.Physics
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(horizontalFixture);
|
||||
|
||||
var broadphase = EntitySystem.Get<SharedBroadphaseSystem>();
|
||||
|
||||
broadphase.CreateFixture(ground, horizontalFixture);
|
||||
|
||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
||||
var verticalFixture = new Fixture(ground, vertical)
|
||||
@@ -137,7 +139,8 @@ namespace Content.Server.Physics
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(verticalFixture);
|
||||
|
||||
broadphase.CreateFixture(ground, verticalFixture);
|
||||
|
||||
var xs = new[]
|
||||
{
|
||||
@@ -158,7 +161,6 @@ namespace Content.Server.Physics
|
||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
box.BodyType = BodyType.Dynamic;
|
||||
box.SleepingAllowed = false;
|
||||
shape = new PolygonShape();
|
||||
shape.SetAsBox(0.5f, 0.5f);
|
||||
box.FixedRotation = false;
|
||||
@@ -170,7 +172,8 @@ namespace Content.Server.Physics
|
||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
||||
Hard = true,
|
||||
};
|
||||
box.AddFixture(fixture);
|
||||
|
||||
broadphase.CreateFixture(box, fixture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +191,9 @@ namespace Content.Server.Physics
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(horizontalFixture);
|
||||
|
||||
var broadphase = EntitySystem.Get<SharedBroadphaseSystem>();
|
||||
broadphase.CreateFixture(ground, horizontalFixture);
|
||||
|
||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
||||
var verticalFixture = new Fixture(ground, vertical)
|
||||
@@ -197,7 +202,8 @@ namespace Content.Server.Physics
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true
|
||||
};
|
||||
ground.AddFixture(verticalFixture);
|
||||
|
||||
broadphase.CreateFixture(ground, verticalFixture);
|
||||
|
||||
var xs = new[]
|
||||
{
|
||||
@@ -218,7 +224,6 @@ namespace Content.Server.Physics
|
||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
||||
|
||||
box.BodyType = BodyType.Dynamic;
|
||||
box.SleepingAllowed = false;
|
||||
shape = new PhysShapeCircle {Radius = 0.5f};
|
||||
box.FixedRotation = false;
|
||||
// TODO: Need to detect shape and work out if we need to use fixedrotation
|
||||
@@ -229,7 +234,8 @@ namespace Content.Server.Physics
|
||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
||||
Hard = true,
|
||||
};
|
||||
box.AddFixture(fixture);
|
||||
|
||||
broadphase.CreateFixture(box, fixture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +256,8 @@ namespace Content.Server.Physics
|
||||
Hard = true
|
||||
};
|
||||
|
||||
ground.AddFixture(horizontalFixture);
|
||||
var broadphase = EntitySystem.Get<SharedBroadphaseSystem>();
|
||||
broadphase.CreateFixture(ground, horizontalFixture);
|
||||
|
||||
// Setup boxes
|
||||
float a = 0.5f;
|
||||
@@ -271,13 +278,13 @@ namespace Content.Server.Physics
|
||||
var box = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
|
||||
box.BodyType = BodyType.Dynamic;
|
||||
box.Owner.Transform.WorldPosition = y;
|
||||
box.AddFixture(
|
||||
broadphase.CreateFixture(box,
|
||||
new Fixture(box, shape) {
|
||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true,
|
||||
Mass = 5.0f,
|
||||
});
|
||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
||||
CollisionMask = (int) CollisionGroup.Impassable,
|
||||
Hard = true,
|
||||
Mass = 5.0f,
|
||||
});
|
||||
y += deltaY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user