private static void OnPoolBurst(float m_ShotCooldown, float m_BurstCooldown, int m_BurstShotCount, int m_NumCannonBarrels, ModuleParticleManager newModule) { // If burst shot count is fraction/multiple of barrel num, then can take shortcut // burst shot count is multiple of number of barrels, just forcibly set stuff to the min if (m_BurstShotCount % m_NumCannonBarrels == 0) { // If it's bigger, then barrels will have both burst + shot_cooldown, and shot_cooldown, so it's technically dynamic. unsupported if (m_BurstShotCount > m_NumCannonBarrels) { /* for (int i = 0; i < m_NumCannonBarrels; i++) * { * List<float> curr_list = newModule.defaultTimeNeeded[i]; * List<ParticleSystem> curr_system_list = newModule.beforeBarrelFired[i]; * for (int j = 0; j < curr_list.Count; j++) * { * curr_list[j] = Mathf.Min(curr_list[j], m_ShotCooldown); * var main = curr_system_list[j].main; * main.startDelay = m_ShotCooldown - curr_list[j]; * // main.startDelayMultiplier = 1.0f; * } * } */ // newModule.dynamicTimeCalc = true; newModule.beforeBarrelFired = null; newModule.defaultTimeNeeded = null; newModule.DebugPrint("<NPM> Dynamic Time Calc Detected [Burst] ShotCount > CannonBarrels"); return; } // must be same number - each burst fires off a volley else { // grace time is time to go through, + burst cooldown float cycle_time = (m_ShotCooldown * (m_BurstShotCount - 1)) + m_BurstCooldown; newModule.DebugPrint("<NPM> [OnPoolBurst] cycle_time calculated at: " + cycle_time.ToString()); // set cycle_time as ceiling for (int i = 0; i < m_NumCannonBarrels; i++) { List <float> curr_list = newModule.defaultTimeNeeded[i]; List <ParticleSystem> curr_system_list = newModule.beforeBarrelFired[i]; float maxTime = 0.0f; float[] timeRequested = new float[curr_list.Count]; bool found_to_remove = false; for (int j = 0; j < curr_list.Count; j++) { float maxTimeAvailable = Mathf.Min(curr_list[j], cycle_time); newModule.DebugPrint("<MPM> [OnPoolBurst] Requested play time of " + maxTimeAvailable.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); var main = curr_system_list[j].main; timeRequested[j] = maxTimeAvailable; if (timeRequested[j] <= 0.0f) { found_to_remove = true; } else { maxTime = Mathf.Max(maxTimeAvailable, maxTime); } } // newModule.adjStartDelay[i] = cycle_time - maxTime; newModule.adjCycleDelay[i] = cycle_time - maxTime; // how much time between cycle end, and start of particles in next cycle newModule.maxTimeNeeded[i] = maxTime; // how much time is enough for every single system // remove particle systems that request 0 time if (found_to_remove) { List <float> temp_list = new List <float>(); List <ParticleSystem> temp_system_list = new List <ParticleSystem>(); int offset = 0; for (int j = 0; j < curr_list.Count; j++) { if (timeRequested[j] > 0.0f) { temp_list.Add(curr_list[j]); temp_system_list.Add(curr_system_list[j]); timeRequested[j - offset] = timeRequested[j]; } else { offset += 1; } } newModule.defaultTimeNeeded[i] = temp_list; newModule.beforeBarrelFired[i] = temp_system_list; curr_list = newModule.defaultTimeNeeded[i]; curr_system_list = newModule.beforeBarrelFired[i]; } // set proper startDelays for remaining PS for (int j = 0; j < curr_list.Count; j++) { float newDelay = maxTime - timeRequested[j]; ParticleSystem currSystem = curr_system_list[j]; var main = currSystem.main; main.startDelay = newDelay; // main.startDelayMultiplier = 1.0f; newModule.DebugPrint("<MPM> [OnPoolBurst] Assign new startDelay of " + newDelay.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); newModule.defaultTimeNeeded[i][j] = newDelay; } float comparator = m_ShotCooldown * i; if (maxTime > comparator) { newModule.numStartModifications += 1; newModule.adjStartDelay[i] = comparator; } } } } // If we know each burst is only fraction of number of barrels, then can set times individually for each thing else if (m_NumCannonBarrels % m_BurstShotCount == 0) { // should be > 1, else we would have done it in prior case int num_sets = m_NumCannonBarrels / m_BurstShotCount; float cycle_time = (m_ShotCooldown * (m_BurstShotCount - 1)) + (num_sets * m_BurstCooldown); // set cycle_time as ceiling for (int i = 0; i < m_NumCannonBarrels; i++) { List <float> curr_list = newModule.defaultTimeNeeded[i]; List <ParticleSystem> curr_system_list = newModule.beforeBarrelFired[i]; float maxTime = 0.0f; float[] timeRequested = new float[curr_list.Count]; bool found_to_remove = false; for (int j = 0; j < curr_list.Count; j++) { float maxTimeAvailable = Mathf.Min(curr_list[j], cycle_time); newModule.DebugPrint("<MPM> [OnPool] Requested play time of " + maxTimeAvailable.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); var main = curr_system_list[j].main; timeRequested[j] = maxTimeAvailable; if (timeRequested[j] <= 0.0f) { found_to_remove = true; } else { maxTime = Mathf.Max(maxTimeAvailable, maxTime); } } // newModule.adjStartDelay[i] = cycle_time - maxTime; newModule.adjCycleDelay[i] = cycle_time - maxTime; // how much time between cycle end, and start of particles in next cycle newModule.maxTimeNeeded[i] = maxTime; // how much time is enough for every single system // remove particle systems that request 0 time if (found_to_remove) { List <float> temp_list = new List <float>(); List <ParticleSystem> temp_system_list = new List <ParticleSystem>(); int offset = 0; for (int j = 0; j < curr_list.Count; j++) { if (timeRequested[j] > 0.0f) { temp_list.Add(curr_list[j]); temp_system_list.Add(curr_system_list[j]); timeRequested[j - offset] = timeRequested[j]; } else { offset += 1; } } newModule.defaultTimeNeeded[i] = temp_list; newModule.beforeBarrelFired[i] = temp_system_list; curr_list = newModule.defaultTimeNeeded[i]; curr_system_list = newModule.beforeBarrelFired[i]; } // set proper startDelays for remaining PS for (int j = 0; j < curr_list.Count; j++) { float newDelay = maxTime - timeRequested[j]; ParticleSystem currSystem = curr_system_list[j]; var main = currSystem.main; main.startDelay = newDelay; // main.startDelayMultiplier = 1.0f; newModule.DebugPrint("<MPM> [OnPool] Assign new startDelay of " + newDelay.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); newModule.defaultTimeNeeded[i][j] = newDelay; } int num_bursts = i / m_BurstShotCount; float comparator = num_bursts * (m_BurstCooldown) + m_ShotCooldown * (i - num_bursts); if (maxTime > comparator) { newModule.numStartModifications += 1; newModule.adjStartDelay[i] = comparator; } } } // else, must set shot timer every single time you've got a change to make // currently unsupported else { // newModule.dynamicTimeCalc = true; newModule.beforeBarrelFired = null; newModule.defaultTimeNeeded = null; newModule.DebugPrint("<NPM> Dynamic Time Calc Detected [Burst] ShotCount unrelated to Barrel Count"); return; } }
private static void OnPoolSequential(float m_ShotCooldown, float m_BurstCooldown, int m_BurstShotCount, int m_NumCannonBarrels, ModuleParticleManager newModule) { float cycle_time = m_ShotCooldown; if (m_BurstShotCount == 1) { cycle_time = m_BurstCooldown; } cycle_time *= m_NumCannonBarrels; newModule.DebugPrint("<NPM> [OnPoolSequential] cycle_time calculated at: " + cycle_time.ToString()); // set cycle_time as ceiling for (int i = 0; i < m_NumCannonBarrels; i++) { List <float> curr_list = newModule.defaultTimeNeeded[i]; List <ParticleSystem> curr_system_list = newModule.beforeBarrelFired[i]; float maxTime = 0.0f; float[] timeRequested = new float[curr_list.Count]; bool found_to_remove = false; for (int j = 0; j < curr_list.Count; j++) { float maxTimeAvailable = Mathf.Min(curr_list[j], cycle_time); newModule.DebugPrint("<MPM> [OnPoolSequential] Requested play time of " + maxTimeAvailable.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); var main = curr_system_list[j].main; timeRequested[j] = maxTimeAvailable; if (timeRequested[j] <= 0.0f) { found_to_remove = true; } else { maxTime = Mathf.Max(maxTimeAvailable, maxTime); } } // newModule.adjStartDelay[i] = cycle_time - maxTime; newModule.adjCycleDelay[i] = cycle_time - maxTime; // how much time between cycle end, and start of particles in next cycle newModule.maxTimeNeeded[i] = maxTime; // how much time is enough for every single system // remove particle systems that request 0 time if (found_to_remove) { List <float> temp_list = new List <float>(); List <ParticleSystem> temp_system_list = new List <ParticleSystem>(); int offset = 0; for (int j = 0; j < curr_list.Count; j++) { if (timeRequested[j] > 0.0f) { temp_list.Add(curr_list[j]); temp_system_list.Add(curr_system_list[j]); timeRequested[j - offset] = timeRequested[j]; } else { offset += 1; } } newModule.defaultTimeNeeded[i] = temp_list; newModule.beforeBarrelFired[i] = temp_system_list; curr_list = newModule.defaultTimeNeeded[i]; curr_system_list = newModule.beforeBarrelFired[i]; } // set proper startDelays for remaining PS for (int j = 0; j < curr_list.Count; j++) { float newDelay = maxTime - timeRequested[j]; ParticleSystem currSystem = curr_system_list[j]; var main = currSystem.main; main.startDelay = newDelay; newModule.DebugPrint("<MPM> [OnPoolSequential] Assign new startDelay of " + newDelay.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); newModule.defaultTimeNeeded[i][j] = newDelay; // main.startDelayMultiplier = 1.0f; } float comparator = m_ShotCooldown * i; if (m_BurstShotCount == 1) { comparator = m_BurstCooldown * i; } if (maxTime > comparator) { newModule.numStartModifications += 1; newModule.adjStartDelay[i] = comparator; } } }
private static void OnPoolAllAtOnce(float m_ShotCooldown, float m_BurstCooldown, int m_BurstShotCount, int m_NumCannonBarrels, ModuleParticleManager newModule) { // select which reload we gon be using float cycle_time = m_ShotCooldown; if (m_BurstShotCount > 0) { if (m_NumCannonBarrels < m_BurstShotCount) { // this is dynamic cooldown // cycle_time = Mathf.Min(cycle_time, m_BurstCooldown); // newModule.dynamicTimeCalc = true; newModule.beforeBarrelFired = null; newModule.defaultTimeNeeded = null; newModule.DebugPrint("<NPM> Dynamic Time Calc Detected [AllAtOnce]"); return; } else { cycle_time = m_BurstCooldown; } } newModule.DebugPrint("<NPM> [OnPoolAllAtOnce] cycle_time calculated at: " + cycle_time.ToString()); for (int i = 0; i < m_NumCannonBarrels; i++) { List <float> curr_list = newModule.defaultTimeNeeded[i]; List <ParticleSystem> curr_system_list = newModule.beforeBarrelFired[i]; float maxTime = 0.0f; float[] timeRequested = new float[curr_list.Count]; bool found_to_remove = false; for (int j = 0; j < curr_list.Count; j++) { float maxTimeAvailable = Mathf.Min(curr_list[j], cycle_time); newModule.DebugPrint("<MPM> [OnPoolAllAtOnce] Requested play time of " + maxTimeAvailable.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); var main = curr_system_list[j].main; timeRequested[j] = maxTimeAvailable; if (timeRequested[j] <= 0.0f) { found_to_remove = true; } else { maxTime = Mathf.Max(maxTimeAvailable, maxTime); } } // newModule.adjStartDelay[i] = cycle_time - maxTime; newModule.adjCycleDelay[i] = cycle_time - maxTime; // how much time between cycle end, and start of particles in next cycle newModule.maxTimeNeeded[i] = maxTime; // how much time is enough for every single system // remove particle systems that request 0 time if (found_to_remove) { List <float> temp_list = new List <float>(); List <ParticleSystem> temp_system_list = new List <ParticleSystem>(); int offset = 0; for (int j = 0; j < curr_list.Count; j++) { if (timeRequested[j] > 0.0f) { temp_list.Add(curr_list[j]); temp_system_list.Add(curr_system_list[j]); timeRequested[j - offset] = timeRequested[j]; } else { offset += 1; } } newModule.defaultTimeNeeded[i] = temp_list; newModule.beforeBarrelFired[i] = temp_system_list; curr_list = newModule.defaultTimeNeeded[i]; curr_system_list = newModule.beforeBarrelFired[i]; } // set proper startDelays for remaining PS for (int j = 0; j < curr_list.Count; j++) { float newDelay = maxTime - timeRequested[j]; ParticleSystem currSystem = curr_system_list[j]; var main = currSystem.main; main.startDelay = newDelay; // main.startDelayMultiplier = 1.0f; newModule.DebugPrint("<MPM> [OnPool] Assign new startDelay of " + newDelay.ToString() + " s to PS #" + j.ToString() + " of Barrel #" + i.ToString()); newModule.defaultTimeNeeded[i][j] = newDelay; } } }