diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 191c1592e0..d9e308f39b 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -48,6 +48,9 @@ namespace Content.Shared.Interaction [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!; + private const CollisionGroup InRangeUnobstructedMask + = CollisionGroup.Impassable | CollisionGroup.InteractImpassable; + public const float InteractionRange = 2; public const float InteractionRangeSquared = InteractionRange * InteractionRange; @@ -329,7 +332,7 @@ namespace Content.Shared.Interaction public float UnobstructedDistance( MapCoordinates origin, MapCoordinates other, - int collisionMask = (int) CollisionGroup.Impassable, + int collisionMask = (int) InRangeUnobstructedMask, Ignored? predicate = null) { var dir = other.Position - origin.Position; @@ -368,7 +371,7 @@ namespace Content.Shared.Interaction MapCoordinates origin, MapCoordinates other, float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, + CollisionGroup collisionMask = InRangeUnobstructedMask, Ignored? predicate = null) { // Have to be on same map regardless. @@ -425,7 +428,7 @@ namespace Content.Shared.Interaction EntityUid origin, EntityUid other, float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, + CollisionGroup collisionMask = InRangeUnobstructedMask, Ignored? predicate = null, bool popup = false) {; @@ -446,7 +449,7 @@ namespace Content.Shared.Interaction MapCoordinates origin, EntityUid target, float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, + CollisionGroup collisionMask = InRangeUnobstructedMask, Ignored? predicate = null) { var transform = Transform(target); @@ -518,7 +521,7 @@ namespace Content.Shared.Interaction EntityUid origin, EntityCoordinates other, float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, + CollisionGroup collisionMask = InRangeUnobstructedMask, Ignored? predicate = null, bool popup = false) { @@ -553,7 +556,7 @@ namespace Content.Shared.Interaction EntityUid origin, MapCoordinates other, float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, + CollisionGroup collisionMask = InRangeUnobstructedMask, Ignored? predicate = null, bool popup = false) { diff --git a/Content.Shared/Physics/CollisionGroup.cs b/Content.Shared/Physics/CollisionGroup.cs index 8a2514ed07..f6762590ef 100644 --- a/Content.Shared/Physics/CollisionGroup.cs +++ b/Content.Shared/Physics/CollisionGroup.cs @@ -7,57 +7,73 @@ namespace Content.Shared.Physics; /// /// Defined collision groups for the physics system. +/// Mask is what it collides with when moving. Layer is what CollisionGroup it is part of. /// [Flags, PublicAPI] [FlagsFor(typeof(CollisionLayer)), FlagsFor(typeof(CollisionMask))] public enum CollisionGroup { - 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 + 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 + InteractImpassable = 1 << 7, // 128 Blocks interaction/InRangeUnobstructed 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, + // Humanoids, etc. MobMask = Impassable | HighImpassable | MidImpassable | LowImpassable, MobLayer = Opaque | BulletImpassable, + // Mice, drones SmallMobMask = Impassable | LowImpassable, SmallMobLayer = Opaque | BulletImpassable, + // Birds/other small flyers FlyingMobMask = Impassable, FlyingMobLayer = Opaque | BulletImpassable, + // Mechs LargeMobMask = Impassable | HighImpassable | MidImpassable | LowImpassable, LargeMobLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable, + // Machines, computers MachineMask = Impassable | MidImpassable | LowImpassable, MachineLayer = Opaque | MidImpassable | LowImpassable | BulletImpassable, + // Tables that SmallMobs can go under TableMask = Impassable | MidImpassable, TableLayer = MidImpassable, + // Tabletop machines, windoors, firelocks TabletopMachineMask = Impassable | HighImpassable, + // Tabletop machines TabletopMachineLayer = Opaque | HighImpassable | BulletImpassable, - GlassAirlockLayer = HighImpassable | MidImpassable | BulletImpassable, + // Airlocks, windoors, firelocks + GlassAirlockLayer = HighImpassable | MidImpassable | BulletImpassable | InteractImpassable, AirlockLayer = Opaque | GlassAirlockLayer, + // Airlock assembly HumanoidBlockLayer = HighImpassable | MidImpassable, + // Soap, spills SlipLayer = MidImpassable | LowImpassable, ItemMask = Impassable | HighImpassable, ThrownItem = Impassable | HighImpassable, - WallLayer = Opaque | Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable, - GlassLayer = Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable, + WallLayer = Opaque | Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable | InteractImpassable, + GlassLayer = Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable | InteractImpassable, HalfWallLayer = MidImpassable | LowImpassable, - FullTileMask = Impassable | HighImpassable | MidImpassable | LowImpassable, - FullTileLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable, - + + // Statue, monument, airlock, window + FullTileMask = Impassable | HighImpassable | MidImpassable | LowImpassable | InteractImpassable, + // FlyingMob can go past + FullTileLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable | InteractImpassable, + SubfloorMask = Impassable | LowImpassable }