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

@@ -16,33 +16,6 @@ namespace Content.Server.Actions
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActionsComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<ActionsComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ActionsComponent, MetaFlagRemoveAttemptEvent>(OnMetaFlagRemoval);
}
private void OnMetaFlagRemoval(EntityUid uid, ActionsComponent component, ref MetaFlagRemoveAttemptEvent args)
{
if (component.LifeStage == ComponentLifeStage.Running)
args.ToRemove &= ~MetaDataFlags.EntitySpecific;
}
private void OnStartup(EntityUid uid, ActionsComponent component, ComponentStartup args)
{
_metaSystem.AddFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args)
{
_metaSystem.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args)
{
// need to send state to new player.
Dirty(component);
}
protected override bool PerformBasicActions(EntityUid user, ActionType action)

View File

@@ -39,32 +39,6 @@ namespace Content.Server.Flash
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
SubscribeLocalEvent<FlashImmunityComponent, FlashAttemptEvent>(OnFlashImmunityFlashAttempt);
SubscribeLocalEvent<FlashableComponent, ComponentStartup>(OnFlashableStartup);
SubscribeLocalEvent<FlashableComponent, ComponentShutdown>(OnFlashableShutdown);
SubscribeLocalEvent<FlashableComponent, MetaFlagRemoveAttemptEvent>(OnMetaFlagRemoval);
SubscribeLocalEvent<FlashableComponent, PlayerAttachedEvent>(OnPlayerAttached);
}
private void OnPlayerAttached(EntityUid uid, FlashableComponent component, PlayerAttachedEvent args)
{
Dirty(component);
}
private void OnMetaFlagRemoval(EntityUid uid, FlashableComponent component, ref MetaFlagRemoveAttemptEvent args)
{
if (component.LifeStage == ComponentLifeStage.Running)
args.ToRemove &= ~MetaDataFlags.EntitySpecific;
}
private void OnFlashableStartup(EntityUid uid, FlashableComponent component, ComponentStartup args)
{
_metaSystem.AddFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnFlashableShutdown(EntityUid uid, FlashableComponent component, ComponentShutdown args)
{
_metaSystem.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
}
private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)

View File

@@ -46,13 +46,6 @@ namespace Content.Server.Shuttles.Systems
SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove);
SubscribeLocalEvent<PilotComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<PilotComponent, ComponentGetStateAttemptEvent>(OnGetStateAttempt);
}
private void OnGetStateAttempt(EntityUid uid, PilotComponent component, ref ComponentGetStateAttemptEvent args)
{
if (args.Cancelled || !TryComp<ActorComponent>(uid, out var actor) || actor.PlayerSession != args.Player)
args.Cancelled = true;
}
private void OnDestinationMessage(EntityUid uid, ShuttleConsoleComponent component, ShuttleConsoleDestinationMessage args)

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()