Moves buckling and vehicles to shared, some cleanup (#15923)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Buckle;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Alert.Click
|
||||
@@ -13,7 +13,7 @@ namespace Content.Server.Alert.Click
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().System<BuckleSystem>().TryUnbuckle(player, player);
|
||||
IoCManager.Resolve<IEntityManager>().System<SharedBuckleSystem>().TryUnbuckle(player, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Server.Bed
|
||||
SubscribeLocalEvent<StasisBedComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||
}
|
||||
|
||||
private void ManageUpdateList(EntityUid uid, HealOnBuckleComponent component, BuckleChangeEvent args)
|
||||
private void ManageUpdateList(EntityUid uid, HealOnBuckleComponent component, ref BuckleChangeEvent args)
|
||||
{
|
||||
_prototypeManager.TryIndex<InstantActionPrototype>("Sleep", out var sleepAction);
|
||||
if (args.Buckling)
|
||||
@@ -92,7 +92,7 @@ namespace Content.Server.Bed
|
||||
_appearance.SetData(uid, StasisBedVisuals.IsOn, isOn);
|
||||
}
|
||||
|
||||
private void OnBuckleChange(EntityUid uid, StasisBedComponent component, BuckleChangeEvent args)
|
||||
private void OnBuckleChange(EntityUid uid, StasisBedComponent component, ref BuckleChangeEvent args)
|
||||
{
|
||||
// In testing this also received an unbuckle event when the bed is destroyed
|
||||
// So don't worry about that
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Buckle.Systems;
|
||||
|
||||
public sealed partial class BuckleSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
private void InitializeBuckle()
|
||||
{
|
||||
SubscribeLocalEvent<BuckleComponent, ComponentStartup>(OnBuckleStartup);
|
||||
SubscribeLocalEvent<BuckleComponent, ComponentShutdown>(OnBuckleShutdown);
|
||||
SubscribeLocalEvent<BuckleComponent, ComponentGetState>(OnBuckleGetState);
|
||||
SubscribeLocalEvent<BuckleComponent, MoveEvent>(MoveEvent);
|
||||
SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(HandleInteractHand);
|
||||
SubscribeLocalEvent<BuckleComponent, GetVerbsEvent<InteractionVerb>>(AddUnbuckleVerb);
|
||||
SubscribeLocalEvent<BuckleComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
||||
SubscribeLocalEvent<BuckleComponent, CanDropDraggedEvent>(OnBuckleCanDrop);
|
||||
SubscribeLocalEvent<BuckleComponent, DragDropDraggedEvent>(OnBuckleDragDrop);
|
||||
}
|
||||
|
||||
private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !component.Buckled)
|
||||
return;
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => TryUnbuckle(uid, args.User, buckle: component),
|
||||
Text = Loc.GetString("verb-categories-unbuckle"),
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/unbuckle.svg.192dpi.png"))
|
||||
};
|
||||
|
||||
if (args.Target == args.User && args.Using == null)
|
||||
{
|
||||
// A user is left clicking themselves with an empty hand, while buckled.
|
||||
// It is very likely they are trying to unbuckle themselves.
|
||||
verb.Priority = 1;
|
||||
}
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void OnBuckleStartup(EntityUid uid, BuckleComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateBuckleStatus(uid, component);
|
||||
}
|
||||
|
||||
private void OnBuckleShutdown(EntityUid uid, BuckleComponent component, ComponentShutdown args)
|
||||
{
|
||||
TryUnbuckle(uid, uid, true, component);
|
||||
|
||||
component.BuckleTime = default;
|
||||
}
|
||||
|
||||
private void OnBuckleGetState(EntityUid uid, BuckleComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new BuckleComponentState(component.Buckled, component.LastEntityBuckledTo, component.DontCollide);
|
||||
}
|
||||
|
||||
private void HandleInteractHand(EntityUid uid, BuckleComponent component, InteractHandEvent args)
|
||||
{
|
||||
if (TryUnbuckle(uid, args.User, buckle: component))
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void MoveEvent(EntityUid uid, BuckleComponent buckle, ref MoveEvent ev)
|
||||
{
|
||||
var strap = buckle.BuckledTo;
|
||||
|
||||
if (strap == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var strapPosition = Transform(strap.Owner).Coordinates;
|
||||
|
||||
if (ev.NewPosition.InRange(EntityManager, strapPosition, strap.MaxBuckleDistance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TryUnbuckle(uid, buckle.Owner, true, buckle);
|
||||
}
|
||||
|
||||
private void OnEntityStorageInsertAttempt(EntityUid uid, BuckleComponent comp, ref InsertIntoEntityStorageAttemptEvent args)
|
||||
{
|
||||
if (comp.Buckled)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnBuckleCanDrop(EntityUid uid, BuckleComponent component, ref CanDropDraggedEvent args)
|
||||
{
|
||||
args.Handled = HasComp<StrapComponent>(args.Target);
|
||||
}
|
||||
|
||||
private void OnBuckleDragDrop(EntityUid uid, BuckleComponent component, ref DragDropDraggedEvent args)
|
||||
{
|
||||
args.Handled = TryBuckle(uid, args.User, args.Target, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows or hides the buckled status effect depending on if the
|
||||
/// entity is buckled or not.
|
||||
/// </summary>
|
||||
private void UpdateBuckleStatus(EntityUid uid, BuckleComponent component)
|
||||
{
|
||||
if (component.Buckled)
|
||||
{
|
||||
var alertType = component.BuckledTo?.BuckledAlertType ?? AlertType.Buckled;
|
||||
_alerts.ShowAlert(uid, alertType);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alerts.ClearAlertCategory(uid, AlertCategory.Buckled);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBuckledTo(BuckleComponent buckle, StrapComponent? strap)
|
||||
{
|
||||
buckle.BuckledTo = strap;
|
||||
buckle.LastEntityBuckledTo = strap?.Owner;
|
||||
|
||||
if (strap == null)
|
||||
{
|
||||
buckle.Buckled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buckle.DontCollide = true;
|
||||
buckle.Buckled = true;
|
||||
buckle.BuckleTime = _gameTiming.CurTime;
|
||||
}
|
||||
|
||||
_actionBlocker.UpdateCanMove(buckle.Owner);
|
||||
UpdateBuckleStatus(buckle.Owner, buckle);
|
||||
Dirty(buckle);
|
||||
}
|
||||
|
||||
private bool CanBuckle(
|
||||
EntityUid buckleId,
|
||||
EntityUid user,
|
||||
EntityUid to,
|
||||
[NotNullWhen(true)] out StrapComponent? strap,
|
||||
BuckleComponent? buckle = null)
|
||||
{
|
||||
strap = null;
|
||||
|
||||
if (user == to ||
|
||||
!Resolve(buckleId, ref buckle, false) ||
|
||||
!Resolve(to, ref strap, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var strapUid = strap.Owner;
|
||||
bool Ignored(EntityUid entity) => entity == buckleId || entity == user || entity == strapUid;
|
||||
|
||||
if (!_interactions.InRangeUnobstructed(buckleId, strapUid, buckle.Range, predicate: Ignored, popup: true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If in a container
|
||||
if (_containers.TryGetContainingContainer(buckleId, out var ownerContainer))
|
||||
{
|
||||
// And not in the same container as the strap
|
||||
if (!_containers.TryGetContainingContainer(strap.Owner, out var strapContainer) ||
|
||||
ownerContainer != strapContainer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!HasComp<HandsComponent>(user))
|
||||
{
|
||||
_popups.PopupEntity(Loc.GetString("buckle-component-no-hands-message"), user, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buckle.Buckled)
|
||||
{
|
||||
var message = Loc.GetString(buckleId == user
|
||||
? "buckle-component-already-buckled-message"
|
||||
: "buckle-component-other-already-buckled-message",
|
||||
("owner", Identity.Entity(buckleId, EntityManager)));
|
||||
_popups.PopupEntity(message, user, user);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var parent = Transform(to).ParentUid;
|
||||
while (parent.IsValid())
|
||||
{
|
||||
if (parent == user)
|
||||
{
|
||||
var message = Loc.GetString(buckleId == user
|
||||
? "buckle-component-cannot-buckle-message"
|
||||
: "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleId, EntityManager)));
|
||||
_popups.PopupEntity(message, user, user);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
parent = Transform(parent).ParentUid;
|
||||
}
|
||||
|
||||
if (!StrapHasSpace(to, buckle, strap))
|
||||
{
|
||||
var message = Loc.GetString(buckleId == user
|
||||
? "buckle-component-cannot-fit-message"
|
||||
: "buckle-component-other-cannot-fit-message", ("owner", Identity.Entity(buckleId, EntityManager)));
|
||||
_popups.PopupEntity(message, user, user);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryBuckle(EntityUid buckleId, EntityUid user, EntityUid to, BuckleComponent? buckle = null)
|
||||
{
|
||||
if (!Resolve(buckleId, ref buckle, false))
|
||||
return false;
|
||||
|
||||
if (!CanBuckle(buckleId, user, to, out var strap, buckle))
|
||||
return false;
|
||||
|
||||
_audio.PlayPvs(strap.BuckleSound, buckleId);
|
||||
|
||||
if (!StrapTryAdd(to, buckle, strap: strap))
|
||||
{
|
||||
var message = Loc.GetString(buckleId == user
|
||||
? "buckle-component-cannot-buckle-message"
|
||||
: "buckle-component-other-cannot-buckle-message", ("owner", Identity.Entity(buckleId, EntityManager)));
|
||||
_popups.PopupEntity(message, user, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TryComp<AppearanceComponent>(buckleId, out var appearance))
|
||||
_appearance.SetData(buckleId, BuckleVisuals.Buckled, true, appearance);
|
||||
|
||||
ReAttach(buckleId, strap, buckle);
|
||||
SetBuckledTo(buckle, strap);
|
||||
|
||||
var ev = new BuckleChangeEvent { Buckling = true, Strap = strap.Owner, BuckledEntity = buckleId };
|
||||
RaiseLocalEvent(ev.BuckledEntity, ev);
|
||||
RaiseLocalEvent(ev.Strap, ev);
|
||||
|
||||
if (TryComp(buckleId, out SharedPullableComponent? ownerPullable))
|
||||
{
|
||||
if (ownerPullable.Puller != null)
|
||||
{
|
||||
_pulling.TryStopPull(ownerPullable);
|
||||
}
|
||||
}
|
||||
|
||||
if (TryComp(to, out SharedPullableComponent? toPullable))
|
||||
{
|
||||
if (toPullable.Puller == buckleId)
|
||||
{
|
||||
// can't pull it and buckle to it at the same time
|
||||
_pulling.TryStopPull(toPullable);
|
||||
}
|
||||
}
|
||||
|
||||
// Logging
|
||||
if (user != buckleId)
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user):player} buckled {ToPrettyString(buckleId)} to {ToPrettyString(to)}");
|
||||
else
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user):player} buckled themselves to {ToPrettyString(to)}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to unbuckle the Owner of this component from its current strap.
|
||||
/// </summary>
|
||||
/// <param name="buckleId">The entity to unbuckle.</param>
|
||||
/// <param name="user">The entity doing the unbuckling.</param>
|
||||
/// <param name="force">
|
||||
/// Whether to force the unbuckling or not. Does not guarantee true to
|
||||
/// be returned, but guarantees the owner to be unbuckled afterwards.
|
||||
/// </param>
|
||||
/// <param name="buckle">The buckle component of the entity to unbuckle.</param>
|
||||
/// <returns>
|
||||
/// true if the owner was unbuckled, otherwise false even if the owner
|
||||
/// was previously already unbuckled.
|
||||
/// </returns>
|
||||
public bool TryUnbuckle(EntityUid buckleId, EntityUid user, bool force = false, BuckleComponent? buckle = null)
|
||||
{
|
||||
if (!Resolve(buckleId, ref buckle, false) ||
|
||||
buckle.BuckledTo is not { } oldBuckledTo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!force)
|
||||
{
|
||||
if (_gameTiming.CurTime < buckle.BuckleTime + buckle.UnbuckleDelay)
|
||||
return false;
|
||||
|
||||
if (!_interactions.InRangeUnobstructed(user, oldBuckledTo.Owner, buckle.Range, popup: true))
|
||||
return false;
|
||||
|
||||
if (HasComp<SleepingComponent>(buckleId) && buckleId == user)
|
||||
return false;
|
||||
|
||||
// If the strap is a vehicle and the rider is not the person unbuckling, return.
|
||||
if (TryComp(oldBuckledTo.Owner, out VehicleComponent? vehicle) &&
|
||||
vehicle.Rider != user)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Logging
|
||||
if (user != buckleId)
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user):player} unbuckled {ToPrettyString(buckleId)} from {ToPrettyString(oldBuckledTo.Owner)}");
|
||||
else
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user):player} unbuckled themselves from {ToPrettyString(oldBuckledTo.Owner)}");
|
||||
|
||||
SetBuckledTo(buckle, null);
|
||||
|
||||
var xform = Transform(buckleId);
|
||||
var oldBuckledXform = Transform(oldBuckledTo.Owner);
|
||||
|
||||
if (xform.ParentUid == oldBuckledXform.Owner && !Terminating(xform.ParentUid))
|
||||
{
|
||||
_containers.AttachParentToContainerOrGrid(xform);
|
||||
xform.WorldRotation = oldBuckledXform.WorldRotation;
|
||||
|
||||
if (oldBuckledTo.UnbuckleOffset != Vector2.Zero)
|
||||
xform.Coordinates = oldBuckledXform.Coordinates.Offset(oldBuckledTo.UnbuckleOffset);
|
||||
}
|
||||
|
||||
if (TryComp(buckleId, out AppearanceComponent? appearance))
|
||||
_appearance.SetData(buckleId, BuckleVisuals.Buckled, false, appearance);
|
||||
|
||||
if ((TryComp<MobStateComponent>(buckleId, out var mobState) && _mobState.IsIncapacitated(buckleId, mobState)) ||
|
||||
HasComp<KnockedDownComponent>(buckleId))
|
||||
{
|
||||
_standing.Down(buckleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_standing.Stand(buckleId);
|
||||
}
|
||||
|
||||
if (_mobState.IsIncapacitated(buckleId, mobState))
|
||||
{
|
||||
_standing.Down(buckleId);
|
||||
}
|
||||
// Sync StrapComponent data
|
||||
_appearance.SetData(oldBuckledTo.Owner, StrapVisuals.State, false);
|
||||
if (oldBuckledTo.BuckledEntities.Remove(buckleId))
|
||||
{
|
||||
oldBuckledTo.OccupiedSize -= buckle.Size;
|
||||
Dirty(oldBuckledTo);
|
||||
}
|
||||
|
||||
_audio.PlayPvs(oldBuckledTo.UnbuckleSound, buckleId);
|
||||
|
||||
var ev = new BuckleChangeEvent { Buckling = false, Strap = oldBuckledTo.Owner, BuckledEntity = buckleId };
|
||||
RaiseLocalEvent(buckleId, ev);
|
||||
RaiseLocalEvent(oldBuckledTo.Owner, ev);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes an entity toggle the buckling status of the owner to a
|
||||
/// specific entity.
|
||||
/// </summary>
|
||||
/// <param name="buckleId">The entity to buckle/unbuckle from <see cref="to"/>.</param>
|
||||
/// <param name="user">The entity doing the buckling/unbuckling.</param>
|
||||
/// <param name="to">
|
||||
/// The entity to toggle the buckle status of the owner to.
|
||||
/// </param>
|
||||
/// <param name="force">
|
||||
/// Whether to force the unbuckling or not, if it happens. Does not
|
||||
/// guarantee true to be returned, but guarantees the owner to be
|
||||
/// unbuckled afterwards.
|
||||
/// </param>
|
||||
/// <param name="buckle">The buckle component of the entity to buckle/unbuckle from <see cref="to"/>.</param>
|
||||
/// <returns>true if the buckling status was changed, false otherwise.</returns>
|
||||
public bool ToggleBuckle(
|
||||
EntityUid buckleId,
|
||||
EntityUid user,
|
||||
EntityUid to,
|
||||
bool force = false,
|
||||
BuckleComponent? buckle = null)
|
||||
{
|
||||
if (!Resolve(buckleId, ref buckle, false))
|
||||
return false;
|
||||
|
||||
if (buckle.BuckledTo?.Owner == to)
|
||||
{
|
||||
return TryUnbuckle(buckleId, user, force, buckle);
|
||||
}
|
||||
|
||||
return TryBuckle(buckleId, user, to, buckle);
|
||||
}
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Construction.Completions;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.Buckle.Systems;
|
||||
|
||||
public sealed partial class BuckleSystem
|
||||
{
|
||||
private void InitializeStrap()
|
||||
{
|
||||
SubscribeLocalEvent<StrapComponent, ComponentShutdown>(OnStrapShutdown);
|
||||
SubscribeLocalEvent<StrapComponent, ComponentRemove>((_, c, _) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, ComponentGetState>(OnStrapGetState);
|
||||
SubscribeLocalEvent<StrapComponent, EntInsertedIntoContainerMessage>(ContainerModifiedStrap);
|
||||
SubscribeLocalEvent<StrapComponent, EntRemovedFromContainerMessage>(ContainerModifiedStrap);
|
||||
SubscribeLocalEvent<StrapComponent, GetVerbsEvent<InteractionVerb>>(AddStrapVerbs);
|
||||
SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnStrapInsertAttempt);
|
||||
SubscribeLocalEvent<StrapComponent, InteractHandEvent>(OnStrapInteractHand);
|
||||
SubscribeLocalEvent<StrapComponent, DestructionEventArgs>((_,c,_) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, BreakageEventArgs>((_, c, _) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, ConstructionBeforeDeleteEvent>((_, c, _) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, DragDropTargetEvent>(OnStrapDragDrop);
|
||||
}
|
||||
|
||||
private void OnStrapGetState(EntityUid uid, StrapComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new StrapComponentState(component.Position, component.BuckleOffset, component.BuckledEntities, component.MaxBuckleDistance);
|
||||
}
|
||||
|
||||
private void ContainerModifiedStrap(EntityUid uid, StrapComponent strap, ContainerModifiedMessage message)
|
||||
{
|
||||
if (GameTiming.ApplyingState)
|
||||
return;
|
||||
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
if (!TryComp(buckledEntity, out BuckleComponent? buckled))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ContainerModifiedReAttach(buckledEntity, strap.Owner, buckled, strap);
|
||||
}
|
||||
}
|
||||
|
||||
private void ContainerModifiedReAttach(EntityUid buckleId, EntityUid strapId, BuckleComponent? buckle = null, StrapComponent? strap = null)
|
||||
{
|
||||
if (!Resolve(buckleId, ref buckle, false) ||
|
||||
!Resolve(strapId, ref strap, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var contained = _containers.TryGetContainingContainer(buckleId, out var ownContainer);
|
||||
var strapContained = _containers.TryGetContainingContainer(strapId, out var strapContainer);
|
||||
|
||||
if (contained != strapContained || ownContainer != strapContainer)
|
||||
{
|
||||
TryUnbuckle(buckleId, buckle.Owner, true, buckle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!contained)
|
||||
{
|
||||
ReAttach(buckleId, strap, buckle);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStrapShutdown(EntityUid uid, StrapComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (LifeStage(uid) > EntityLifeStage.MapInitialized)
|
||||
return;
|
||||
|
||||
StrapRemoveAll(component);
|
||||
}
|
||||
|
||||
private void OnStrapInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args)
|
||||
{
|
||||
// If someone is attempting to put this item inside of a backpack, ensure that it has no entities strapped to it.
|
||||
if (HasComp<SharedStorageComponent>(args.Container.Owner) && component.BuckledEntities.Count != 0)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnStrapInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
ToggleBuckle(args.User, args.User, uid);
|
||||
}
|
||||
|
||||
private void AddStrapVerbs(EntityUid uid, StrapComponent strap, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (args.Hands == null || !args.CanAccess || !args.CanInteract || !strap.Enabled)
|
||||
return;
|
||||
|
||||
// Note that for whatever bloody reason, buckle component has its own interaction range. Additionally, this
|
||||
// range can be set per-component, so we have to check a modified InRangeUnobstructed for every verb.
|
||||
|
||||
// Add unstrap verbs for every strapped entity.
|
||||
foreach (var entity in strap.BuckledEntities)
|
||||
{
|
||||
var buckledComp = Comp<BuckleComponent>(entity);
|
||||
|
||||
if (!_interactions.InRangeUnobstructed(args.User, args.Target, range: buckledComp.Range))
|
||||
continue;
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => TryUnbuckle(entity, args.User, buckle: buckledComp),
|
||||
Category = VerbCategory.Unbuckle
|
||||
};
|
||||
|
||||
if (entity == args.User)
|
||||
verb.Text = Loc.GetString("verb-self-target-pronoun");
|
||||
else
|
||||
verb.Text = Comp<MetaDataComponent>(entity).EntityName;
|
||||
|
||||
// In the event that you have more than once entity with the same name strapped to the same object,
|
||||
// these two verbs will be identical according to Verb.CompareTo, and only one with actually be added to
|
||||
// the verb list. However this should rarely ever be a problem. If it ever is, it could be fixed by
|
||||
// appending an integer to verb.Text to distinguish the verbs.
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// Add a verb to buckle the user.
|
||||
if (TryComp(args.User, out BuckleComponent? buckle) &&
|
||||
buckle.BuckledTo != strap &&
|
||||
args.User != strap.Owner &&
|
||||
StrapHasSpace(uid, buckle, strap) &&
|
||||
_interactions.InRangeUnobstructed(args.User, args.Target, range: buckle.Range))
|
||||
{
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => TryBuckle(args.User, args.User, args.Target, buckle),
|
||||
Category = VerbCategory.Buckle,
|
||||
Text = Loc.GetString("verb-self-target-pronoun")
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// If the user is currently holding/pulling an entity that can be buckled, add a verb for that.
|
||||
if (args.Using is {Valid: true} @using &&
|
||||
TryComp(@using, out BuckleComponent? usingBuckle) &&
|
||||
StrapHasSpace(uid, usingBuckle, strap) &&
|
||||
_interactions.InRangeUnobstructed(@using, args.Target, range: usingBuckle.Range))
|
||||
{
|
||||
// Check that the entity is unobstructed from the target (ignoring the user).
|
||||
bool Ignored(EntityUid entity) => entity == args.User || entity == args.Target || entity == @using;
|
||||
if (!_interactions.InRangeUnobstructed(@using, args.Target, usingBuckle.Range, predicate: Ignored))
|
||||
return;
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => TryBuckle(@using, args.User, args.Target, usingBuckle),
|
||||
Category = VerbCategory.Buckle,
|
||||
Text = Comp<MetaDataComponent>(@using).EntityName,
|
||||
// just a held object, the user is probably just trying to sit down.
|
||||
// If the used entity is a person being pulled, prioritize this verb. Conversely, if it is
|
||||
Priority = HasComp<ActorComponent>(@using) ? 1 : -1
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
|
||||
private void StrapRemoveAll(StrapComponent strap)
|
||||
{
|
||||
foreach (var entity in strap.BuckledEntities.ToArray())
|
||||
{
|
||||
TryUnbuckle(entity, entity, true);
|
||||
}
|
||||
|
||||
strap.BuckledEntities.Clear();
|
||||
strap.OccupiedSize = 0;
|
||||
Dirty(strap);
|
||||
}
|
||||
|
||||
private void OnStrapDragDrop(EntityUid uid, StrapComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
if (!StrapCanDragDropOn(uid, args.User, uid, args.Dragged, component))
|
||||
return;
|
||||
|
||||
args.Handled = TryBuckle(args.Dragged, args.User, uid);
|
||||
}
|
||||
|
||||
private bool StrapHasSpace(EntityUid strapId, BuckleComponent buckle, StrapComponent? strap = null)
|
||||
{
|
||||
if (!Resolve(strapId, ref strap, false))
|
||||
return false;
|
||||
|
||||
return strap.OccupiedSize + buckle.Size <= strap.Size;
|
||||
}
|
||||
|
||||
private bool StrapTryAdd(EntityUid strapId, BuckleComponent buckle, bool force = false, StrapComponent? strap = null)
|
||||
{
|
||||
if (!Resolve(strapId, ref strap, false) ||
|
||||
!strap.Enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!force && !StrapHasSpace(strapId, buckle, strap))
|
||||
return false;
|
||||
|
||||
if (!strap.BuckledEntities.Add(buckle.Owner))
|
||||
return false;
|
||||
|
||||
strap.OccupiedSize += buckle.Size;
|
||||
|
||||
_appearance.SetData(buckle.Owner, StrapVisuals.RotationAngle, strap.Rotation);
|
||||
|
||||
_appearance.SetData(strap.Owner, StrapVisuals.State, true);
|
||||
|
||||
Dirty(strap);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void StrapSetEnabled(EntityUid strapId, bool enabled, StrapComponent? strap = null)
|
||||
{
|
||||
if (!Resolve(strapId, ref strap, false) ||
|
||||
strap.Enabled == enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
strap.Enabled = enabled;
|
||||
|
||||
if (!enabled)
|
||||
StrapRemoveAll(strap);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,7 @@
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Pulling;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Buckle.Systems;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed partial class BuckleSystem : SharedBuckleSystem
|
||||
public sealed class BuckleSystem : SharedBuckleSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly ContainerSystem _containers = default!;
|
||||
[Dependency] private readonly InteractionSystem _interactions = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly PopupSystem _popups = default!;
|
||||
[Dependency] private readonly PullingSystem _pulling = default!;
|
||||
[Dependency] private readonly Shared.Standing.StandingStateSystem _standing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
UpdatesAfter.Add(typeof(InteractionSystem));
|
||||
UpdatesAfter.Add(typeof(InputSystem));
|
||||
|
||||
InitializeBuckle();
|
||||
InitializeStrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
Climb(uid, uid, uid, climbable, true, component);
|
||||
}
|
||||
|
||||
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, BuckleChangeEvent args)
|
||||
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, ref BuckleChangeEvent args)
|
||||
{
|
||||
if (!args.Buckling)
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Server.Disease.Cures
|
||||
public override bool Cure(DiseaseEffectArgs args)
|
||||
{
|
||||
if (!args.EntityManager.TryGetComponent<BuckleComponent>(args.DiseasedEntity, out var buckle) ||
|
||||
!args.EntityManager.HasComponent<HealOnBuckleComponent>(buckle.BuckledTo?.Owner))
|
||||
!args.EntityManager.HasComponent<HealOnBuckleComponent>(buckle.BuckledTo))
|
||||
return false;
|
||||
|
||||
var ticks = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Foldable;
|
||||
using Content.Shared.Verbs;
|
||||
@@ -13,7 +13,7 @@ namespace Content.Server.Foldable
|
||||
[UsedImplicitly]
|
||||
public sealed class FoldableSystem : SharedFoldableSystem
|
||||
{
|
||||
[Dependency] private readonly BuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
public override void Initialize()
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Light;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Light.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This is simplified version of <see cref="HandheldLightComponent"/>.
|
||||
/// It doesn't consume any power and can be toggle only by verb.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class UnpoweredFlashlightComponent : Component
|
||||
{
|
||||
[DataField("toggleFlashlightSound")]
|
||||
public SoundSpecifier ToggleSound = new SoundPathSpecifier("/Audio/Items/flashlight_pda.ogg");
|
||||
|
||||
[ViewVariables] public bool LightOn = false;
|
||||
|
||||
[DataField("toggleAction", required: true)]
|
||||
public InstantAction ToggleAction = new();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Light.Events;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Shared.Buckle;
|
||||
|
||||
namespace Content.Server.NPC.HTN.Preconditions;
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace Content.Server.NPC.HTN.Preconditions;
|
||||
/// </summary>
|
||||
public sealed class BuckledPrecondition : HTNPrecondition
|
||||
{
|
||||
private BuckleSystem _buckle = default!;
|
||||
private SharedBuckleSystem _buckle = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("isBuckled")] public bool IsBuckled = true;
|
||||
|
||||
public override void Initialize(IEntitySystemManager sysManager)
|
||||
{
|
||||
base.Initialize(sysManager);
|
||||
_buckle = sysManager.GetEntitySystem<BuckleSystem>();
|
||||
_buckle = sysManager.GetEntitySystem<SharedBuckleSystem>();
|
||||
}
|
||||
|
||||
public override bool IsMet(NPCBlackboard blackboard)
|
||||
|
||||
@@ -15,6 +15,7 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Traitor;
|
||||
using Content.Shared.Light.Component;
|
||||
|
||||
namespace Content.Server.PDA
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Mind.Commands;
|
||||
@@ -7,6 +6,7 @@ using Content.Server.Mind.Components;
|
||||
using Content.Server.Polymorph.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Polymorph.Systems
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
[Dependency] private readonly BuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly ContainerSystem _container = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -37,7 +36,7 @@ namespace Content.Server.Toilet
|
||||
SubscribeLocalEvent<ToiletComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<ToiletComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<ToiletComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand, new []{typeof(BuckleSystem)});
|
||||
SubscribeLocalEvent<ToiletComponent, InteractHandEvent>(OnInteractHand, new []{typeof(SharedBuckleSystem)});
|
||||
SubscribeLocalEvent<ToiletComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<ToiletComponent, SuicideEvent>(OnSuicide);
|
||||
SubscribeLocalEvent<ToiletComponent, ToiletPryDoAfterEvent>(OnToiletPried);
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
using Content.Server.Standing;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
{
|
||||
public sealed partial class VehicleSystem
|
||||
{
|
||||
private void InitializeRider()
|
||||
{
|
||||
SubscribeLocalEvent<RiderComponent, ComponentGetState>(OnRiderGetState);
|
||||
SubscribeLocalEvent<RiderComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||
SubscribeLocalEvent<RiderComponent, FellDownEvent>(OnFallDown);
|
||||
SubscribeLocalEvent<RiderComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
}
|
||||
|
||||
private void OnRiderGetState(EntityUid uid, RiderComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new RiderComponentState()
|
||||
{
|
||||
Entity = component.Vehicle,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they press q / drop the virtual item
|
||||
/// </summary>
|
||||
private void OnVirtualItemDeleted(EntityUid uid, RiderComponent component, VirtualItemDeletedEvent args)
|
||||
{
|
||||
if (args.BlockingEntity == component.Vehicle)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they get stunned
|
||||
/// </summary>
|
||||
private void OnFallDown(EntityUid uid, RiderComponent rider, FellDownEvent args)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kick the rider off the vehicle if they go into crit or die.
|
||||
/// </summary>
|
||||
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args)
|
||||
{
|
||||
if (args.NewMobState is MobState.Critical or MobState.Dead)
|
||||
{
|
||||
UnbuckleFromVehicle(uid);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbuckleFromVehicle(EntityUid uid)
|
||||
{
|
||||
_buckle.TryUnbuckle(uid, uid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +1,7 @@
|
||||
using Content.Server.Buckle.Systems;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Vehicle;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Vehicle
|
||||
namespace Content.Server.Vehicle;
|
||||
|
||||
public sealed class VehicleSystem : SharedVehicleSystem
|
||||
{
|
||||
public sealed partial class VehicleSystem : SharedVehicleSystem
|
||||
{
|
||||
[Dependency] private readonly BuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly HandVirtualItemSystem _virtualItemSystem = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedJointSystem _joints = default!;
|
||||
[Dependency] private readonly SharedMoverController _mover = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
InitializeRider();
|
||||
|
||||
SubscribeLocalEvent<VehicleComponent, HonkActionEvent>(OnHonk);
|
||||
SubscribeLocalEvent<VehicleComponent, BuckleChangeEvent>(OnBuckleChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This fires when the rider presses the honk action
|
||||
/// </summary>
|
||||
private void OnHonk(EntityUid uid, VehicleComponent vehicle, HonkActionEvent args)
|
||||
{
|
||||
if (args.Handled || vehicle.HornSound == null)
|
||||
return;
|
||||
|
||||
// TODO: Need audio refactor maybe, just some way to null it when the stream is over.
|
||||
// For now better to just not loop to keep the code much cleaner.
|
||||
vehicle.HonkPlayingStream?.Stop();
|
||||
vehicle.HonkPlayingStream = SoundSystem.Play(vehicle.HornSound.GetSound(), Filter.Pvs(uid), uid, vehicle.HornSound.Params);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This just controls whether the wheels are turning.
|
||||
/// </summary>
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var (vehicle, mover) in EntityQuery<VehicleComponent, InputMoverComponent>())
|
||||
{
|
||||
if (_mover.GetVelocityInput(mover).Sprinting == Vector2.Zero)
|
||||
{
|
||||
UpdateAutoAnimate(vehicle.Owner, false);
|
||||
continue;
|
||||
}
|
||||
UpdateAutoAnimate(vehicle.Owner, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Give the user the rider component if they're buckling to the vehicle,
|
||||
/// otherwise remove it.
|
||||
/// </summary>
|
||||
private void OnBuckleChange(EntityUid uid, VehicleComponent component, BuckleChangeEvent args)
|
||||
{
|
||||
// Add Rider
|
||||
if (args.Buckling)
|
||||
{
|
||||
// Add a virtual item to rider's hand, unbuckle if we can't.
|
||||
if (!_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.BuckledEntity))
|
||||
{
|
||||
UnbuckleFromVehicle(args.BuckledEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the rider and vehicle with each other
|
||||
EnsureComp<InputMoverComponent>(uid);
|
||||
var rider = EnsureComp<RiderComponent>(args.BuckledEntity);
|
||||
component.Rider = args.BuckledEntity;
|
||||
|
||||
var relay = EnsureComp<RelayInputMoverComponent>(args.BuckledEntity);
|
||||
_mover.SetRelay(args.BuckledEntity, uid, relay);
|
||||
rider.Vehicle = uid;
|
||||
|
||||
// Update appearance stuff, add actions
|
||||
UpdateBuckleOffset(Transform(uid), component);
|
||||
if (TryComp<InputMoverComponent>(uid, out var mover))
|
||||
UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component, mover.RelativeRotation.Degrees));
|
||||
|
||||
if (TryComp<ActionsComponent>(args.BuckledEntity, out var actions) && TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
||||
{
|
||||
_actionsSystem.AddAction(args.BuckledEntity, flashlight.ToggleAction, uid, actions);
|
||||
}
|
||||
|
||||
if (component.HornSound != null)
|
||||
{
|
||||
_actionsSystem.AddAction(args.BuckledEntity, component.HornAction, uid, actions);
|
||||
}
|
||||
|
||||
_joints.ClearJoints(args.BuckledEntity);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove rider
|
||||
|
||||
// Clean up actions and virtual items
|
||||
_actionsSystem.RemoveProvidedActions(args.BuckledEntity, uid);
|
||||
_virtualItemSystem.DeleteInHandsMatching(args.BuckledEntity, uid);
|
||||
|
||||
// Entity is no longer riding
|
||||
RemComp<RiderComponent>(args.BuckledEntity);
|
||||
RemComp<RelayInputMoverComponent>(args.BuckledEntity);
|
||||
|
||||
// Reset component
|
||||
component.Rider = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user