Beispiel #1
0
    /*
     * Addes newTarget to the array.
     *      newTarget is added to the first empty space in the array.
     *      If there are no empty spaces, the oldest entry (targets[0]) is overritten by MoveDown(0)
     *      and newTarget is added at the ent of the array.
     * If newTarget is already within the array, it is moved to the front.
     * Returns true if newTarget was not already within the array and false if it was already in the array.
     */
    public bool AddTarget(Magnetic newTarget, AllomanticIronSteel allomancer)
    {
        int indexOfTarget = GetIndex(newTarget);

        if (indexOfTarget >= 0)     // Target is already in the array

        {
            if (indexOfTarget < Count - 1)   // Target is not already at the end of the array
            // MoveDown over old version of the target, and add the new one at the end.
            {
                MoveDown(indexOfTarget, false);
                targets[Count] = newTarget;
                Count++;
            }
            return(false);
        }
        else     // Target is not already in the array.
        // If Count < Size, just add newTarget at Count and increment Count.
        {
            if (Count < Size)
            {
                targets[Count] = newTarget;
                Count++;
            }
            else        // Count == Size. Move all elements down, delete the first entry, and add newTarget to the end.
                        // Do not increment Count, since the number of entries doesn't change.
            {
                MoveDown(0);
                targets[Count] = newTarget;
                Count++;
            }
            return(true);
        }
    }
Beispiel #2
0
    void pickup()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            int x = Screen.width / 2;
            int y = Screen.height / 2;

            Ray        ray = mainCamera.GetComponent <Camera> ().ScreenPointToRay(new Vector3(x, y));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                Pickupable p = hit.collider.GetComponent <Pickupable> ();
                if (p != null)
                {
                    carrying = true;
                    Magnetic magnet = hit.transform.gameObject.GetComponent <Magnetic> ();
                    if (magnet != null)
                    {
                        magnet.Deactivate();
                    }
                    carriedObject = p.gameObject;
                    //p.gameObject.rigidbody.isKinematic = true;
                    carriedObject.GetComponent <Rigidbody> ().useGravity = false;
                    carriedObject.layer = 2;
                    //playPickupSound ();
                }
            }
        }
    }
        public void Uncertainty2020()
        {
            //All values static accept dec. Grab Dec variations for 2020 2022 and 2024
            Coordinate c = new Coordinate(-45, 20, new DateTime(2020, 1, 1), new EagerLoad(false));
            Magnetic   m = new Magnetic(c, DataModel.WMM2020);

            Assert.AreEqual(.51, m.Uncertainty.Declination, .01, "Declination attempt 1 exceeds delta.");
            Assert.AreEqual(.21, m.Uncertainty.Inclination, "Inclination incorrect.");
            Assert.AreEqual(128, m.Uncertainty.HorizontalIntensity, "Inclination incorrect.");
            Assert.AreEqual(131, m.Uncertainty.NorthComponent, "North Component incorrect.");
            Assert.AreEqual(94, m.Uncertainty.EastComponent, "East Component incorrect.");
            Assert.AreEqual(157, m.Uncertainty.DownComponent, "Down Component incorrect.");
            Assert.AreEqual(145, m.Uncertainty.TotalIntensity, "Total Intensity incorrect.");


            Assert.AreEqual(.21, m.Uncertainty.Inclination, "Inclination incorrect.");

            c = new Coordinate(45, -120, new DateTime(2022, 1, 1), new EagerLoad(false));
            m = new Magnetic(c, DataModel.WMM2020);
            Assert.AreEqual(.38, m.Uncertainty.Declination, .01, "Declination attempt 2 exceeds delta.");

            c = new Coordinate(82, 120, new DateTime(2024, 1, 1), new EagerLoad(false));
            m = new Magnetic(c, DataModel.WMM2020);
            Assert.AreEqual(5.13, m.Uncertainty.Declination, .01, "Declination attempt 3 exceeds delta.");
        }
Beispiel #4
0
 // Assign a vacuous target when none others are selected.
 // If target is null, stop vacuously targeting.
 protected void SetVacuousTarget(Magnetic target, bool usingIron = true)
 {
     if (target == null)
     {
         if (usingIron)
         {
             RemovePullTargetAt(0);
             VacuousPullTarget = null;
         }
         else
         {
             RemovePushTargetAt(0);
             VacuousPushTarget = null;
         }
     }
     else
     {
         if (usingIron)
         {
             RemovePullTargetAt(0);
             VacuousPullTarget = target;
             PullTargets.AddTarget(target, this);
         }
         else
         {
             RemovePushTargetAt(0);
             VacuousPushTarget = target;
             PushTargets.AddTarget(target, this);
         }
     }
 }
Beispiel #5
0
 /*
  * Remove a target, regardless of it being a pull or push target.
  */
 public bool RemoveTarget(Magnetic target, bool startWithPullTargets = false)
 {
     // Try to remove target from both arrays, if necessary
     if (startWithPullTargets)
     {
         if (PullTargets.RemoveTarget(target))
         {
             return(true);
         }
         else
         {
             return(PushTargets.RemoveTarget(target));
         }
     }
     else
     {
         if (PushTargets.RemoveTarget(target))
         {
             return(true);
         }
         else
         {
             return(PullTargets.RemoveTarget(target));
         }
     }
 }
Beispiel #6
0
    private void Awake()
    {
        _magnetic      = GetComponent <Magnetic>();
        _currentState  = RoyStates.None;
        _currentEnergy = _maxEnergy;
        OnCurrentEnergyChange?.Invoke((float)_currentEnergy / _maxEnergy);
        _currentFuel = _maxFuel;
        OnCurrentFuelChange?.Invoke((float)_currentFuel / _maxFuel);
        _energyPerSecond   = (float)_maxEnergy / _energyTimeDuration;
        _rechargePerSecond = (float)_maxFuel / _totalTimeToReloadFullFuel;

        _aimController = GetComponentInChildren <AimController>();
        var playerInputComponent = GetComponent <PlayerInput>();

        _magnetic.OnPull += _onPlayerPull_Magnetic;

        _actionMove            = playerInputComponent.actions["Move"];
        _actionJump            = playerInputComponent.actions["Jump"];
        _actionJump.performed += _actionJump_performed;
        _actionJump.canceled  += _actionJump_canceled;
        _actionMov1            = playerInputComponent.actions["Mov1"];
        _actionMov1.started   += _actionMov1_started;
        _actionMov1.canceled  += _actionMov1_canceled;
        _actionMov2            = playerInputComponent.actions["Mov2"];
        _actionMov2.performed += _actionMov2_performed;
        _actionMov2.canceled  += _actionMov2_canceled;
        _animator.Play("Roy_Armature_Idle");
    }
Beispiel #7
0
    protected void SwapVacuousTargets()
    {
        Magnetic temp = VacuousPullTarget;

        VacuousPullTarget = VacuousPushTarget;
        VacuousPushTarget = temp;
    }
Beispiel #8
0
    private void OnTriggerStay(Collider other)
    {
        Magnetic mag = other.GetComponent <Magnetic>();

        Rigidbody rb = other.GetComponent <Rigidbody>();



        if (mag != null && rb != null)
        {
            Vector3 direction = other.transform.position - transform.position;
            float   distance  = direction.magnitude * distanceCoeff;

            if (distance < 1)
            {
                distance = 1;
            }



            rb.AddForce(direction.normalized * (pole * mag.pole) * (force / (distance)) /** Time.deltaTime*/);

            if (mag.pole == -pole && mag.still && other.GetComponent <MForce>())
            {
                rb.AddForce(direction.normalized * (pole * mag.pole) * (other.GetComponent <MForce>().force * 1 / distance));
            }
        }
    }
Beispiel #9
0
    private void Awake()
    {
        _magnetic         = GetComponent <Magnetic>();
        _magnetic.OnPull += _onPlayerPull_Magnetic;
        _currentState     = KlunkState.None;
        _currentFuel      = _maxFuel;
        OnCurrentFuelChange?.Invoke((float)_currentFuel / _maxFuel);
        _currentEnergy = _maxEnergy;
        OnCurrentEnergyChange?.Invoke((float)_currentEnergy / _maxEnergy);
        _fuelPerSecond     = (float)_maxFuel / _fuelTimeDuration;
        _rechargePerSecond = (float)_maxEnergy / _totalTimeToReloadFullEnergy;

        _frontAttack = GetComponentInChildren <FrontAttack>();
        _frontAttack.gameObject.SetActive(false);
        _frontAttack.OnTriggerEnterEvent += _frontAttackChecker_OnTriggerEnterEvent;
        _characterController              = GetComponent <KlunkCharController>();
        _frictionController = GetComponent <FrictionController>();

        var playerInput = GetComponent <PlayerInput>();

        _actionMove            = playerInput.actions["Move"];
        _actionJump            = playerInput.actions["Jump"];
        _actionJump.performed += _actionJump_performed;
        _actionJump.canceled  += _actionJump_canceled;
        _actionMov1            = playerInput.actions["Mov1"];
        _actionMov2            = playerInput.actions["Mov2"];
        _actionMov2.performed += _actionMov2_performed;
        _actionMov2.canceled  += _actionMov2_canceled;
        inGameUIController     = FindObjectOfType <InGameUIController>();
    }
Beispiel #10
0
    private void SoftRefreshTargets(TargetArray targets, Text[] actualForce, Text[] sumForce, bool refreshSum)
    {
        for (int i = 0; i < targets.Count; i++)
        {
            Magnetic target = targets[i];

            Vector3 heightToTop = Vector3.zero;
            heightToTop.y = target.ColliderBodyBoundsSizeY / 2f;

            Vector3 positionActualForce = CameraController.ActiveCamera.WorldToScreenPoint(target.transform.position - heightToTop) + new Vector3(0, -pixelDelta);

            if (positionActualForce.z > 0)
            {
                actualForce[i].transform.position = positionActualForce;
                actualForce[i].text = HUD.ForceString(target.LastNetForceOnTarget.magnitude, target.NetMass);
                if (refreshSum)
                {
                    sumForce[i].text = HUD.AllomanticSumString(target.LastAllomanticForce, target.LastAnchoredPushBoostFromAllomancer, target.NetMass, 2, true);
                }
            }
            else     // Target is not on screen
            {
                sumForce[i].text    = "";
                actualForce[i].text = "";
            }
        }
    }
        public void Overload_Constructors()
        {
            Coordinate c  = new Coordinate(89, -121, new DateTime(2020, 1, 1), new EagerLoad(false));
            Magnetic   m1 = new Magnetic(c, DataModel.WMM2020);
            Magnetic   m2 = new Magnetic(89, -121, new DateTime(2020, 1, 1), 0, 0, DataModel.WMM2020);

            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements));
        }
Beispiel #12
0
 private void OnEnable()
 {
     _rigidbody   = GetComponent <Rigidbody2D>();
     _magnetic    = GetComponent <Magnetic>();
     _audio       = GetComponent <AudioSource>();
     _usualCharge = _magnetic.Charge;
     Health       = MaxHealth;
 }
        /// <summary>
        /// Benchmark magnetic calculations.
        /// </summary>
        /// <param name="opt"></param>
        static void Magnetic_Calculations(OutputOption opt)
        {
            Coordinate c = new Coordinate(45, 45, new DateTime(2021, 1, 1), new EagerLoad(false));

            Benchmarkers.Benchmark(() => {
                Magnetic m = new Magnetic(c, DataModel.WMM2020);
            }, 100, "Magnetic Calculation Times", opt);
        }
Beispiel #14
0
 public void AddMagnet(Magnetic magnet)
 {
     //Check if its already in the list if not add it to it
     if (!magnets.Contains(magnet))
     {
         magnets.Add(magnet);
     }
 }
Beispiel #15
0
    void OnTriggerStay(Collider other)
    {
        if (other.CompareTag(MAGNETIC_FIELD) && other.attachedRigidbody != null)
        {
            Magnetic magnet      = transform.parent.GetComponent <Magnetic> ();
            Magnetic otherMagnet = other.transform.parent.GetComponent <Magnetic> ();

            if (magnet.IsActive && otherMagnet.IsActive)
            {
                Vector3     dir, force;
                BoxCollider bc = GetComponent <BoxCollider> ();

                dir = other.transform.position - this.transform.position;
                if (bc != null)
                {
                    float ax = Mathf.Abs(magnet.transform.lossyScale.x);
                    float ay = Mathf.Abs(magnet.transform.lossyScale.y);
                    float az = Mathf.Abs(magnet.transform.lossyScale.z);

                    float mag = Mathf.Abs(dir.magnitude);
                    if (ax < ay && ax < az)                       // x is smallest
                    {
                        mag = other.transform.position.x - this.transform.position.x;
                        dir = new Vector3(mag, 0, 0);
                    }
                    else if (ay < az)                         // y is smallest
                    {
                        mag = other.transform.position.y - this.transform.position.y;
                        dir = new Vector3(0, mag, 0);
                    }
                    else                         // z is smallest
                    {
                        mag = other.transform.position.z - this.transform.position.z;
                        dir = new Vector3(0, 0, mag);
                    }
                }
                //Debug.DrawRay (magnet.transform.position, dir);

                force = (Mathf.Abs(6 - dir.magnitude)) * dir.normalized * magForce;

                if (!magnet.SamePolarityAs(otherMagnet))
                {
                    force *= -1;
                }

                if (other.attachedRigidbody != null)
                {
                    other.attachedRigidbody.AddForce(force);
                }
                else
                {
                    Debug.LogError("Magnetic field " + other.name + " with parent " + other.transform.parent.name + " does not have a magnet");
                }
            }
        }
    }
Beispiel #16
0
    // Update is called once per frame
    void Update()
    {
        //New list for only the polar magnets
        List <Magnetic> polar = new List <Magnetic>();

        foreach (Magnetic mag in magnets)
        {
            if (mag.pole != Polarity.Neutral)
            {
                polar.Add(mag);
            }
        }

        while (polar.Count > 1)
        {
            //Take off the first item
            Magnetic mag = polar[0];
            polar.RemoveAt(0);

            MagInfo info1 = mag.GetInfo();

            //Go through every other item
            foreach (Magnetic net in polar)
            {
                MagInfo info2 = net.GetInfo();

                //Check if they're close enough to bother
                Vector3 separation = info1.pos - info2.pos;
                float   magnitude  = separation.magnitude;
                if (magnitude >= cutoff)
                {
                    continue;
                }

                magnitude += 1f;
                separation.Normalize();
                float force = (info1.power * info2.power * strength) / (magnitude * magnitude);
                force *= Time.deltaTime;

                if (mag.pole == net.pole)
                {
                    //Repel
                    force *= ratio;
                    info1.rb.AddForce(separation * force);
                    info2.rb.AddForce(-separation * force);
                }
                else
                {
                    //Attract
                    force /= ratio;
                    info1.rb.AddForce(-separation * force);
                    info2.rb.AddForce(separation * force);
                }
            }
        }
    }
    public override void StartSimulation()
    {
        base.StartSimulation();

        allomancer = GetComponentInChildren <NonPlayerPushPullController>();
        coin       = GetComponentInChildren <Magnetic>();
        coinWall   = transform.Find("CoinWall").GetComponent <Rigidbody>();
        alloWall   = transform.Find("AlloWall").GetComponent <Rigidbody>();

        counter = 0;
        cleared = false;

        allomancer.PushTargets.MaxRange = -1;
        allomancer.AddPushTarget(coin);
        texts = HUDSimulations.CoinWall.GetComponentsInChildren <Text>();

        texts[texts.Length - 8].text = "Wall: " + TextCodes.LightBlue("Anchored");
        texts[texts.Length - 7].text = "Allomancer: " + TextCodes.Gray("Unanchored");
        texts[texts.Length - 6].text = "Coin: " + TextCodes.Gray("Unanchored");
        texts[texts.Length - 5].text = "Wall: " + TextCodes.LightBlue("Anchored");

        if (SettingsMenu.settingsData.anchoredBoost == 1)
        {
            texts[texts.Length - 4].text = "Allomantic Normal Force";
            //Time.timeScale = 1f;
        }
        else if (SettingsMenu.settingsData.anchoredBoost == 2)
        {
            texts[texts.Length - 4].text = "Exponential w/ Velocity factor";
            //Time.timeScale = 1f;
        }
        else
        {
            texts[texts.Length - 4].text = "Distributed Power";
            //Time.timeScale = .2f;
        }
        // This is what messes up the DP's energy distribution
        //Time.fixedDeltaTime = Time.timeScale * 1 / 60f;

        if (SettingsMenu.settingsData.forceDistanceRelationship == 0)
        {
            texts[texts.Length - 9].text = "Linear Distance Relationship";
        }
        else if (SettingsMenu.settingsData.forceDistanceRelationship == 1)
        {
            texts[texts.Length - 9].text = "Inverse Square Distance Relationship";
        }
        else if (SettingsMenu.settingsData.forceDistanceRelationship == 2)
        {
            texts[texts.Length - 9].text = "Exponential w/ Distance Relationship";
        }

        texts[texts.Length - 3].text = "Time scale: " + HUD.RoundStringToSigFigs(Time.timeScale);
        texts[texts.Length - 2].text = "Allomancer mass: " + allomancer.Mass + "kg";
        texts[texts.Length - 1].text = "Coin mass: " + coin.MagneticMass + "kg";
    }
    // Start is called before the first frame update
    void Start()
    {
        p1Body = Player1.GetComponent <Rigidbody>();
        p2Body = Player2.GetComponent <Rigidbody>();

        p1Mag = Player1.GetComponent <Magnetic>();
        p2Mag = Player2.GetComponent <Magnetic>();

        //if (!p1Mesh) p1Mesh = Player1.GetComponent<MeshRenderer>();
        //if (!p2Mesh) p2Mesh = Player2.GetComponent<MeshRenderer>();
    }
Beispiel #19
0
 /*
  * Returns true if potentialTarget is in the array, false otherwise
  */
 public bool IsTarget(Magnetic potentialTarget)
 {
     for (int i = 0; i < Count; i++)
     {
         if (potentialTarget == targets[i])
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #20
0
 /*
  * Returns the index of potentialTarget in targets.
  * Returns -1 if potentialTarget is not in targets.
  */
 private int GetIndex(Magnetic potentialTarget)
 {
     for (int i = 0; i < Count; i++)
     {
         if (potentialTarget == targets[i])
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #21
0
        /// <summary>Converts the specified value to string.</summary>
        /// <param name="value">The value to convert.</param>
        /// <returns>The converted string.</returns>
        public static string ConvertToString(Magnetic value)
        {
            switch (value)
            {
            case Magnetic.North: return("north");

            case Magnetic.South: return("south");

            default: return("");
            }
        }
Beispiel #22
0
 /*
  * Removes a target by reference
  * return true if it was successfully removed, false if target was not found
  */
 public bool RemoveTarget(Magnetic target, bool clear = true)
 {
     for (int i = 0; i < Count; i++)
     {
         if (targets[i] == target)   // Magnetic was found, move targets along
         {
             MoveDown(i, clear);
             return(true);
         }
     }
     return(false);
 }
Beispiel #23
0
    private IEnumerator ShotEffectR(Magnetic magnet, float dist)
    {
        yield return(new WaitForSeconds(dist / speed));

        if (magnet.SetPolarityOrDeactivate(false))
        {
            PlaySound(redSound);
        }
        else
        {
            PlaySound(deactivateSound);
        }
    }
Beispiel #24
0
 public static void RemoveMagnetic(Magnetic magnetic)
 {
     // Remove from all allomancers
     foreach (Allomancer allomancer in Allomancers)
     {
         AllomanticIronSteel ironSteel = allomancer.GetComponent <AllomanticIronSteel>();
         if (ironSteel)
         {
             ironSteel.RemoveTarget(magnetic);
         }
     }
     MagneticsInScene.Remove(magnetic);
 }
Beispiel #25
0
    void Update()
    {
        int mask = 1 << 8;

        mask = ~mask;
        RaycastHit hit;

        Debug.DrawRay(transform.position, transform.forward * 30);

        if (Physics.Raycast(transform.position, transform.forward, out hit, 55, mask))
        {
            float        dist       = Vector3.Distance(Spawnpoint.position, hit.point);
            Magnetic     magnet     = hit.transform.gameObject.GetComponent <Magnetic> ();
            notChangable cantchange = hit.transform.gameObject.GetComponent <notChangable> ();
            if (magnet != null && cantchange == null)
            {
                change.SetImage1();
                if (Input.GetMouseButtonDown(0) && canShootBlue)
                {
                    StartCoroutine(ShotEffectB(magnet, dist));
                }
                else if (Input.GetMouseButtonDown(1) && canShootRed)
                {
                    StartCoroutine(ShotEffectR(magnet, dist));
                }
            }
            else
            {
                change.SetImage2();
            }
        }

        if (Physics.Raycast(transform.position, transform.forward, out hit, 55, mask))
        {
            float dist = Vector3.Distance(Spawnpoint.position, hit.point);

            if (Input.GetMouseButtonDown(0) && canShootBlue)
            {
                GameObject newproj = Instantiate(projectileB, Spawnpoint.position, Spawnpoint.rotation) as GameObject;
                newproj.GetComponent <Rigidbody> ().velocity = (hit.point - transform.position).normalized * 55;
                StartCoroutine(des(dist, newproj));
            }

            if (Input.GetMouseButtonDown(1) && canShootRed)
            {
                GameObject newproj = Instantiate(projectileR, Spawnpoint.position, Spawnpoint.rotation) as GameObject;
                newproj.GetComponent <Rigidbody> ().velocity = (hit.point - transform.position).normalized * 55;
                StartCoroutine(des(dist, newproj));
            }
        }
    }
Beispiel #26
0
        public DataPoint(CoefficientModel cem, Magnetic parent, int index)
        {
            IndexPoint = index;
            Parent     = parent;

            Degree = cem.Degree;
            Order  = cem.Order;


            Gm  = cem.Gm;
            Hm  = cem.Hm;
            Gtm = cem.Gtm;
            Htm = cem.Htm;
        }
Beispiel #27
0
    /*
     * Applys the force that was calculated in CalculateForce to the target and player.
     * This effectively executes the Push or Pull.
     */
    private void AddForce(Magnetic target)
    {
        target.AddForce(target.LastNetForceOnTarget, target.LastAllomanticForceOnTarget);
        rb.AddForce(target.LastNetForceOnAllomancer);

        // Debug
        //allomanticsForce = target.LastAllomanticForce.magnitude;
        //allomanticsForces = target.LastAllomanticForce;
        //netAllomancersForce = target.LastNetForceOnAllomancer.magnitude;
        //resititutionFromTargetsForce = target.LastAnchoredPushBoostFromTarget;
        //resititutionFromPlayersForce = target.LastAnchoredPushBoostFromAllomancer;
        //percentOfTargetForceReturned = resititutionFromTargetsForce.magnitude / allomanticsForce;
        //percentOfAllomancerForceReturned = resititutionFromPlayersForce.magnitude / allomanticsForce;
        //netTargetsForce = target.LastNetForceOnTarget.magnitude;
    }
Beispiel #28
0
        public Form1()
        {
            InitializeComponent();
            E = new Electric(3, wind, samp);
            H = new Magnetic(3, wind, samp);

            ilPanel1.Scene = scene;
            plotCube = scene.Add(new ILPlotCube());

            plotCube.Limits.Set(new Vector3(0f,-1f,0f), new Vector3(200f,1f,0f));
            plotCube.AllowRotation = false;
            plotCube.AllowZoom = false;
            plotCube.AllowPan = false;
            ilPanel1.Scene = scene;
            backgroundWorker1.RunWorkerAsync();
        }
        public void Coordinate_Extensions()
        {
            Coordinate c  = new Coordinate(89, -121, new DateTime(2020, 1, 1), new EagerLoad(false));
            Magnetic   m1 = new Magnetic(c, DataModel.WMM2020);
            Magnetic   m2 = c.GetMagnetic(DataModel.WMM2020);

            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements), "Failed on attempt 1.");

            m1 = new Magnetic(c, 10000, DataModel.WMM2020);
            m2 = c.GetMagnetic(10000, DataModel.WMM2020);
            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements), "Failed on attempt 2.");

            m1 = new Magnetic(c, new Distance(100), DataModel.WMM2020);
            m2 = c.GetMagnetic(new Distance(100), DataModel.WMM2020);
            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements), "Failed on attempt 3.");
        }
        public void Local_Time()
        {
            Coordinate c1 = new Coordinate(89, -121, new DateTime(2020, 1, 1), new EagerLoad(false));

            c1.Offset = -8;
            Coordinate c2 = new Coordinate(89, -121, new DateTime(2020, 1, 1, 8, 0, 0), new EagerLoad(false));

            Magnetic m1 = new Magnetic(c1, DataModel.WMM2020);
            Magnetic m2 = new Magnetic(c2, DataModel.WMM2020);

            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements), "Failed on attempt 1.");

            m1 = new Magnetic(45, 45, new DateTime(2020, 1, 1), -8, 100, DataModel.WMM2020);
            m2 = new Magnetic(45, 45, new DateTime(2020, 1, 1, 8, 0, 0), 0, 100, DataModel.WMM2020);

            Assert.IsTrue(Helpers.ReflectiveEquals(m1.MagneticFieldElements, m2.MagneticFieldElements), "Failed on attempt 2.");
        }
        public void GridVariation2020()
        {
            Coordinate c = new Coordinate(89, -121, new DateTime(2020, 1, 1), new EagerLoad(false));
            Magnetic   m = new Magnetic(c, DataModel.WMM2020);

            Assert.AreEqual(9.08, m.MagneticFieldElements.GridVariation, .01, "Attempt 1 exceeds delta.");

            c = new Coordinate(80, 0, new DateTime(2020, 1, 1), new EagerLoad(false));
            m = new Magnetic(c, DataModel.WMM2020);
            Assert.AreEqual(-1.28, m.MagneticFieldElements.GridVariation, .01, "Attempt 2 exceeds delta.");

            c = new Coordinate(-80, -120, new DateTime(2020, 1, 1), new EagerLoad(false));
            m = new Magnetic(c, DataModel.WMM2020);
            Assert.AreEqual(-50.64, m.MagneticFieldElements.GridVariation, .01, "Attempt 3 exceeds delta.");

            c = new Coordinate(20, -121, new DateTime(2020, 1, 1), new EagerLoad(false));
            m = new Magnetic(c, DataModel.WMM2020);
            Assert.AreEqual(m.MagneticFieldElements.Declination, m.MagneticFieldElements.GridVariation, "Attempt 4 exceeds delta.");
        }