Update content for PhysicsMapComponent (#4462)
* Update content for PhysicsMapComponent * Fix command * Cache broadphasesystem
This commit is contained in:
@@ -113,9 +113,10 @@ namespace Content.Server.Physics
|
|||||||
|
|
||||||
private void SetupPlayer(MapId mapId, IConsoleShell shell, IPlayerSession? player, IMapManager mapManager)
|
private void SetupPlayer(MapId mapId, IConsoleShell shell, IPlayerSession? player, IMapManager mapManager)
|
||||||
{
|
{
|
||||||
|
if (mapId == MapId.Nullspace) return;
|
||||||
var pauseManager = IoCManager.Resolve<IPauseManager>();
|
var pauseManager = IoCManager.Resolve<IPauseManager>();
|
||||||
pauseManager.SetMapPaused(mapId, false);
|
pauseManager.SetMapPaused(mapId, false);
|
||||||
var map = EntitySystem.Get<SharedPhysicsSystem>().Maps[mapId].Gravity = new Vector2(0, -4.9f);
|
IoCManager.Resolve<IMapManager>().GetMapEntity(mapId).GetComponent<SharedPhysicsMapComponent>().Gravity = new Vector2(0, -4.9f);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -353,9 +354,7 @@ namespace Content.Server.Physics
|
|||||||
// Box2D has this as 800 which is jesus christo.
|
// Box2D has this as 800 which is jesus christo.
|
||||||
// Wouldn't recommend higher than 100 in debug and higher than 300 on release unless
|
// Wouldn't recommend higher than 100 in debug and higher than 300 on release unless
|
||||||
// you really want a profile.
|
// you really want a profile.
|
||||||
var count = 50;
|
var count = 200;
|
||||||
|
|
||||||
EntitySystem.Get<SharedPhysicsSystem>().Maps[mapId].Gravity = new Vector2(0f, -9.8f);
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ namespace Content.Shared.Friction
|
|||||||
configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
|
configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateBeforeMapSolve(bool prediction, PhysicsMap map, float frameTime)
|
public override void UpdateBeforeMapSolve(bool prediction, SharedPhysicsMapComponent mapComponent, float frameTime)
|
||||||
{
|
{
|
||||||
base.UpdateBeforeMapSolve(prediction, map, frameTime);
|
base.UpdateBeforeMapSolve(prediction, mapComponent, frameTime);
|
||||||
|
|
||||||
foreach (var body in map.AwakeBodies)
|
foreach (var body in mapComponent.AwakeBodies)
|
||||||
{
|
{
|
||||||
// Only apply friction when it's not a mob (or the mob doesn't have control)
|
// Only apply friction when it's not a mob (or the mob doesn't have control)
|
||||||
if (body.Deleted ||
|
if (body.Deleted ||
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Linq;
|
|||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
@@ -14,6 +15,8 @@ namespace Content.Shared.Throwing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ThrownItemSystem : EntitySystem
|
public class ThrownItemSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedBroadphaseSystem _broadphaseSystem = default!;
|
||||||
|
|
||||||
private const string ThrowingFixture = "throw-fixture";
|
private const string ThrowingFixture = "throw-fixture";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -37,7 +40,7 @@ namespace Content.Shared.Throwing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Get<SharedBroadphaseSystem>().DestroyFixture(physicsComponent, fixture);
|
_broadphaseSystem.DestroyFixture(physicsComponent, fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
||||||
@@ -52,7 +55,7 @@ namespace Content.Shared.Throwing
|
|||||||
}
|
}
|
||||||
|
|
||||||
var shape = physicsComponent.Fixtures[0].Shape;
|
var shape = physicsComponent.Fixtures[0].Shape;
|
||||||
Get<SharedBroadphaseSystem>().CreateFixture(physicsComponent, new Fixture(physicsComponent, shape) {CollisionLayer = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture});
|
_broadphaseSystem.CreateFixture(physicsComponent, new Fixture(physicsComponent, shape) {CollisionLayer = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCollision(EntityUid uid, ThrownItemComponent component, StartCollideEvent args)
|
private void HandleCollision(EntityUid uid, ThrownItemComponent component, StartCollideEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user