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] private readonly SharedPhysicsSystem _physicsSystem = default!;
|
||||||
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||||
|
|
||||||
|
private const CollisionGroup InRangeUnobstructedMask
|
||||||
|
= CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
|
||||||
|
|
||||||
public const float InteractionRange = 2;
|
public const float InteractionRange = 2;
|
||||||
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
||||||
|
|
||||||
@@ -329,7 +332,7 @@ namespace Content.Shared.Interaction
|
|||||||
public float UnobstructedDistance(
|
public float UnobstructedDistance(
|
||||||
MapCoordinates origin,
|
MapCoordinates origin,
|
||||||
MapCoordinates other,
|
MapCoordinates other,
|
||||||
int collisionMask = (int) CollisionGroup.Impassable,
|
int collisionMask = (int) InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null)
|
Ignored? predicate = null)
|
||||||
{
|
{
|
||||||
var dir = other.Position - origin.Position;
|
var dir = other.Position - origin.Position;
|
||||||
@@ -368,7 +371,7 @@ namespace Content.Shared.Interaction
|
|||||||
MapCoordinates origin,
|
MapCoordinates origin,
|
||||||
MapCoordinates other,
|
MapCoordinates other,
|
||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null)
|
Ignored? predicate = null)
|
||||||
{
|
{
|
||||||
// Have to be on same map regardless.
|
// Have to be on same map regardless.
|
||||||
@@ -425,7 +428,7 @@ namespace Content.Shared.Interaction
|
|||||||
EntityUid origin,
|
EntityUid origin,
|
||||||
EntityUid other,
|
EntityUid other,
|
||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null,
|
Ignored? predicate = null,
|
||||||
bool popup = false)
|
bool popup = false)
|
||||||
{;
|
{;
|
||||||
@@ -446,7 +449,7 @@ namespace Content.Shared.Interaction
|
|||||||
MapCoordinates origin,
|
MapCoordinates origin,
|
||||||
EntityUid target,
|
EntityUid target,
|
||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null)
|
Ignored? predicate = null)
|
||||||
{
|
{
|
||||||
var transform = Transform(target);
|
var transform = Transform(target);
|
||||||
@@ -518,7 +521,7 @@ namespace Content.Shared.Interaction
|
|||||||
EntityUid origin,
|
EntityUid origin,
|
||||||
EntityCoordinates other,
|
EntityCoordinates other,
|
||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null,
|
Ignored? predicate = null,
|
||||||
bool popup = false)
|
bool popup = false)
|
||||||
{
|
{
|
||||||
@@ -553,7 +556,7 @@ namespace Content.Shared.Interaction
|
|||||||
EntityUid origin,
|
EntityUid origin,
|
||||||
MapCoordinates other,
|
MapCoordinates other,
|
||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null,
|
Ignored? predicate = null,
|
||||||
bool popup = false)
|
bool popup = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Content.Shared.Physics;
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defined collision groups for the physics system.
|
/// Defined collision groups for the physics system.
|
||||||
|
/// Mask is what it collides with when moving. Layer is what CollisionGroup it is part of.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Flags, PublicAPI]
|
[Flags, PublicAPI]
|
||||||
[FlagsFor(typeof(CollisionLayer)), FlagsFor(typeof(CollisionMask))]
|
[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
|
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
|
GhostImpassable = 1 << 5, // 32 Things impassible by ghosts/observers, ie blessed tiles or forcefields
|
||||||
BulletImpassable = 1 << 6, // 64 Can be hit by bullets
|
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.
|
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
|
// 32 possible groups
|
||||||
AllMask = -1,
|
AllMask = -1,
|
||||||
|
|
||||||
|
// Humanoids, etc.
|
||||||
MobMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
MobMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
||||||
MobLayer = Opaque | BulletImpassable,
|
MobLayer = Opaque | BulletImpassable,
|
||||||
|
// Mice, drones
|
||||||
SmallMobMask = Impassable | LowImpassable,
|
SmallMobMask = Impassable | LowImpassable,
|
||||||
SmallMobLayer = Opaque | BulletImpassable,
|
SmallMobLayer = Opaque | BulletImpassable,
|
||||||
|
// Birds/other small flyers
|
||||||
FlyingMobMask = Impassable,
|
FlyingMobMask = Impassable,
|
||||||
FlyingMobLayer = Opaque | BulletImpassable,
|
FlyingMobLayer = Opaque | BulletImpassable,
|
||||||
|
|
||||||
|
// Mechs
|
||||||
LargeMobMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
LargeMobMask = Impassable | HighImpassable | MidImpassable | LowImpassable,
|
||||||
LargeMobLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
LargeMobLayer = Opaque | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
||||||
|
|
||||||
|
// Machines, computers
|
||||||
MachineMask = Impassable | MidImpassable | LowImpassable,
|
MachineMask = Impassable | MidImpassable | LowImpassable,
|
||||||
MachineLayer = Opaque | MidImpassable | LowImpassable | BulletImpassable,
|
MachineLayer = Opaque | MidImpassable | LowImpassable | BulletImpassable,
|
||||||
|
|
||||||
|
// Tables that SmallMobs can go under
|
||||||
TableMask = Impassable | MidImpassable,
|
TableMask = Impassable | MidImpassable,
|
||||||
TableLayer = MidImpassable,
|
TableLayer = MidImpassable,
|
||||||
|
|
||||||
|
// Tabletop machines, windoors, firelocks
|
||||||
TabletopMachineMask = Impassable | HighImpassable,
|
TabletopMachineMask = Impassable | HighImpassable,
|
||||||
|
// Tabletop machines
|
||||||
TabletopMachineLayer = Opaque | HighImpassable | BulletImpassable,
|
TabletopMachineLayer = Opaque | HighImpassable | BulletImpassable,
|
||||||
|
|
||||||
GlassAirlockLayer = HighImpassable | MidImpassable | BulletImpassable,
|
// Airlocks, windoors, firelocks
|
||||||
|
GlassAirlockLayer = HighImpassable | MidImpassable | BulletImpassable | InteractImpassable,
|
||||||
AirlockLayer = Opaque | GlassAirlockLayer,
|
AirlockLayer = Opaque | GlassAirlockLayer,
|
||||||
|
|
||||||
|
// Airlock assembly
|
||||||
HumanoidBlockLayer = HighImpassable | MidImpassable,
|
HumanoidBlockLayer = HighImpassable | MidImpassable,
|
||||||
|
|
||||||
|
// Soap, spills
|
||||||
SlipLayer = MidImpassable | LowImpassable,
|
SlipLayer = MidImpassable | LowImpassable,
|
||||||
ItemMask = Impassable | HighImpassable,
|
ItemMask = Impassable | HighImpassable,
|
||||||
ThrownItem = Impassable | HighImpassable,
|
ThrownItem = Impassable | HighImpassable,
|
||||||
WallLayer = Opaque | Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
WallLayer = Opaque | Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable | InteractImpassable,
|
||||||
GlassLayer = Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable,
|
GlassLayer = Impassable | HighImpassable | MidImpassable | LowImpassable | BulletImpassable | InteractImpassable,
|
||||||
HalfWallLayer = MidImpassable | LowImpassable,
|
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
|
SubfloorMask = Impassable | LowImpassable
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user