Content changes for session specific entity states (#11235)

This commit is contained in:
Leon Friedrich
2022-09-14 21:40:05 +12:00
committed by GitHub
parent 7cd0677708
commit 2908cd994c
12 changed files with 10 additions and 118 deletions

View File

@@ -11,38 +11,12 @@ namespace Content.Server.Vehicle
{
private void InitializeRider()
{
SubscribeLocalEvent<RiderComponent, ComponentStartup>(OnRiderStartup);
SubscribeLocalEvent<RiderComponent, ComponentShutdown>(OnRiderShutdown);
SubscribeLocalEvent<RiderComponent, MetaFlagRemoveAttemptEvent>(OnRiderRemoval);
SubscribeLocalEvent<RiderComponent, ComponentGetState>(OnRiderGetState);
SubscribeLocalEvent<RiderComponent, ComponentGetStateAttemptEvent>(OnRiderGetStateAttempt);
SubscribeLocalEvent<RiderComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
SubscribeLocalEvent<RiderComponent, FellDownEvent>(OnFallDown);
SubscribeLocalEvent<RiderComponent, MobStateChangedEvent>(OnMobStateChanged);
}
private void OnRiderRemoval(EntityUid uid, RiderComponent component, ref MetaFlagRemoveAttemptEvent args)
{
if ((args.ToRemove & MetaDataFlags.EntitySpecific) != 0x0)
args.ToRemove = MetaDataFlags.None;
}
private void OnRiderStartup(EntityUid uid, RiderComponent component, ComponentStartup args)
{
_metadata.AddFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
{
_metadata.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnRiderGetStateAttempt(EntityUid uid, RiderComponent component, ref ComponentGetStateAttemptEvent args)
{
if (uid != args.Player.AttachedEntity)
args.Cancelled = true;
}
private void OnRiderGetState(EntityUid uid, RiderComponent component, ref ComponentGetState args)
{
args.State = new RiderComponentState()