vehicle access fix (#12868)
This commit is contained in:
@@ -21,4 +21,17 @@ namespace Content.Shared.Access.Components
|
|||||||
[DataField("groups", readOnly: true, customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessGroupPrototype>))]
|
[DataField("groups", readOnly: true, customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AccessGroupPrototype>))]
|
||||||
public readonly HashSet<string> Groups = new();
|
public readonly HashSet<string> Groups = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event raised on an entity to find additional entities which provide access.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public struct GetAdditionalAccessEvent
|
||||||
|
{
|
||||||
|
public HashSet<EntityUid> Entities = new();
|
||||||
|
|
||||||
|
public GetAdditionalAccessEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace Content.Shared.Access.Systems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the access tags on the given entity
|
/// Finds the access tags on the given entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The entity that to search.</param>
|
/// <param name="uid">The entity that is being searched.</param>
|
||||||
public ICollection<string> FindAccessTags(EntityUid uid)
|
public ICollection<string> FindAccessTags(EntityUid uid)
|
||||||
{
|
{
|
||||||
HashSet<string>? tags = null;
|
HashSet<string>? tags = null;
|
||||||
@@ -117,18 +117,19 @@ namespace Content.Shared.Access.Systems
|
|||||||
// check entity itself
|
// check entity itself
|
||||||
FindAccessTagsItem(uid, ref tags, ref owned);
|
FindAccessTagsItem(uid, ref tags, ref owned);
|
||||||
|
|
||||||
foreach (var item in _handsSystem.EnumerateHeld(uid))
|
FindAccessItemsInventory(uid, out var items);
|
||||||
|
|
||||||
|
var ev = new GetAdditionalAccessEvent
|
||||||
{
|
{
|
||||||
FindAccessTagsItem(item, ref tags, ref owned);
|
Entities = items
|
||||||
|
};
|
||||||
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
foreach (var ent in ev.Entities)
|
||||||
|
{
|
||||||
|
FindAccessTagsItem(ent, ref tags, ref owned);
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe its inside an inventory slot?
|
return (ICollection<string>?) tags ?? Array.Empty<string>();
|
||||||
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
|
|
||||||
{
|
|
||||||
FindAccessTagsItem(idUid.Value, ref tags, ref owned);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((ICollection<string>?) tags) ?? Array.Empty<string>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -163,6 +164,24 @@ namespace Content.Shared.Access.Systems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FindAccessItemsInventory(EntityUid uid, out HashSet<EntityUid> items)
|
||||||
|
{
|
||||||
|
items = new();
|
||||||
|
|
||||||
|
foreach (var item in _handsSystem.EnumerateHeld(uid))
|
||||||
|
{
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// maybe its inside an inventory slot?
|
||||||
|
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
|
||||||
|
{
|
||||||
|
items.Add(idUid.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items.Any();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to find <see cref="AccessComponent"/> on this item
|
/// Try to find <see cref="AccessComponent"/> on this item
|
||||||
/// or inside this item (if it's pda)
|
/// or inside this item (if it's pda)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Shared.Access.Components;
|
||||||
|
using Content.Shared.Access.Systems;
|
||||||
using Content.Shared.Vehicle.Components;
|
using Content.Shared.Vehicle.Components;
|
||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
@@ -9,6 +12,8 @@ using Robust.Shared.Serialization;
|
|||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
|
using Content.Shared.Hands.EntitySystems;
|
||||||
|
using Content.Shared.Inventory;
|
||||||
|
|
||||||
namespace Content.Shared.Vehicle;
|
namespace Content.Shared.Vehicle;
|
||||||
|
|
||||||
@@ -24,6 +29,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSound = default!;
|
[Dependency] private readonly SharedAmbientSoundSystem _ambientSound = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||||
|
[Dependency] private readonly AccessReaderSystem _access = default!;
|
||||||
|
|
||||||
private const string KeySlot = "key_slot";
|
private const string KeySlot = "key_slot";
|
||||||
|
|
||||||
@@ -37,6 +43,7 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<VehicleComponent, MoveEvent>(OnVehicleRotate);
|
SubscribeLocalEvent<VehicleComponent, MoveEvent>(OnVehicleRotate);
|
||||||
SubscribeLocalEvent<VehicleComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
SubscribeLocalEvent<VehicleComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||||
SubscribeLocalEvent<VehicleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
SubscribeLocalEvent<VehicleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||||
|
SubscribeLocalEvent<VehicleComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -177,6 +184,17 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGetAdditionalAccess(EntityUid uid, VehicleComponent component, ref GetAdditionalAccessEvent args)
|
||||||
|
{
|
||||||
|
if (component.Rider == null)
|
||||||
|
return;
|
||||||
|
var rider = component.Rider.Value;
|
||||||
|
|
||||||
|
args.Entities.Add(rider);
|
||||||
|
_access.FindAccessItemsInventory(rider, out var items);
|
||||||
|
args.Entities = args.Entities.Union(items).ToHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the draw depth for the sprite.
|
/// Set the draw depth for the sprite.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -89,10 +89,6 @@
|
|||||||
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Access
|
|
||||||
tags:
|
|
||||||
- Maintenance
|
|
||||||
- Janitor
|
|
||||||
- type: UnpoweredFlashlight
|
- type: UnpoweredFlashlight
|
||||||
toggleAction:
|
toggleAction:
|
||||||
name: action-name-toggle-light
|
name: action-name-toggle-light
|
||||||
@@ -180,12 +176,6 @@
|
|||||||
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Access
|
|
||||||
tags:
|
|
||||||
- Security
|
|
||||||
- Brig
|
|
||||||
- Maintenance
|
|
||||||
- Service
|
|
||||||
- type: Strap
|
- type: Strap
|
||||||
buckleOffset: "0.15, -0.05"
|
buckleOffset: "0.15, -0.05"
|
||||||
maxBuckleDistance: 1
|
maxBuckleDistance: 1
|
||||||
@@ -230,10 +220,6 @@
|
|||||||
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Access
|
|
||||||
tags:
|
|
||||||
- Cargo
|
|
||||||
- Maintenance
|
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
descriptionSegments: [ATVDescriptions]
|
descriptionSegments: [ATVDescriptions]
|
||||||
- type: MovementSpeedModifier
|
- type: MovementSpeedModifier
|
||||||
@@ -290,10 +276,6 @@
|
|||||||
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
map: ["enum.VehicleVisualLayers.AutoAnimate"]
|
||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Access
|
|
||||||
tags:
|
|
||||||
- Maintenance
|
|
||||||
- Service
|
|
||||||
- type: Strap
|
- type: Strap
|
||||||
buckleOffset: "0.15, -0.05"
|
buckleOffset: "0.15, -0.05"
|
||||||
maxBuckleDistance: 1
|
maxBuckleDistance: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user