/// <summary> /// For now pilots just interact with the console and can start piloting with wasd. /// </summary> private void HandleConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, ActivateInWorldEvent args) { if (!args.User.HasTag("CanPilot")) { return; } var pilotComponent = args.User.EnsureComponent <PilotComponent>(); if (!component.Enabled) { args.User.PopupMessage($"Console is not powered."); return; } args.Handled = true; var console = pilotComponent.Console; if (console != null) { RemovePilot(pilotComponent); if (console != component) { return; } } AddPilot(args.User, component); }
public void ClearPilots(ShuttleConsoleComponent component) { foreach (var pilot in component.SubscribedPilots) { RemovePilot(pilot); } }
public void ClearPilots(ShuttleConsoleComponent component) { while (component.SubscribedPilots.TryGetValue(0, out var pilot)) { RemovePilot(pilot); } }
/// <summary> /// Console requires power to operate. /// </summary> private void HandlePowerChange(EntityUid uid, ShuttleConsoleComponent component, PowerChangedEvent args) { if (!args.Powered) { component.Enabled = false; ClearPilots(component); } else { component.Enabled = true; } }
public void AddPilot(IEntity entity, ShuttleConsoleComponent component) { if (!Get <ActionBlockerSystem>().CanInteract(entity) || !entity.TryGetComponent(out PilotComponent? pilotComponent) || component.SubscribedPilots.Contains(pilotComponent)) { return; } component.SubscribedPilots.Add(pilotComponent); if (entity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) { alertsComponent.ShowAlert(AlertType.PilotingShuttle); } entity.PopupMessage(Loc.GetString("shuttle-pilot-start")); pilotComponent.Console = component; pilotComponent.Dirty(); }
private void HandleConsoleShutdown(EntityUid uid, ShuttleConsoleComponent component, ComponentShutdown args) { ClearPilots(component); }