Fix interaction and add comments to CollisionGroup (#8149)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Content.Shared.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Defined collision groups for the physics system.
|
||||
/// Mask is what it collides with when moving. Layer is what CollisionGroup it is part of.
|
||||
/// </summary>
|
||||
[Flags, PublicAPI]
|
||||
[FlagsFor(typeof(CollisionLayer)), FlagsFor(typeof(CollisionMask))]
|
||||
@@ -20,44 +21,59 @@ public enum CollisionGroup
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user