Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 4
0
        /// <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;
            }
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
 private void HandleConsoleShutdown(EntityUid uid, ShuttleConsoleComponent component, ComponentShutdown args)
 {
     ClearPilots(component);
 }