public BlackHole() { this.shape = new FCircle(); this.settings = new BlackHoleSettings(); this.baseSettings = new BlackHoleSettings(); settings.weigh = PhysicSettings.Instance().DEFAULT_BLACKHOLE_WEIGH; settings.capacity = PhysicSettings.Instance().DEFAULT_BLACKHOLE_CAPACITY; ((FCircle)shape).Radius = PhysicSettings.Instance().DEFAULT_BLACKHOLE_RADIUS; }
/// <summary> /// Process black holes for one particle /// </summary> public static void ProcessBlackHoles(TableDepositor system, Particle part) { foreach (BlackHole blackH in system.blackHoles) { BlackHoleSettings settings = (blackH.Settings_Allowed) ? blackH.Settings : system.table.Settings.blackHoleSettings; // distance between the particle and the stone double length = Math.Sqrt((part.Position.X - blackH.Position.X) * (part.Position.X - blackH.Position.X) + (part.Position.Y - blackH.Position.Y) * (part.Position.Y - blackH.Position.Y)); // if the distance is within the treshold, we will remove it if (length < blackH.Radius) { if (PhysicsSettings.absorptionMode == AbsorptionMode.BLACKHOLE) { deletedParticles.Add(part); } else if (PhysicsSettings.absorptionMode == AbsorptionMode.RECYCLE) { // if the recycling is enabled, just find an appropriate generator and give it the deleted particle if (system.generators.Count > 0) { system.generators.ElementAt(CommonAttribService.apiRandom.Next(system.generators.Count - 1)).generatingNumber--; deletedParticles.Add(part); } } else if (PhysicsSettings.absorptionMode == AbsorptionMode.SELECT) { if (CommonAttribService.apiRandom.Next(50) == 40) { deletedParticles.Add(part); } } return; } // creepy gravity acceleration double acc = (PhysicSettings.Instance().DEFAULT_GRAVITY_CONSTANT *settings.weigh) / (Math.Log(length * length) / 114 + 14) * (((A_Rock)blackH).Intensity / 100); double dist_x = (blackH.Position.X - part.Position.X); double dist_y = (blackH.Position.Y - part.Position.Y); double celk = length * 1.5; // pulsar if (settings.Energy_pulsing) { acc /= (1 + Math.Tan(counter * settings.Energy_pulse_speed) / (4 + 4 * Math.Log10(length))); } part.Vector_Acceleration.Add(0.5 * acc * ((dist_x) / length), 0.5 * acc * ((dist_y) / length)); // this is really creepy but it works if (dist_x > 0 && (-dist_y) > 0) { dist_y *= length / 4; } else if (dist_x > 0 && (-dist_y) < 0) { dist_x *= length / 4; } else if (dist_x < 0 && (-dist_y) > 0) { dist_x *= length / 4; } else if (dist_x < 0 && (-dist_y) < 0) { dist_y *= length / 4; } // add gravityy acceleration part.Vector_Acceleration.Add((-dist_y / celk) / 30, (dist_x / celk) / 30); } }