private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args) { if (args.Current is not PilotComponentState state) { return; } var console = state.Console.GetValueOrDefault(); if (!console.IsValid()) { component.Console = null; _input.Contexts.SetActiveContext("human"); return; } if (!TryComp <ShuttleConsoleComponent>(console, out var shuttleConsoleComponent)) { Logger.Warning($"Unable to set Helmsman console to {console}"); return; } component.Console = shuttleConsoleComponent; ActionBlockerSystem.UpdateCanMove(uid); _input.Contexts.SetActiveContext("shuttle"); }
public void RemovePilot(PilotComponent pilotComponent) { var console = pilotComponent.Console; if (console is not ShuttleConsoleComponent helmsman) { return; } pilotComponent.Console = null; if (!helmsman.SubscribedPilots.Remove(pilotComponent)) { return; } if (pilotComponent.Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent)) { alertsComponent.ClearAlert(AlertType.PilotingShuttle); } pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end")); // TODO: RemoveComponent<T> is cooked and doesn't sync to client so this f***s up movement prediction. // ComponentManager.RemoveComponent<PilotComponent>(pilotComponent.Owner.Uid); pilotComponent.Console = null; pilotComponent.Dirty(); }
public void RemovePilot(PilotComponent pilotComponent) { var console = pilotComponent.Console; if (console is not ShuttleConsoleComponent helmsman) { return; } pilotComponent.Console = null; pilotComponent.Position = null; if (TryComp <SharedEyeComponent>(pilotComponent.Owner, out var eye)) { eye.Zoom = new(1.0f, 1.0f); } if (!helmsman.SubscribedPilots.Remove(pilotComponent)) { return; } _alertsSystem.ClearAlert(pilotComponent.Owner, AlertType.PilotingShuttle); pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end")); if (pilotComponent.LifeStage < ComponentLifeStage.Stopping) { EntityManager.RemoveComponent <PilotComponent>(pilotComponent.Owner); } }
public void RemovePilot(PilotComponent pilotComponent) { var console = pilotComponent.Console; if (console is not ShuttleConsoleComponent helmsman) { return; } pilotComponent.Console = null; pilotComponent.Position = null; if (!helmsman.SubscribedPilots.Remove(pilotComponent)) { return; } if (EntityManager.TryGetComponent(pilotComponent.Owner, out ServerAlertsComponent? alertsComponent)) { alertsComponent.ClearAlert(AlertType.PilotingShuttle); } pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end")); if (pilotComponent.LifeStage < ComponentLifeStage.Stopping) { EntityManager.RemoveComponent <PilotComponent>(pilotComponent.Owner); } }
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; } }
/// <summary> /// If pilot is moved then we'll stop them from piloting. /// </summary> private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args) { if (component.Console == null) { return; } RemovePilot(component); }
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) { base.HandlePilotShutdown(uid, component, args); if (_playerManager.LocalPlayer?.ControlledEntity != uid) { return; } _input.Contexts.SetActiveContext("human"); }
private void HandleMovementBlock(EntityUid uid, PilotComponent component, UpdateCanMoveEvent args) { if (component.LifeStage > ComponentLifeStage.Running) { return; } if (component.Console == null) { return; } args.Cancel(); }
/// <summary> /// If pilot is moved then we'll stop them from piloting. /// </summary> private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args) { if (component.Console == null || component.Position == null) { DebugTools.Assert(component.Position == null && component.Console == null); EntityManager.RemoveComponent <PilotComponent>(uid); return; } if (args.NewPosition.TryDistance(EntityManager, component.Position.Value, out var distance) && distance < PilotComponent.BreakDistance) { return; } RemovePilot(component); }
private void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) { RemovePilot(component); }
private void OnStartup(EntityUid uid, PilotComponent component, ComponentStartup args) { ActionBlockerSystem.UpdateCanMove(uid); }
protected virtual void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) { ActionBlockerSystem.UpdateCanMove(uid); }
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) { base.HandlePilotShutdown(uid, component, args); RemovePilot(component); }
private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args) { args.State = new PilotComponentState(component.Console?.Owner); }