public virtual void Clear(bool clearTargets = true) { base.Clear(); if (clearTargets) { IronPulling = false; SteelPushing = false; } else // prevents calling of StopOn____Targets { ironPulling = false; steelPushing = false; } IronBurnPercentageTarget = 0; SteelBurnPercentageTarget = 0; IronPassiveBurn = 0; SteelPassiveBurn = 0; PullTargets.Clear(true, clearTargets); PushTargets.Clear(true, clearTargets); lastExpectedAllomancerAcceleration = Vector3.zero; //lastExpectedAllomancerVelocityChange = Vector3.zero; //LastExpectedAllomancerEnergyUsed = 0; LastAllomancerVelocity = Vector3.zero; LastNetForceOnAllomancer = Vector3.zero; LastAllomanticForce = Vector3.zero; LastAnchoredPushBoost = Vector3.zero; LastMaximumNetForce = Vector3.zero; }
public void RemoveAllTargets() { PullTargets.Clear(); PushTargets.Clear(); HUD.TargetOverlayController.Clear(); }
public virtual void StopBurning() { if (IsBurning) { PullTargets.Clear(); PushTargets.Clear(); IronBurnPercentageTarget = 0; SteelBurnPercentageTarget = 0; IsBurning = false; lastWasPulling = false; lastWasPushing = false; } }
/* * Every frame: Calculate and apply forces to targets being pushed on. * Drain metal reserves. */ private void FixedUpdate() { if (!PauseMenu.IsPaused) { if (IsBurning) { // Remove all targets that are out of pushing range // For Mouse/Keyboard, Iron and Steel burn percentages are equal, so it's somewhat redundant to specify PullTargets.RemoveAllOutOfRange(IronBurnPercentageTarget, this); PushTargets.RemoveAllOutOfRange(SteelBurnPercentageTarget, this); // Calculate net charges to know how pushes will be distributed amongst targets float netPullTargetsCharge = PullTargets.NetCharge(); float netPushTargetsCharge = PushTargets.NetCharge(); float sumPullTargetsCharge = PullTargets.SumOfCharges(); float sumPushTargetsCharge = PushTargets.SumOfCharges(); // Calculate Allomantic Forces and APBs // Execute AFs and APBs on target and Allomancer if (PullingOnPullTargets) { for (int i = 0; i < PullTargets.Count; i++) { CalculateForce(PullTargets[i], netPullTargetsCharge, sumPullTargetsCharge, iron); AddForce(PullTargets[i]); BurnIron(PullTargets[i].LastNetForceOnAllomancer.magnitude); } } else if (PushingOnPullTargets) { for (int i = 0; i < PullTargets.Count; i++) { CalculateForce(PullTargets[i], netPullTargetsCharge, sumPullTargetsCharge, steel); AddForce(PullTargets[i]); BurnSteel(PullTargets[i].LastNetForceOnAllomancer.magnitude); } } else if (HasPullTarget) { for (int i = 0; i < PullTargets.Count; i++) { CalculateForce(PullTargets[i], netPullTargetsCharge, sumPullTargetsCharge, iron); } } if (PullingOnPushTargets) { for (int i = 0; i < PushTargets.Count; i++) { CalculateForce(PushTargets[i], netPushTargetsCharge, sumPushTargetsCharge, iron); AddForce(PushTargets[i]); BurnIron(PushTargets[i].LastNetForceOnAllomancer.magnitude); } } else if (PushingOnPushTargets) { for (int i = 0; i < PushTargets.Count; i++) { CalculateForce(PushTargets[i], netPushTargetsCharge, sumPushTargetsCharge, steel); AddForce(PushTargets[i]); BurnSteel(PushTargets[i].LastNetForceOnAllomancer.magnitude); } } else if (HasPushTarget) { for (int i = 0; i < PushTargets.Count; i++) { CalculateForce(PushTargets[i], netPushTargetsCharge, sumPushTargetsCharge, steel); } } // Consume iron or steel for passively burning, depending on which metal was last used to push/pull if (HasIron && lastWasPulling || !HasSteel) { IronReserve.Mass += IronPassiveBurn * gramsPerSecondPassiveBurn * Time.fixedDeltaTime; } else if (HasSteel && lastWasPushing || !HasIron) { SteelReserve.Mass += SteelPassiveBurn * gramsPerSecondPassiveBurn * Time.fixedDeltaTime; } else { IronReserve.Mass += IronPassiveBurn * gramsPerSecondPassiveBurn * Time.fixedDeltaTime / 2; SteelReserve.Mass += SteelPassiveBurn * gramsPerSecondPassiveBurn * Time.fixedDeltaTime / 2; } // If out of metals, stop burning. if (!HasIron) { if (HasPullTarget) { PullTargets.Clear(); } if (!HasSteel) { StopBurning(); } } if (!HasSteel) { if (HasPushTarget) { PushTargets.Clear(); } } lastWasPulling = (lastWasPulling || IronPulling) && !SteelPushing; lastWasPushing = (lastWasPushing || SteelPushing) && !IronPulling; // Update variables for calculating APBs and the like for next frame LastAllomancerVelocity = rb.velocity; LastAllomanticForce = thisFrameAllomanticForce; thisFrameAllomanticForce = Vector3.zero; LastAnchoredPushBoost = thisFrameAnchoredPushBoost; thisFrameAnchoredPushBoost = Vector3.zero; LastMaximumNetForce = thisFrameMaximumNetForce; thisFrameMaximumNetForce = Vector3.zero; LastNetForceOnAllomancer = LastAllomanticForce + LastAnchoredPushBoost; lastExpectedAllomancerAcceleration = LastNetForceOnAllomancer / rb.mass; } } }