Example #1
0
 private void Assignations()
 {
     _noDestroy  = FindObjectOfType <NoDestroy>();
     _control    = FindObjectOfType <FlightControl>();
     _sound      = GetComponent <SoundManager>();
     _transition = FindObjectOfType <TransitionControl>();
 }
Example #2
0
        override public void drive(FlightControl control)
        {
            _drive(control);

            control.yaw   *= _sensetivity.value;
            control.pitch *= _sensetivity.value;
            control.roll  *= _sensetivity.value;
        }
Example #3
0
 private void Assignations()
 {
     _noDestroy = FindObjectOfType <NoDestroy>();
     _musicAu   = gameObject.AddComponent <AudioSource>();
     _soundsAu  = gameObject.AddComponent <AudioSource>();
     _uiManager = FindObjectOfType <UIManager>();
     _control   = FindObjectOfType <FlightControl>();
 }
Example #4
0
 public void UpdateFlightControl(Vessel vessel)
 {
     control = GetControllerByVessel(vessel);
     if (steeringManager != null)
     {
         steeringManager = SteeringManagerProvider.SwapInstance(shared, steeringManager);
         steeringManager.Update(vessel);
     }
 }
Example #5
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         FlightControl fc = collision.gameObject.GetComponent <FlightControl>();
         fc.getPowerUp(0, 100);
     }
     Destroy(this.gameObject);
 }
Example #6
0
 public static FlightControl GetControllerByVessel(Vessel target)
 {
     FlightControl flightControl;
     if (!flightControls.TryGetValue(target.rootPart.flightID, out flightControl))
     {
         flightControl = new FlightControl(target);
         flightControls.Add(target.rootPart.flightID, flightControl);
     }
     return flightControl;
 }
Example #7
0
            public FlightCtrlParam(string name, SharedObjects sharedObjects)
            {
                this.name    = name;
                this.control = GetControllerByVessel(sharedObjects.Vessel);
                this.binding = sharedObjects.BindingMgr;
                Enabled      = false;
                value        = null;

                HookEvents();
            }
Example #8
0
 private void OnCollisionEnter(Collision collision)
 {
     Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
     print("Hit");
     if (collision.gameObject.tag == "Player")
     {
         FlightControl fc = collision.gameObject.GetComponent <FlightControl>();
         fc.takeDamage(dmg);
     }
     Destroy(this.gameObject);
 }
Example #9
0
        public static FlightControl GetControllerByVessel(Vessel target)
        {
            FlightControl flightControl;

            if (!flightControls.TryGetValue(target.rootPart.flightID, out flightControl))
            {
                flightControl = new FlightControl(target);
                flightControls.Add(target.rootPart.flightID, flightControl);
            }
            return(flightControl);
        }
Example #10
0
 private void BuildViewModel_FlightBegun(object sender, EventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         _flightViewModel            = new FlightViewModel(_client, _playerListViewModel, _buildViewModel.Ship);
         _flightViewModel.GameEnded += FlightViewModel_GameEnded;
         FlightControl flightControl = new FlightControl
         {
             DataContext = _flightViewModel
         };
         _mainWindow.Content = flightControl;
     });
 }
Example #11
0
 private void OnCollisionEnter(Collision collision)
 {
     Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
     print("Hit");
     audioSource.Play();
     if (isBig)
     {
         Instantiate(smallAsteroid, gameObject.transform.position, Quaternion.Euler(45, 0, 0));
     }
     if (collision.gameObject.tag == "Player")
     {
         FlightControl fc = collision.gameObject.GetComponent <FlightControl>();
         fc.takeDamage(dmg);
     }
     Destroy(this.gameObject);
 }
Example #12
0
        /// <summary>
        /// After a decouple or part explosion, it's possible for this vessel to
        /// still have an assigned flight control parameter that is coming from
        /// a kOS core that is no longer on this vessel but is instead on the newly
        /// branched vessel we left behind.  If so, that parameter needs to be
        /// removed from this vessel.  The new kOSVesselModule will take care of
        /// making a new parameter on the new vessel, but this kOSVesselModule needs
        /// to detach it from this one.
        /// </summary>
        private void ResetPhysicallyDetachedParameters()
        {
            List <string> removeKeys = new List <string>();

            foreach (string key in flightControlParameters.Keys)
            {
                IFlightControlParameter p = flightControlParameters[key];
                if (p.GetShared() != null && p.GetShared().Vessel != null && Vessel != null &&
                    p.GetShared().Vessel.id != Vessel.id)
                {
                    removeKeys.Add(key);
                }
            }
            foreach (string key in removeKeys)
            {
                SafeHouse.Logger.SuperVerbose(string.Format(
                                                  "kOSVesselModule: re-defaulting parameter \"{0}\" because it's on a detached part of the vessel.", key));
                RemoveFlightControlParameter(key);
                IFlightControlParameter p = null;
                if (key.Equals("steering"))
                {
                    p = new SteeringManager(Vessel);
                }
                else if (key.Equals("throttle"))
                {
                    p = new ThrottleManager(Vessel);
                }
                else if (key.Equals("wheelsteering"))
                {
                    p = new WheelSteeringManager(Vessel);
                }
                else if (key.Equals("wheelthrottle"))
                {
                    p = new WheelThrottleManager(Vessel);
                }
                else if (key.Equals("flightcontrol"))
                {
                    p = new FlightControl(Vessel);
                }

                if (p != null)
                {
                    AddFlightControlParameter(key, p);
                }
            }
            foundWrongVesselAutopilot = false;
        }
Example #13
0
        private void _drive(FlightControl c)
        {
            double rollDelta = Math.Abs(vessel.rotation.roll - _lastRoll);

            if (rollDelta > Math.PI)
            {
                rollDelta = 2 * Math.PI - rollDelta;
            }
            if (rollDelta > Math.PI / 36)
            {
                _controller.reset();
                _lastRoll = vessel.rotation.roll;
            }

            Quaternion delta = vessel.rotation.inverse * target;

            Vector3 err = new Vector3((delta.pitch > Math.PI) ? (delta.pitch - 2 * Math.PI) : delta.pitch,
                                      (delta.yaw > Math.PI) ? (delta.yaw - 2 * Math.PI) : delta.yaw,
                                      (delta.roll > Math.PI) ? (delta.roll - 2 * Math.PI) : delta.roll);

            err = new Vector3(controlPitch == Control.KillRotation ? 0 : err.x,
                              controlYaw == Control.KillRotation ? 0 : err.y,
                              controlRoll == Control.KillRotation ? 0 : err.z);

            Vector3 torque = vessel.body.torque;

            Vector3 inertia = vessel.body.angularMomentum.sign *
                              vessel.body.angularMomentum * vessel.body.angularMomentum *
                              (torque * vessel.body.momentumOfInertia).invert;

            err += inertia;
            err *= vessel.body.momentumOfInertia * torque.invert;

            Vector3 act = _controller.compute(err, vessel.mainBody.universe.fixedDeltaTime);

            double precision  = (Math.Min(vessel.body.torque.x, vessel.body.torque.y) * 20.0 / vessel.body.momentumOfInertia.magnitude).clamp(0.5, 10);
            double driveLimit = (err.magnitude * driveFactor / precision).clamp(0, 1);

            act = act.clamp(-driveLimit, driveLimit);

            act = _act + (act - _act) * (vessel.mainBody.universe.fixedDeltaTime / Tf);

            setControls(act, c, driveLimit);

            _act = new Vector3(c.pitch, c.yaw, c.roll);
        }
Example #14
0
            public FlightCtrlParam(string name, SharedObjects sharedObjects)
            {
                this.name = name;
                shared    = sharedObjects;
                control   = GetControllerByVessel(sharedObjects.Vessel);

                binding = sharedObjects.BindingMgr;
                Enabled = false;
                value   = null;

                if (string.Equals(name, "steering", StringComparison.CurrentCultureIgnoreCase))
                {
                    steeringManager = SteeringManagerProvider.GetInstance(sharedObjects);
                }

                HookEvents();
            }
Example #15
0
        public Form1()
        {
            InitializeComponent();

            String filename = "";

            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"C:\",
                Title            = "Browse Text Files",

                CheckFileExists = true,
                CheckPathExists = true,


                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filename = openFileDialog1.FileName;
            }



            temp = new FlightControl();

            gmap.MapProvider             = GMap.NET.MapProviders.BingMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gmap.Position   = new GMap.NET.PointLatLng(37.0902, -95.7129);
            gmap.ShowCenter = false;


            flightList = temp.ReadDataBase(filename);


            dgvAirView.DataSource = flightList;
        }
Example #16
0
 void Setup()
 {
     flightController = GetComponent <FlightControl> ();
     playerHealth     = GetComponent <PlayerHealth> ();
 }
Example #17
0
 void Start()
 {
     playerHealth  = maxPlayerHealth;
     flightControl = GetComponent <FlightControl> ();
     serial        = GetComponent <SerialCommunicator> ();
 }
Example #18
0
 private void Awake() => _flightControl = GetComponent <FlightControl>();
Example #19
0
 public void UpdateFlightControl(Vessel vessel)
 {
     control = GetControllerByVessel(vessel);
 }
Example #20
0
 public void Consume(InitMessage applicationsMessage, IMessageContext context)
 {
     Log.Information(GetType(), $"{GetType().Assembly.GetName()} Consumer init");
     FlightControl.AddConsumer(typeof(DashboardData), this);
     FlightControl.Post(DashBoardGw, new DashBoardRefresh());
 }
Example #21
0
 public void UpdateFlightControl(Vessel vessel)
 {
     control = GetControllerByVessel(vessel);
 }
Example #22
0
            public FlightCtrlParam(string name, SharedObjects sharedObjects)
            {
                this.name = name;
                control = GetControllerByVessel(sharedObjects.Vessel);

                binding = sharedObjects.BindingMgr;
                Enabled = false;
                value = null;

                HookEvents();
            }
Example #23
0
        public async Task RegisterUser(string userName, string userRole, string connectionId)
        {
            await _dashboardQueryHubContext.Groups.AddToGroupAsync(connectionId, userRole);

            FlightControl.Post(DashBoardGw, new DashBoardRefresh());
        }
Example #24
0
 public void UpdateFlightControl(Vessel vessel)
 {
     control = GetControllerByVessel(vessel);
     if (steeringManager != null)
     {
         steeringManager = SteeringManagerProvider.SwapInstance(shared, steeringManager);
         steeringManager.Update(vessel);
     }
 }
Example #25
0
            public FlightCtrlParam(string name, SharedObjects sharedObjects)
            {
                this.name = name;
                shared = sharedObjects;
                control = GetControllerByVessel(sharedObjects.Vessel);
                
                binding = sharedObjects.BindingMgr;
                Enabled = false;
                value = null;

                if (string.Equals(name, "steering", StringComparison.CurrentCultureIgnoreCase))
                {
                    steeringManager = SteeringManagerProvider.GetInstance(sharedObjects);
                }

                HookEvents();
            }
Example #26
0
 void Start()
 {
     flightControl = GetComponent <FlightControl> ();
     playerHealth  = GetComponent <PlayerHealth>();
 }
Example #27
0
 public void onControl(FlightControl control)
 {
     attitude.drive(control);
 }
Example #28
0
 abstract public void drive(FlightControl c);
Example #29
0
 private void setControls(Vector3 act, FlightControl c, double driveLimit)
 {
     control(act.z, driveLimit, controlRoll, ref c.roll);
     control(act.x, driveLimit, controlPitch, ref c.pitch);
     control(act.y, driveLimit, controlYaw, ref c.yaw);
 }
Example #30
0
        IEnumerator <bool> Initialize()
        {
            cameras = new List <IMyCameraBlock>();
            GridTerminalSystem.GetBlocksOfType(cameras, x => x.CubeGrid == Me.CubeGrid);
            foreach (var cam in cameras)
            {
                cam.EnableRaycast = true;
            }
            yield return(true);

            gyros = new List <IMyGyro>();
            GridTerminalSystem.GetBlocksOfType(gyros, x => x.CubeGrid == Me.CubeGrid);
            yield return(true);

            antennaComms = new ACPWrapper(this, x => x.CubeGrid == Me.CubeGrid);
            yield return(true);

            thrusters = new List <IMyThrust>();
            GridTerminalSystem.GetBlocksOfType(thrusters, x => x.CubeGrid == Me.CubeGrid);
            yield return(true);

            rc = GetBlockWithNameOnGrid(RCNAME) as IMyRemoteControl;
            yield return(true);

            mainCam = GetBlockWithNameOnGrid(MAINCAM) as IMyCameraBlock;
            yield return(true);

            var GTSUtils = new GridTerminalSystemUtils(Me, GridTerminalSystem);

            ingameTime = new IngameTime();
            yield return(true);

            entityTracking = new EntityTracking_Module(GTSUtils, rc, mainCam);
            yield return(true);

            var pid = new PID_Controller.PIDSettings
            {
                PGain = 1
            };

            autopilot = new Autopilot_Module(GTSUtils, rc, ingameTime, pid, pid, entityTracking);
            yield return(true);

            flightControl = new FlightControl(rc, gyros, thrusters, autopilot);
            yield return(true);

            guidance = new TargetGuidance(rc);
            yield return(true);

            clientSystem = new MissileManagementClient(antennaComms, rc, Me.EntityId, missileType);
            yield return(true);

            turretMonitor = new TurretMonitor(this);
            turretMonitor.OnTargetDetected += OnTargetDetected;
            yield return(true);

            proximityFuse = new ProximityFuse(rc, DETONATIONDIST, this);
            proximityFuse.OnEnemyInRange += proximityFuse.Detonate;

            DebugEcho("Initialized!");
        }