コード例 #1
0
        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");
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
        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");
        }
コード例 #8
0
        private void HandleMovementBlock(EntityUid uid, PilotComponent component, UpdateCanMoveEvent args)
        {
            if (component.LifeStage > ComponentLifeStage.Running)
            {
                return;
            }

            if (component.Console == null)
            {
                return;
            }
            args.Cancel();
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
 private void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
 {
     RemovePilot(component);
 }
コード例 #11
0
 private void OnStartup(EntityUid uid, PilotComponent component, ComponentStartup args)
 {
     ActionBlockerSystem.UpdateCanMove(uid);
 }
コード例 #12
0
 protected virtual void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
 {
     ActionBlockerSystem.UpdateCanMove(uid);
 }
コード例 #13
0
 protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
 {
     base.HandlePilotShutdown(uid, component, args);
     RemovePilot(component);
 }
コード例 #14
0
 private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args)
 {
     args.State = new PilotComponentState(component.Console?.Owner);
 }