if (PausedMap != null)
_transform.SetParent(uid, targetTransformComp, PausedMap.Value);
+ // Raise an event to inform anything that wants to know about the entity swap
+ var ev = new PolymorphedEvent(uid, child, false);
+ RaiseLocalEvent(uid, ref ev);
+
return child;
}
// if an item polymorph was picked up, put it back down after reverting
_transform.AttachToGridOrMap(parent, parentXform);
+ // Raise an event to inform anything that wants to know about the entity swap
+ var ev = new PolymorphedEvent(uid, parent, true);
+ RaiseLocalEvent(uid, ref ev);
+
_popup.PopupEntity(Loc.GetString("polymorph-revert-popup-generic",
("parent", Identity.Entity(uid, EntityManager)),
("child", Identity.Entity(parent, EntityManager))),
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;
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<FollowedComponent, PolymorphedEvent>(OnFollowedPolymorphed);
SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
}
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)
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>
RaiseLocalEvent(follower, followerEv);
RaiseLocalEvent(entity, entityEv);
Dirty(entity, followedComp);
+ Dirty(follower, followerComp);
}
/// <summary>
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);