Implement inflatable wall (#3703)

* Implement inflatable wall

* Actually block atmos

* Fix naming and add description

* Add requested changes

* Change prototype to field

* Refactor checks to use existing methods

* Fix PrototypeIdSerializer imports

* Fix mass in yaml
This commit is contained in:
ShadowCommander
2021-04-01 00:04:56 -07:00
committed by GitHub
parent a69e98dcdc
commit a98c0dadd4
17 changed files with 417 additions and 9 deletions

View File

@@ -95,6 +95,8 @@ namespace Content.Shared.GameObjects
public const uint TAG = 1086;
// Used for clientside fake prediction of doors.
public const uint DOOR = 1087;
public const uint SPAWN_AFTER_INTERACT = 1088;
public const uint DISASSEMBLE_ON_ACTIVATE = 1089;
// Net IDs for integration tests.
public const uint PREDICTION_TEST = 10001;

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Physics;
@@ -541,5 +541,63 @@ namespace Content.Shared.GameObjects.EntitySystems
return InRangeUnobstructed(user, otherPosition, range, collisionMask, predicate, ignoreInsideBlocker, popup);
}
/// <summary>
/// Checks that the user and target of a
/// <see cref="AfterInteractMessage"/> are within a certain distance
/// without any entity that matches the collision mask obstructing them.
/// If the <paramref name="range"/> is zero or negative,
/// this method will only check if nothing obstructs the entity and component.
/// </summary>
/// <param name="args">The event args to use.</param>
/// <param name="range">
/// Maximum distance between the two entity and set of map coordinates.
/// </param>
/// <param name="collisionMask">The mask to check for collisions.</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <param name="ignoreInsideBlocker">
/// If true and both the user and target are inside
/// the obstruction, ignores the obstruction and considers the interaction
/// unobstructed.
/// Therefore, setting this to true makes this check more permissive,
/// such as allowing an interaction to occur inside something impassable
/// (like a wall). The default, false, makes the check more restrictive.
/// </param>
/// <param name="popup">
/// Whether or not to popup a feedback message on the user entity for
/// it to see.
/// </param>
/// <returns>
/// True if the two points are within a given range without being obstructed.
/// </returns>
public bool InRangeUnobstructed(
AfterInteractMessage args,
float range = InteractionRange,
CollisionGroup collisionMask = CollisionGroup.Impassable,
Ignored? predicate = null,
bool ignoreInsideBlocker = false,
bool popup = false)
{
var user = args.User;
var target = args.Attacked;
predicate ??= e => e == user;
MapCoordinates otherPosition;
if (target == null)
{
otherPosition = args.ClickLocation.ToMap(EntityManager);
}
else
{
otherPosition = target.Transform.MapPosition;
predicate += e => e == target;
}
return InRangeUnobstructed(user, otherPosition, range, collisionMask, predicate, ignoreInsideBlocker, popup);
}
}
}

View File

@@ -58,9 +58,9 @@ namespace Content.Shared.Maps
return tile;
}
public static bool TryGetTileRef(this EntityCoordinates coordinates, [NotNullWhen(true)] out TileRef? turf)
public static bool TryGetTileRef(this EntityCoordinates coordinates, [NotNullWhen(true)] out TileRef? turf, IEntityManager? entityManager = null, IMapManager? mapManager = null)
{
return (turf = coordinates.GetTileRef()) != null;
return (turf = coordinates.GetTileRef(entityManager, mapManager)) != null;
}
/// <summary>

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Physics;
@@ -430,5 +430,19 @@ namespace Content.Shared.Utility
ignoreInsideBlocker, popup);
}
#endregion
#region EntityEventArgs
public static bool InRangeUnobstructed(
this AfterInteractMessage args,
float range = InteractionRange,
CollisionGroup collisionMask = CollisionGroup.Impassable,
Ignored? predicate = null,
bool ignoreInsideBlocker = false,
bool popup = false)
{
return SharedInteractionSystem.InRangeUnobstructed(args, range, collisionMask, predicate,
ignoreInsideBlocker, popup);
}
#endregion
}
}