Merge branch 'master' of https://github.com/space-wizards/space-station-14 into map-load-refactor

This commit is contained in:
ElectroJr
2025-02-16 16:52:51 +13:00
1624 changed files with 385006 additions and 263837 deletions

View File

@@ -7,6 +7,7 @@ using Content.Shared.Ghost;
using Content.Shared.Hands;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Polymorph;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
@@ -39,11 +40,13 @@ public sealed class FollowerSystem : EntitySystem
SubscribeLocalEvent<FollowerComponent, MoveInputEvent>(OnFollowerMove);
SubscribeLocalEvent<FollowerComponent, PullStartedMessage>(OnPullStarted);
SubscribeLocalEvent<FollowerComponent, EntityTerminatingEvent>(OnFollowerTerminating);
SubscribeLocalEvent<FollowerComponent, AfterAutoHandleStateEvent>(OnAfterHandleState);
SubscribeLocalEvent<FollowedComponent, ComponentGetStateAttemptEvent>(OnFollowedAttempt);
SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
SubscribeLocalEvent<BeforeSerializationEvent>(OnBeforeSave);
SubscribeLocalEvent<FollowedComponent, PolymorphedEvent>(OnFollowedPolymorphed);
}
private void OnFollowedAttempt(Entity<FollowedComponent> ent, ref ComponentGetStateAttemptEvent args)
@@ -142,6 +145,11 @@ public sealed class FollowerSystem : EntitySystem
StopFollowingEntity(uid, component.Following, deparent: false);
}
private void OnAfterHandleState(Entity<FollowerComponent> entity, ref AfterAutoHandleStateEvent args)
{
StartFollowingEntity(entity, entity.Comp.Following);
}
// Since we parent our observer to the followed entity, we need to detach
// before they get deleted so that we don't get recursively deleted too.
private void OnFollowedTerminating(EntityUid uid, FollowedComponent component, ref EntityTerminatingEvent args)
@@ -149,6 +157,15 @@ public sealed class FollowerSystem : EntitySystem
StopAllFollowers(uid, component);
}
private void OnFollowedPolymorphed(Entity<FollowedComponent> entity, ref PolymorphedEvent args)
{
foreach (var follower in entity.Comp.Following)
{
// Stop following the target's old entity and start following the new one
StartFollowingEntity(follower, args.NewEntity);
}
}
/// <summary>
/// Makes an entity follow another entity, by parenting to it.
/// </summary>
@@ -209,6 +226,7 @@ public sealed class FollowerSystem : EntitySystem
RaiseLocalEvent(follower, followerEv);
RaiseLocalEvent(entity, entityEv);
Dirty(entity, followedComp);
Dirty(follower, followerComp);
}
/// <summary>
@@ -220,7 +238,7 @@ public sealed class FollowerSystem : EntitySystem
if (!Resolve(target, ref followed, false))
return;
if (!HasComp<FollowerComponent>(uid))
if (!TryComp<FollowerComponent>(uid, out var followerComp) || followerComp.Following != target)
return;
followed.Following.Remove(uid);