Rework CollisionGroups (#7656)
* Replace Mob, Vault, and Small impassable with Mid, High, Low * Remove CollisionGroup.Underplating * Remove CollisionGroup.Passable * Fix constructed APCs not being interactable * Change firelocks to occlude * Make pipe inherit from BaseItem * Clean up pipes * Remove duplicate physics and fixtures from bucket * Rework CollisionGroups on all entities * Add SlipLayer * Remove fixture from delta * Fix maps * Address reviews * Add SubfloorMask * Fix glass collisions for flying mobs * Fix maps * Update new items * Fix bagel again * Fix slug * Fix maps * Touchups * Fix tables blocking high pressure movement * Update StandingState to allow going under flaps * Cleanup * More formatting
This commit is contained in:
@@ -1,35 +1,62 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Serialization;
|
||||
using RobustPhysics = Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Shared.Physics
|
||||
namespace Content.Shared.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Defined collision groups for the physics system.
|
||||
/// </summary>
|
||||
[Flags, PublicAPI]
|
||||
[FlagsFor(typeof(CollisionLayer)), FlagsFor(typeof(CollisionMask))]
|
||||
public enum CollisionGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Defined collision groups for the physics system.
|
||||
/// </summary>
|
||||
[Flags, PublicAPI]
|
||||
[FlagsFor(typeof(CollisionLayer)), FlagsFor(typeof(CollisionMask))]
|
||||
public enum CollisionGroup
|
||||
{
|
||||
None = 0,
|
||||
Opaque = 1 << 0, // 1 Blocks light, for lasers
|
||||
Impassable = 1 << 1, // 2 Walls, objects impassable by any means
|
||||
MobImpassable = 1 << 2, // 4 Mobs, players, crabs, etc
|
||||
VaultImpassable = 1 << 3, // 8 Things that cannot be jumped over, not half walls or tables
|
||||
SmallImpassable = 1 << 4, // 16 Things a smaller object - a cat, a crab - can't go through - a wall, but not a computer terminal or a table
|
||||
GhostImpassable = 1 << 5, // 32 Things impassible by ghosts/observers, ie blessed tiles or forcefields
|
||||
Underplating = 1 << 6, // 64 Things that are under plating
|
||||
[Obsolete("Don't use Passable for collision.")]
|
||||
// Collision is for what things collide, not what they "don't collide with" so this makes 0 logical sense.
|
||||
Passable = 1 << 7, // 128 Things that are passable.
|
||||
MapGrid = MapGridHelpers.CollisionGroup, // Map grids, like shuttles. This is the actual grid itself, not the walls or other entities connected to the grid.
|
||||
None = 0,
|
||||
Opaque = 1 << 0, // 1 Blocks light, can be hit by lasers
|
||||
Impassable = 1 << 1, // 2 Walls, objects impassable by any means
|
||||
MidImpassable = 1 << 2, // 4 Mobs, players, crabs, etc
|
||||
HighImpassable = 1 << 3, // 8 Things on top of tables and things that block tall/large mobs.
|
||||
LowImpassable = 1 << 4, // 16 For things that can fit under a table or squeeze under an airlock
|
||||
GhostImpassable = 1 << 5, // 32 Things impassible by ghosts/observers, ie blessed tiles or forcefields
|
||||
BulletImpassable = 1 << 6, // 64 Can be hit by bullets
|
||||
|
||||
MobMask = Impassable | MobImpassable | VaultImpassable | SmallImpassable,
|
||||
ThrownItem = VaultImpassable,
|
||||
// 32 possible groups
|
||||
AllMask = -1,
|
||||
}
|
||||
MapGrid = MapGridHelpers.CollisionGroup, // Map grids, like shuttles. This is the actual grid itself, not the walls or other entities connected to the grid.
|
||||
|
||||
// 32 possible groups
|
||||
AllMask = -1,
|
||||
|
||||
MobMask = Impassable | MidImpassable | LowImpassable,
|
||||
MobLayer = Opaque | BulletImpassable,
|
||||
SmallMobMask = Impassable | LowImpassable,
|
||||
SmallMobLayer = Opaque | BulletImpassable,
|
||||
FlyingMobMask = Impassable,
|
||||
FlyingMobLayer = Opaque | BulletImpassable,
|
||||
|
||||
LargeMobMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
||||
LargeMobLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
||||
|
||||
MachineMask = Impassable | MidImpassable | LowImpassable,
|
||||
MachineLayer = Opaque | MidImpassable | LowImpassable | BulletImpassable,
|
||||
|
||||
TableMask = Impassable | MidImpassable,
|
||||
TableLayer = MidImpassable,
|
||||
|
||||
TabletopMachineMask = Impassable | HighImpassable,
|
||||
TabletopMachineLayer = Opaque | HighImpassable | BulletImpassable,
|
||||
|
||||
GlassAirlockLayer = HighImpassable | MidImpassable | BulletImpassable,
|
||||
AirlockLayer = Opaque | GlassAirlockLayer,
|
||||
|
||||
HumanoidBlockLayer = HighImpassable | MidImpassable,
|
||||
|
||||
SlipLayer = MidImpassable | LowImpassable,
|
||||
ItemMask = Impassable | HighImpassable,
|
||||
ThrownItem = Impassable | HighImpassable,
|
||||
WallLayer = Opaque | Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
||||
GlassLayer = Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
||||
HalfWallLayer = MidImpassable | LowImpassable,
|
||||
FullTileMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
||||
|
||||
SubfloorMask = Impassable | LowImpassable
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Content.Shared.Standing
|
||||
public bool Standing { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// List of fixtures that had vault-impassable prior to an entity being downed. Required when re-adding the
|
||||
/// collision mask.
|
||||
/// List of fixtures that had their collision mask changed when the entity was downed.
|
||||
/// Required for re-adding the collision mask.
|
||||
/// </summary>
|
||||
[DataField("vaultImpassableFixtures")]
|
||||
public List<string> VaultImpassableFixtures = new();
|
||||
[DataField("changedFixtures")]
|
||||
public List<string> ChangedFixtures = new();
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace Content.Shared.Standing
|
||||
public sealed class StandingStateSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
|
||||
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
|
||||
|
||||
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
|
||||
{
|
||||
@@ -61,15 +64,16 @@ namespace Content.Shared.Standing
|
||||
// Seemed like the best place to put it
|
||||
appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal);
|
||||
|
||||
// Change collision masks to allow going under certain entities like flaps and tables
|
||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||
{
|
||||
foreach (var (key, fixture) in fixtureComponent.Fixtures)
|
||||
{
|
||||
if ((fixture.CollisionMask & (int) CollisionGroup.VaultImpassable) == 0)
|
||||
if ((fixture.CollisionMask & StandingCollisionLayer) == 0)
|
||||
continue;
|
||||
|
||||
standingState.VaultImpassableFixtures.Add(key);
|
||||
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
||||
standingState.ChangedFixtures.Add(key);
|
||||
fixture.CollisionMask &= ~StandingCollisionLayer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,13 +115,13 @@ namespace Content.Shared.Standing
|
||||
|
||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||
{
|
||||
foreach (var key in standingState.VaultImpassableFixtures)
|
||||
foreach (var key in standingState.ChangedFixtures)
|
||||
{
|
||||
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture))
|
||||
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
||||
fixture.CollisionMask |= StandingCollisionLayer;
|
||||
}
|
||||
}
|
||||
standingState.VaultImpassableFixtures.Clear();
|
||||
standingState.ChangedFixtures.Clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user