Content update for ECS physics (#13291)
This commit is contained in:
@@ -30,15 +30,16 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
foreach (var comp in _activePressures)
|
||||
{
|
||||
var uid = comp.Owner;
|
||||
MetaDataComponent? metadata = null;
|
||||
|
||||
if (Deleted(comp.Owner, metadata))
|
||||
if (Deleted(uid, metadata))
|
||||
{
|
||||
toRemove.Add(comp);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Paused(comp.Owner, metadata)) continue;
|
||||
if (Paused(uid, metadata)) continue;
|
||||
|
||||
comp.Accumulator += frameTime;
|
||||
|
||||
@@ -48,17 +49,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
comp.Accumulator = 0f;
|
||||
toRemove.Add(comp);
|
||||
|
||||
if (HasComp<MobStateComponent>(comp.Owner) &&
|
||||
TryComp<PhysicsComponent>(comp.Owner, out var body))
|
||||
if (HasComp<MobStateComponent>(uid) &&
|
||||
TryComp<PhysicsComponent>(uid, out var body))
|
||||
{
|
||||
body.BodyStatus = BodyStatus.OnGround;
|
||||
_physics.SetBodyStatus(body, BodyStatus.OnGround);
|
||||
}
|
||||
|
||||
if (TryComp<FixturesComponent>(comp.Owner, out var fixtures))
|
||||
if (TryComp<FixturesComponent>(uid, out var fixtures))
|
||||
{
|
||||
foreach (var (_, fixture) in fixtures.Fixtures)
|
||||
foreach (var fixture in fixtures.Fixtures.Values)
|
||||
{
|
||||
_physics.AddCollisionMask(fixtures, fixture, (int) CollisionGroup.TableLayer);
|
||||
_physics.AddCollisionMask(uid, fixture, (int) CollisionGroup.TableLayer, manager: fixtures);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,11 +74,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
if (!TryComp<FixturesComponent>(component.Owner, out var fixtures)) return;
|
||||
|
||||
body.BodyStatus = BodyStatus.InAir;
|
||||
_physics.SetBodyStatus(body, BodyStatus.InAir);
|
||||
|
||||
foreach (var fixture in fixtures.Fixtures.Values)
|
||||
{
|
||||
_physics.RemoveCollisionMask(fixtures, fixture, (int) CollisionGroup.TableLayer);
|
||||
_physics.RemoveCollisionMask(body.Owner, fixture, (int) CollisionGroup.TableLayer, manager: fixtures);
|
||||
}
|
||||
|
||||
// TODO: Make them dynamic type? Ehh but they still want movement so uhh make it non-predicted like weightless?
|
||||
@@ -188,10 +189,12 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
TransformComponent? xform = null,
|
||||
PhysicsComponent? physics = null)
|
||||
{
|
||||
if (!Resolve(component.Owner, ref physics, false))
|
||||
var uid = component.Owner;
|
||||
|
||||
if (!Resolve(uid, ref physics, false))
|
||||
return;
|
||||
|
||||
if (!Resolve(component.Owner, ref xform)) return;
|
||||
if (!Resolve(uid, ref xform)) return;
|
||||
|
||||
// TODO ATMOS stuns?
|
||||
|
||||
@@ -209,7 +212,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
&& (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForcePushRatio)))
|
||||
|| (physics.BodyType == BodyType.Static && (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForceForcePushRatio))))
|
||||
{
|
||||
if (HasComp<MobStateComponent>(physics.Owner))
|
||||
if (HasComp<MobStateComponent>(uid))
|
||||
{
|
||||
AddMobMovedByPressure(component, physics);
|
||||
}
|
||||
@@ -231,13 +234,12 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if (throwTarget != EntityCoordinates.Invalid)
|
||||
{
|
||||
var pos = ((throwTarget.ToMap(EntityManager).Position - xform.WorldPosition).Normalized + dirVec).Normalized;
|
||||
physics.ApplyLinearImpulse(pos * moveForce);
|
||||
_physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
moveForce = MathF.Min(moveForce, SpaceWindMaxPushForce);
|
||||
physics.ApplyLinearImpulse(dirVec * moveForce);
|
||||
_physics.ApplyLinearImpulse(uid, dirVec * moveForce, body: physics);
|
||||
}
|
||||
|
||||
component.LastHighPressureMovementAirCycle = cycle;
|
||||
|
||||
@@ -484,8 +484,8 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var gridPhysics = Comp<PhysicsComponent>(mapGrid.Owner);
|
||||
|
||||
// TODO ATMOS: Come up with better values for these.
|
||||
gridPhysics.ApplyLinearImpulse(direction * totalMolesRemoved * gridPhysics.Mass);
|
||||
gridPhysics.ApplyAngularImpulse(Vector2.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalMolesRemoved);
|
||||
_physics.ApplyLinearImpulse(mapGrid.Owner, direction * totalMolesRemoved * gridPhysics.Mass, body: gridPhysics);
|
||||
_physics.ApplyAngularImpulse(mapGrid.Owner, Vector2.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalMolesRemoved, body: gridPhysics);
|
||||
}
|
||||
|
||||
if(tileCount > 10 && (totalMolesRemoved / tileCount) > 20)
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly FixtureSystem _fixture = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
public const float MinimumFireStacks = -10f;
|
||||
@@ -92,12 +93,8 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body))
|
||||
return;
|
||||
|
||||
_fixture.TryCreateFixture(body, new Fixture(body, component.FlammableCollisionShape)
|
||||
{
|
||||
Hard = false,
|
||||
ID = FlammableFixtureID,
|
||||
CollisionMask = (int) CollisionGroup.FullTileLayer
|
||||
});
|
||||
_fixture.TryCreateFixture(uid, component.FlammableCollisionShape, FlammableFixtureID, hard: false,
|
||||
collisionMask: (int) CollisionGroup.FullTileLayer, body: body);
|
||||
}
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
|
||||
@@ -274,7 +271,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
_timer -= UpdateTime;
|
||||
|
||||
// TODO: This needs cleanup to take off the crust from TemperatureComponent and shit.
|
||||
foreach (var (flammable, physics, transform) in EntityManager.EntityQuery<FlammableComponent, PhysicsComponent, TransformComponent>())
|
||||
foreach (var (flammable, transform) in EntityManager.EntityQuery<FlammableComponent, TransformComponent>())
|
||||
{
|
||||
var uid = flammable.Owner;
|
||||
|
||||
@@ -327,20 +324,21 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
}
|
||||
|
||||
foreach (var otherUid in flammable.Collided.ToArray())
|
||||
for (var i = flammable.Collided.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var otherUid = flammable.Collided[i];
|
||||
|
||||
if (!otherUid.IsValid() || !EntityManager.EntityExists(otherUid))
|
||||
{
|
||||
flammable.Collided.Remove(otherUid);
|
||||
flammable.Collided.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var otherPhysics = EntityManager.GetComponent<PhysicsComponent>(uid);
|
||||
|
||||
// TODO: Sloth, please save our souls!
|
||||
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
|
||||
// no
|
||||
if (!_lookup.GetWorldAABB(uid, transform).Intersects(_lookup.GetWorldAABB(otherUid)))
|
||||
{
|
||||
flammable.Collided.Remove(otherUid);
|
||||
flammable.Collided.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user