Content update for ECS physics (#13291)
This commit is contained in:
@@ -186,14 +186,12 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
|
||||
if (TryComp<PhysicsComponent>(user, out var physicsComponent))
|
||||
{
|
||||
var fixture = new Fixture(physicsComponent, component.Shape)
|
||||
{
|
||||
ID = BlockingComponent.BlockFixtureID,
|
||||
Hard = true,
|
||||
CollisionLayer = (int) CollisionGroup.WallLayer
|
||||
};
|
||||
|
||||
_fixtureSystem.TryCreateFixture(physicsComponent, fixture);
|
||||
_fixtureSystem.TryCreateFixture(user,
|
||||
component.Shape,
|
||||
BlockingComponent.BlockFixtureID,
|
||||
hard: true,
|
||||
collisionLayer: (int) CollisionGroup.WallLayer,
|
||||
body: physicsComponent);
|
||||
}
|
||||
|
||||
component.IsBlocking = true;
|
||||
@@ -243,8 +241,8 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
_transformSystem.Unanchor(xform);
|
||||
|
||||
_actionsSystem.SetToggled(component.BlockingToggleAction, false);
|
||||
_fixtureSystem.DestroyFixture(physicsComponent, BlockingComponent.BlockFixtureID);
|
||||
_physics.SetBodyType(physicsComponent, blockingUserComponent.OriginalBodyType);
|
||||
_fixtureSystem.DestroyFixture(user, BlockingComponent.BlockFixtureID, body: physicsComponent);
|
||||
_physics.SetBodyType(user, blockingUserComponent.OriginalBodyType, body: physicsComponent);
|
||||
_popupSystem.PopupEntity(msgUser, user, user);
|
||||
_popupSystem.PopupEntity(msgOther, user, Filter.PvsExcept(user), true);
|
||||
}
|
||||
|
||||
@@ -31,9 +31,8 @@ public sealed class BlockingComponent : Component
|
||||
/// <summary>
|
||||
/// The shape of the blocking fixture that will be dynamically spawned
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("shape")]
|
||||
public IPhysShape Shape = new PhysShapeCircle {Radius = 0.5F};
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("shape")]
|
||||
public IPhysShape Shape = new PhysShapeCircle(0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// The damage modifer to use while passively blocking
|
||||
|
||||
@@ -381,7 +381,10 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
#endregion
|
||||
|
||||
#region Collisions
|
||||
protected virtual void SetCollidable(EntityUid uid, bool collidable,
|
||||
|
||||
protected virtual void SetCollidable(
|
||||
EntityUid uid,
|
||||
bool collidable,
|
||||
DoorComponent? door = null,
|
||||
PhysicsComponent? physics = null,
|
||||
OccluderComponent? occluder = null)
|
||||
@@ -390,13 +393,13 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
return;
|
||||
|
||||
if (Resolve(uid, ref physics, false))
|
||||
PhysicsSystem.SetCanCollide(physics, collidable);
|
||||
PhysicsSystem.SetCanCollide(uid, collidable, body: physics);
|
||||
|
||||
if (!collidable)
|
||||
door.CurrentlyCrushing.Clear();
|
||||
|
||||
if (door.Occludes)
|
||||
_occluder.SetEnabled(uid, collidable);
|
||||
_occluder.SetEnabled(uid, collidable, occluder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Explosion;
|
||||
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedTriggerOnProximityComponent : Component
|
||||
{
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ namespace Content.Shared.Friction
|
||||
|
||||
foreach (var body in mapComponent.AwakeBodies)
|
||||
{
|
||||
var uid = body.Owner;
|
||||
|
||||
// Only apply friction when it's not a mob (or the mob doesn't have control)
|
||||
if (prediction && !body.Predict ||
|
||||
body.BodyStatus == BodyStatus.InAir ||
|
||||
@@ -86,46 +88,45 @@ namespace Content.Shared.Friction
|
||||
continue;
|
||||
}
|
||||
|
||||
if (body.LinearVelocity.Equals(Vector2.Zero) && body.AngularVelocity.Equals(0f)) continue;
|
||||
if (body.LinearVelocity.Equals(Vector2.Zero) && body.AngularVelocity.Equals(0f))
|
||||
continue;
|
||||
|
||||
DebugTools.Assert(!Deleted(body.Owner));
|
||||
|
||||
if (!xformQuery.TryGetComponent(body.Owner, out var xform))
|
||||
if (!xformQuery.TryGetComponent(uid, out var xform))
|
||||
{
|
||||
Logger.ErrorS("physics", $"Unable to get transform for {ToPrettyString(body.Owner)} in tilefrictioncontroller");
|
||||
continue;
|
||||
}
|
||||
|
||||
var surfaceFriction = GetTileFriction(body, xform);
|
||||
var surfaceFriction = GetTileFriction(uid, body, xform);
|
||||
var bodyModifier = 1f;
|
||||
|
||||
if (frictionQuery.TryGetComponent(body.Owner, out var frictionComp))
|
||||
if (frictionQuery.TryGetComponent(uid, out var frictionComp))
|
||||
{
|
||||
bodyModifier = frictionComp.Modifier;
|
||||
}
|
||||
|
||||
var ev = new TileFrictionEvent(bodyModifier);
|
||||
|
||||
RaiseLocalEvent(body.Owner, ref ev);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
bodyModifier = ev.Modifier;
|
||||
|
||||
// If we're sandwiched between 2 pullers reduce friction
|
||||
// Might be better to make this dynamic and check how many are in the pull chain?
|
||||
// Either way should be much faster for now.
|
||||
if (pullerQuery.TryGetComponent(body.Owner, out var puller) && puller.Pulling != null &&
|
||||
pullableQuery.TryGetComponent(body.Owner, out var pullable) && pullable.BeingPulled)
|
||||
if (pullerQuery.TryGetComponent(uid, out var puller) && puller.Pulling != null &&
|
||||
pullableQuery.TryGetComponent(uid, out var pullable) && pullable.BeingPulled)
|
||||
{
|
||||
bodyModifier *= 0.2f;
|
||||
}
|
||||
|
||||
var friction = _frictionModifier * surfaceFriction * bodyModifier;
|
||||
|
||||
ReduceLinearVelocity(prediction, body, friction, frameTime);
|
||||
ReduceAngularVelocity(prediction, body, friction, frameTime);
|
||||
ReduceLinearVelocity(uid, prediction, body, friction, frameTime);
|
||||
ReduceAngularVelocity(uid, prediction, body, friction, frameTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReduceLinearVelocity(bool prediction, PhysicsComponent body, float friction, float frameTime)
|
||||
private void ReduceLinearVelocity(EntityUid uid, bool prediction, PhysicsComponent body, float friction, float frameTime)
|
||||
{
|
||||
var speed = body.LinearVelocity.Length;
|
||||
|
||||
@@ -153,10 +154,10 @@ namespace Content.Shared.Friction
|
||||
var newSpeed = MathF.Max(0.0f, speed - drop);
|
||||
|
||||
newSpeed /= speed;
|
||||
_physics.SetLinearVelocity(body, body.LinearVelocity * newSpeed);
|
||||
_physics.SetLinearVelocity(uid, body.LinearVelocity * newSpeed, body: body);
|
||||
}
|
||||
|
||||
private void ReduceAngularVelocity(bool prediction, PhysicsComponent body, float friction, float frameTime)
|
||||
private void ReduceAngularVelocity(EntityUid uid, bool prediction, PhysicsComponent body, float friction, float frameTime)
|
||||
{
|
||||
var speed = MathF.Abs(body.AngularVelocity);
|
||||
|
||||
@@ -184,14 +185,14 @@ namespace Content.Shared.Friction
|
||||
var newSpeed = MathF.Max(0.0f, speed - drop);
|
||||
|
||||
newSpeed /= speed;
|
||||
_physics.SetAngularVelocity(body, body.AngularVelocity * newSpeed);
|
||||
_physics.SetAngularVelocity(uid, body.AngularVelocity * newSpeed, body: body);
|
||||
}
|
||||
|
||||
[Pure]
|
||||
private float GetTileFriction(PhysicsComponent body, TransformComponent xform)
|
||||
private float GetTileFriction(EntityUid uid, PhysicsComponent body, TransformComponent xform)
|
||||
{
|
||||
// TODO: Make IsWeightless event-based; we already have grid traversals tracked so just raise events
|
||||
if (_gravity.IsWeightless(body.Owner, body, xform))
|
||||
if (_gravity.IsWeightless(uid, body, xform))
|
||||
return 0.0f;
|
||||
|
||||
if (!xform.Coordinates.IsValid(EntityManager)) return 0.0f;
|
||||
@@ -201,7 +202,8 @@ namespace Content.Shared.Friction
|
||||
var tile = grid.GetTileRef(xform.Coordinates);
|
||||
|
||||
// If it's a map but on an empty tile then just assume it has gravity.
|
||||
if (tile.Tile.IsEmpty && HasComp<MapComponent>(xform.GridUid) &&
|
||||
if (tile.Tile.IsEmpty &&
|
||||
HasComp<MapComponent>(xform.GridUid) &&
|
||||
(!TryComp<GravityComponent>(xform.GridUid, out var gravity) || gravity.Enabled))
|
||||
{
|
||||
return DefaultFriction;
|
||||
|
||||
@@ -42,21 +42,20 @@ public partial class MobStateSystem
|
||||
|
||||
private void OnStateExitSubscribers(EntityUid target, MobStateComponent component, MobState state)
|
||||
{
|
||||
var uid = component.Owner;
|
||||
switch (state)
|
||||
{
|
||||
case MobState.Alive:
|
||||
//unused
|
||||
break;
|
||||
case MobState.Critical:
|
||||
_standing.Stand(uid);
|
||||
_standing.Stand(target);
|
||||
break;
|
||||
case MobState.Dead:
|
||||
RemComp<CollisionWakeComponent>(uid);
|
||||
_standing.Stand(uid);
|
||||
if (!_standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
|
||||
RemComp<CollisionWakeComponent>(target);
|
||||
_standing.Stand(target);
|
||||
if (!_standing.IsDown(target) && TryComp<PhysicsComponent>(target, out var physics))
|
||||
{
|
||||
_physics.SetCanCollide(physics, true);
|
||||
_physics.SetCanCollide(target, true, body: physics);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -70,28 +69,27 @@ public partial class MobStateSystem
|
||||
|
||||
private void OnStateEnteredSubscribers(EntityUid target, MobStateComponent component, MobState state)
|
||||
{
|
||||
var uid = component.Owner;
|
||||
_blocker.UpdateCanMove(uid); //update movement anytime a state changes
|
||||
_blocker.UpdateCanMove(target); //update movement anytime a state changes
|
||||
switch (state)
|
||||
{
|
||||
case MobState.Alive:
|
||||
_standing.Stand(uid);
|
||||
_appearance.SetData(uid, MobStateVisuals.State, MobState.Alive);
|
||||
_standing.Stand(target);
|
||||
_appearance.SetData(target, MobStateVisuals.State, MobState.Alive);
|
||||
break;
|
||||
case MobState.Critical:
|
||||
_standing.Down(uid);
|
||||
_appearance.SetData(uid, MobStateVisuals.State, MobState.Critical);
|
||||
_standing.Down(target);
|
||||
_appearance.SetData(target, MobStateVisuals.State, MobState.Critical);
|
||||
break;
|
||||
case MobState.Dead:
|
||||
EnsureComp<CollisionWakeComponent>(uid);
|
||||
_standing.Down(uid);
|
||||
EnsureComp<CollisionWakeComponent>(target);
|
||||
_standing.Down(target);
|
||||
|
||||
if (_standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
|
||||
if (_standing.IsDown(target) && TryComp<PhysicsComponent>(target, out var physics))
|
||||
{
|
||||
_physics.SetCanCollide(physics, false);
|
||||
_physics.SetCanCollide(target, false, body: physics);
|
||||
}
|
||||
|
||||
_appearance.SetData(uid, MobStateVisuals.State, MobState.Dead);
|
||||
_appearance.SetData(target, MobStateVisuals.State, MobState.Dead);
|
||||
break;
|
||||
case MobState.Invalid:
|
||||
//unused;
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Content.Shared.Movement.Systems
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
@@ -304,10 +305,10 @@ namespace Content.Shared.Movement.Systems
|
||||
if (!weightless || touching)
|
||||
Accelerate(ref velocity, in worldTotal, accel, frameTime);
|
||||
|
||||
PhysicsSystem.SetLinearVelocity(physicsComponent, velocity);
|
||||
PhysicsSystem.SetLinearVelocity(physicsComponent.Owner, velocity, body: physicsComponent);
|
||||
|
||||
// Ensures that players do not spiiiiiiin
|
||||
PhysicsSystem.SetAngularVelocity(physicsComponent, 0);
|
||||
PhysicsSystem.SetAngularVelocity(physicsComponent.Owner, 0, body: physicsComponent);
|
||||
}
|
||||
|
||||
private void Friction(float minimumFrictionSpeed, float frameTime, float friction, ref Vector2 velocity)
|
||||
@@ -364,7 +365,7 @@ namespace Content.Shared.Movement.Systems
|
||||
/// </summary>
|
||||
private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, MobMoverComponent mover, PhysicsComponent collider)
|
||||
{
|
||||
var enlargedAABB = collider.GetWorldAABB().Enlarged(mover.GrabRangeVV);
|
||||
var enlargedAABB = _lookup.GetWorldAABB(collider.Owner, transform).Enlarged(mover.GrabRangeVV);
|
||||
|
||||
foreach (var otherCollider in broadPhaseSystem.GetCollidingEntities(transform.MapID, enlargedAABB))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Content.Shared.Physics.Pull
|
||||
{
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Content.Shared.Pulling
|
||||
if (!_timing.ApplyingState)
|
||||
{
|
||||
// Joint startup
|
||||
var union = _physics.GetHardAABB(pullerPhysics).Union(_physics.GetHardAABB(pullablePhysics));
|
||||
var union = _physics.GetHardAABB(puller.Owner).Union(_physics.GetHardAABB(pullable.Owner, body: pullablePhysics));
|
||||
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
||||
|
||||
var joint = _jointSystem.CreateDistanceJoint(pullablePhysics.Owner, pullerPhysics.Owner, id: pullable.PullJointId);
|
||||
|
||||
@@ -11,15 +11,17 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.Shared.Pulling
|
||||
{
|
||||
public abstract partial class SharedPullingSystem : EntitySystem
|
||||
public abstract partial class SharedPullingSystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
public bool CanPull(EntityUid puller, EntityUid pulled)
|
||||
@@ -102,7 +104,7 @@ namespace Content.Shared.Pulling
|
||||
|
||||
if (TryComp<PhysicsComponent>(pullable.Owner, out var pullablePhysics))
|
||||
{
|
||||
pullablePhysics.FixedRotation = pullable.PrevFixedRotation;
|
||||
_physics.SetFixedRotation(pullable.Owner, pullable.PrevFixedRotation, body: pullablePhysics);
|
||||
}
|
||||
|
||||
_pullSm.ForceRelationship(null, pullable);
|
||||
@@ -198,7 +200,7 @@ namespace Content.Shared.Pulling
|
||||
|
||||
_pullSm.ForceRelationship(puller, pullable);
|
||||
pullable.PrevFixedRotation = pullablePhysics.FixedRotation;
|
||||
pullablePhysics.FixedRotation = pullable.FixedRotationOnPull;
|
||||
_physics.SetFixedRotation(pullable.Owner, pullable.FixedRotationOnPull, body: pullablePhysics);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low,
|
||||
$"{ToPrettyString(puller.Owner):user} started pulling {ToPrettyString(pullable.Owner):target}");
|
||||
return true;
|
||||
|
||||
@@ -40,8 +40,8 @@ public abstract class SharedCorporealSystem : EntitySystem
|
||||
{
|
||||
var fixture = fixtures.Fixtures.Values.First();
|
||||
|
||||
_physics.SetCollisionMask(fixture, (int) (CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable));
|
||||
_physics.SetCollisionLayer(fixture, (int) CollisionGroup.SmallMobLayer);
|
||||
_physics.SetCollisionMask(uid, fixture, (int) (CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable), fixtures);
|
||||
_physics.SetCollisionLayer(uid, fixture, (int) CollisionGroup.SmallMobLayer, fixtures);
|
||||
}
|
||||
_movement.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
@@ -54,8 +54,8 @@ public abstract class SharedCorporealSystem : EntitySystem
|
||||
{
|
||||
var fixture = fixtures.Fixtures.Values.First();
|
||||
|
||||
_physics.SetCollisionMask(fixture, (int) CollisionGroup.GhostImpassable);
|
||||
_physics.SetCollisionLayer(fixture, 0);
|
||||
_physics.SetCollisionMask(uid, fixture, (int) CollisionGroup.GhostImpassable, fixtures);
|
||||
_physics.SetCollisionLayer(uid, fixture, 0, fixtures);
|
||||
}
|
||||
component.MovementSpeedDebuff = 1; //just so we can avoid annoying code elsewhere
|
||||
_movement.RefreshMovementSpeedModifiers(uid);
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.Physics.Systems;
|
||||
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Shared.Singularity.EntitySystems;
|
||||
|
||||
@@ -14,10 +15,11 @@ namespace Content.Shared.Singularity.EntitySystems;
|
||||
/// </summary>
|
||||
public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] protected readonly IViewVariablesManager Vvm = default!;
|
||||
#endregion Dependencies
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -62,7 +64,7 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
return;
|
||||
|
||||
eventHorizon.Radius = value;
|
||||
EntityManager.Dirty(eventHorizon);
|
||||
Dirty(eventHorizon);
|
||||
if (updateFixture)
|
||||
UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon);
|
||||
}
|
||||
@@ -85,7 +87,7 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
return;
|
||||
|
||||
eventHorizon.CanBreachContainment = value;
|
||||
EntityManager.Dirty(eventHorizon);
|
||||
Dirty(eventHorizon);
|
||||
if (updateFixture)
|
||||
UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon);
|
||||
}
|
||||
@@ -108,7 +110,7 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
return;
|
||||
|
||||
eventHorizon.HorizonFixtureId = value;
|
||||
EntityManager.Dirty(eventHorizon);
|
||||
Dirty(eventHorizon);
|
||||
if (updateFixture)
|
||||
UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon);
|
||||
}
|
||||
@@ -117,25 +119,26 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
/// Updates the state of the fixture associated with the event horizon.
|
||||
/// </summary>
|
||||
/// <param name="eventHorizon">The uid of the event horizon associated with the fixture to update.</param>
|
||||
/// <param name="fixtures">The physics component containing the fixture to update.</param>
|
||||
/// <param name="physics">The physics component containing the fixture to update.</param>
|
||||
/// <param name="eventHorizon">The state of the event horizon associated with the fixture to update.</param>
|
||||
public void UpdateEventHorizonFixture(EntityUid uid, PhysicsComponent? fixtures = null, EventHorizonComponent? eventHorizon = null)
|
||||
public void UpdateEventHorizonFixture(EntityUid uid, PhysicsComponent? physics = null, EventHorizonComponent? eventHorizon = null)
|
||||
{
|
||||
if(!Resolve(uid, ref eventHorizon))
|
||||
return;
|
||||
|
||||
var fixtureId = eventHorizon.HorizonFixtureId;
|
||||
if (fixtureId == null || !Resolve(eventHorizon.Owner, ref fixtures, logMissing: false))
|
||||
FixturesComponent? manager = null;
|
||||
|
||||
if (fixtureId == null || !Resolve(uid, ref manager, ref physics, logMissing: false))
|
||||
return;
|
||||
|
||||
var fixture = _fixtures.GetFixtureOrNull(fixtures, fixtureId);
|
||||
var fixture = _fixtures.GetFixtureOrNull(uid, fixtureId, manager);
|
||||
if (fixture == null)
|
||||
return;
|
||||
|
||||
var shape = (PhysShapeCircle)fixture.Shape;
|
||||
shape.Radius = eventHorizon.Radius;
|
||||
fixture.Hard = !eventHorizon.CanBreachContainment;
|
||||
EntityManager.Dirty(fixtures);
|
||||
_physics.SetRadius(uid, fixture, shape, eventHorizon.Radius, manager: manager, body: physics);
|
||||
_physics.SetHard(uid, fixture, true, manager);
|
||||
}
|
||||
|
||||
#endregion Getters/Setters
|
||||
@@ -181,8 +184,8 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
var otherUid = args.BodyB.Owner;
|
||||
|
||||
// For prediction reasons always want the client to ignore these.
|
||||
if (EntityManager.HasComponent<MapGridComponent>(otherUid) ||
|
||||
EntityManager.HasComponent<SharedGhostComponent>(otherUid))
|
||||
if (HasComp<MapGridComponent>(otherUid) ||
|
||||
HasComp<SharedGhostComponent>(otherUid))
|
||||
{
|
||||
args.Cancelled = true;
|
||||
return true;
|
||||
@@ -190,8 +193,8 @@ public abstract class SharedEventHorizonSystem : EntitySystem
|
||||
|
||||
// If we can, breach containment
|
||||
// otherwise, check if it's containment and just keep the collision
|
||||
if (EntityManager.HasComponent<ContainmentFieldComponent>(otherUid) ||
|
||||
EntityManager.HasComponent<ContainmentFieldGeneratorComponent>(otherUid))
|
||||
if (HasComp<ContainmentFieldComponent>(otherUid) ||
|
||||
HasComp<ContainmentFieldGeneratorComponent>(otherUid))
|
||||
{
|
||||
if (comp.CanBreachContainment)
|
||||
args.Cancelled = true;
|
||||
|
||||
@@ -355,7 +355,7 @@ public abstract class SharedSingularitySystem : EntitySystem
|
||||
{
|
||||
_physics.SetBodyStatus(comp, (args.NewValue > 1) ? BodyStatus.InAir : BodyStatus.OnGround);
|
||||
if (args.NewValue <= 1 && args.OldValue > 1) // Apparently keeps singularities from getting stuck in the corners of containment fields.
|
||||
_physics.SetLinearVelocity(comp, Vector2.Zero); // No idea how stopping the singularities movement keeps it from getting stuck though.
|
||||
_physics.SetLinearVelocity(uid, Vector2.Zero, body: comp); // No idea how stopping the singularities movement keeps it from getting stuck though.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Content.Shared.Slippery
|
||||
return;
|
||||
|
||||
if (TryComp(other, out PhysicsComponent? physics))
|
||||
_physics.SetLinearVelocity(physics, physics.LinearVelocity * component.LaunchForwardsMultiplier);
|
||||
_physics.SetLinearVelocity(other, physics.LinearVelocity * component.LaunchForwardsMultiplier, body: physics);
|
||||
|
||||
var playSound = !_statusEffectsSystem.HasStatusEffect(other, "KnockedDown");
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Content.Shared.Standing
|
||||
continue;
|
||||
|
||||
standingState.ChangedFixtures.Add(key);
|
||||
_physics.SetCollisionMask(fixture, fixture.CollisionMask & ~StandingCollisionLayer);
|
||||
_physics.SetCollisionMask(uid, fixture, fixture.CollisionMask & ~StandingCollisionLayer, manager: fixtureComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Content.Shared.Standing
|
||||
foreach (var key in standingState.ChangedFixtures)
|
||||
{
|
||||
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture))
|
||||
_physics.SetCollisionMask(fixture, fixture.CollisionMask | StandingCollisionLayer);
|
||||
_physics.SetCollisionMask(uid, fixture, fixture.CollisionMask | StandingCollisionLayer, fixtureComponent);
|
||||
}
|
||||
}
|
||||
standingState.ChangedFixtures.Clear();
|
||||
|
||||
@@ -60,7 +60,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
comp.Thrower = user;
|
||||
// Give it a l'il spin.
|
||||
if (!_tagSystem.HasTag(uid, "NoSpinOnThrow"))
|
||||
_physics.ApplyAngularImpulse(physics, ThrowAngularImpulse);
|
||||
_physics.ApplyAngularImpulse(uid, ThrowAngularImpulse, body: physics);
|
||||
else
|
||||
{
|
||||
if (transform == null)
|
||||
@@ -75,7 +75,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
_interactionSystem.ThrownInteraction(user.Value, uid);
|
||||
|
||||
var impulseVector = direction.Normalized * strength * physics.Mass;
|
||||
_physics.ApplyLinearImpulse(physics, impulseVector);
|
||||
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
|
||||
|
||||
// Estimate time to arrival so we can apply OnGround status and slow it much faster.
|
||||
var time = (direction / strength).Length;
|
||||
@@ -109,7 +109,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
RaiseLocalEvent(physics.Owner, msg);
|
||||
|
||||
if (!msg.Cancelled)
|
||||
_physics.ApplyLinearImpulse(userPhysics, -impulseVector * pushbackRatio);
|
||||
_physics.ApplyLinearImpulse(user.Value, -impulseVector * pushbackRatio, body: userPhysics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,16 @@ namespace Content.Shared.Throwing
|
||||
|
||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out FixturesComponent? fixturesComponent) ||
|
||||
fixturesComponent.Fixtures.Count != 1) return;
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) return;
|
||||
|
||||
if (fixturesComponent.Fixtures.ContainsKey(ThrowingFixture))
|
||||
if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
|
||||
fixturesComponent.Fixtures.Count != 1 ||
|
||||
!TryComp<PhysicsComponent>(uid, out var body))
|
||||
{
|
||||
Logger.Error($"Found existing throwing fixture on {component.Owner}");
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = fixturesComponent.Fixtures.Values.First();
|
||||
var shape = fixture.Shape;
|
||||
var throwingFixture = new Fixture(physicsComponent, shape) { CollisionMask = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture };
|
||||
_fixtures.TryCreateFixture(physicsComponent, throwingFixture, manager: fixturesComponent);
|
||||
_fixtures.TryCreateFixture(uid, shape, ThrowingFixture, hard: false, collisionMask: (int) CollisionGroup.ThrownItem, manager: fixturesComponent, body: body);
|
||||
}
|
||||
|
||||
private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref StartCollideEvent args)
|
||||
@@ -104,13 +101,13 @@ namespace Content.Shared.Throwing
|
||||
|
||||
private void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
|
||||
if (EntityManager.TryGetComponent(uid, out FixturesComponent? manager))
|
||||
{
|
||||
var fixture = _fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture);
|
||||
var fixture = _fixtures.GetFixtureOrNull(uid, ThrowingFixture, manager: manager);
|
||||
|
||||
if (fixture != null)
|
||||
{
|
||||
_fixtures.DestroyFixture(physicsComponent, fixture);
|
||||
_fixtures.DestroyFixture(uid, fixture, manager: manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,21 +28,12 @@ public abstract class SharedFlyBySoundSystem : EntitySystem
|
||||
|
||||
private void OnStartup(EntityUid uid, FlyBySoundComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body)) return;
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body))
|
||||
return;
|
||||
|
||||
var shape = new PhysShapeCircle()
|
||||
{
|
||||
Radius = component.Range,
|
||||
};
|
||||
var shape = new PhysShapeCircle(component.Range);
|
||||
|
||||
var fixture = new Fixture(body, shape)
|
||||
{
|
||||
Hard = false,
|
||||
ID = FlyByFixture,
|
||||
CollisionLayer = (int) CollisionGroup.MobMask,
|
||||
};
|
||||
|
||||
_fixtures.TryCreateFixture(body, fixture);
|
||||
_fixtures.TryCreateFixture(uid, shape, FlyByFixture, collisionLayer: (int) CollisionGroup.MobMask, hard: false, body: body);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, FlyBySoundComponent component, ComponentShutdown args)
|
||||
@@ -53,7 +44,7 @@ public abstract class SharedFlyBySoundSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
_fixtures.DestroyFixture(body, FlyByFixture);
|
||||
_fixtures.DestroyFixture(uid, FlyByFixture, body: body);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, FlyBySoundComponent component, ref ComponentHandleState args)
|
||||
|
||||
@@ -383,7 +383,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
|
||||
const float impulseStrength = 85.0f; //The bullet impulse strength, TODO: In the future we might want to make it more projectile dependent
|
||||
var impulseVector = shotDirection * impulseStrength;
|
||||
Physics.ApplyLinearImpulse(userPhysics, -impulseVector);
|
||||
Physics.ApplyLinearImpulse(userPhysics.Owner, -impulseVector, body: userPhysics);
|
||||
}
|
||||
protected abstract void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user