Beispiel #1
0
        /// <summary>
        /// 在物理世界创建一个全局作用力区域
        /// </summary>
        /// <param name="world">物理世界</param>
        /// <param name="particleForceGenerator">作用力发生器</param>
        /// <returns></returns>
        public static GlobalZone CreateGlobalZone(
            this World world,
            ParticleForceGenerator particleForceGenerator)
        {
            var zone = new GlobalZone();

            return(world.CreateZone(zone, particleForceGenerator));
        }
Beispiel #2
0
 /// <summary>
 /// 在物理世界中创建一个区域
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="world"></param>
 /// <param name="zone"></param>
 /// <param name="particleForceGenerator"></param>
 /// <returns></returns>
 public static T CreateZone <T>(
     this World world,
     T zone,
     ParticleForceGenerator particleForceGenerator)
     where T : Zone
 {
     zone.Add(particleForceGenerator);
     world.Zones.Add(zone);
     return(zone);
 }
Beispiel #3
0
        /// <summary>
        /// 在物理世界创建一个矩形区域作用力
        /// </summary>
        /// <param name="world">物理世界</param>
        /// <param name="particleForceGenerator">作用力发生器</param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        public static RectangleZone CreateRectangleZone(
            this World world,
            ParticleForceGenerator particleForceGenerator,
            double x1,
            double y1,
            double x2,
            double y2)
        {
            var zone = new RectangleZone(x1, y1, x2, y2);

            return(world.CreateZone(zone, particleForceGenerator));
        }
Beispiel #4
0
 private void TestRemoveForceGenerator(
     ForceRegistry forceRegistry,
     ParticleForceGenerator force)
 {
     forceRegistry.Remove(force);
 }
Beispiel #5
0
 private void TestAddForceGenerator(
     ForceRegistry forceRegistry,
     ParticleForceGenerator force)
 {
     forceRegistry.Add(force);
 }
 /*Registers given force generator to apply to the particle*/
 public void add(MyParticle particle, ParticleForceGenerator fg)
 {
     registration.setValues(particle, fg);
     Registry.Add(registration);
     listLength++;
 }
 /*Removes given pair from Registry. If not in registry nothing happens*/
 public void remove(MyParticle particle, ParticleForceGenerator fg)
 {
     registration.setValues(particle, fg);
     Registry.Remove(registration);
     listLength--;
 }
 public void setValues(MyParticle p, ParticleForceGenerator f)
 {
     this.particle = p;
     this.fg       = f;
 }
Beispiel #9
0
 /// <summary>
 /// 删除一个作用力发生器
 /// </summary>
 /// <param name="forceGenerator">作用力发生器</param>
 public void Remove(ParticleForceGenerator forceGenerator) => this.generators.Remove(forceGenerator);
Beispiel #10
0
 /// <summary>
 /// 添加一个新项目
 /// </summary>
 /// <param name="forceGenerator">作用力发生器</param>
 public void Add(ParticleForceGenerator forceGenerator) => this.generators.Add(forceGenerator);
Beispiel #11
0
 /// <summary>
 /// 移除一个作用力发生器
 /// </summary>
 /// <param name="particleForceGenerator"></param>
 public void Remove(ParticleForceGenerator particleForceGenerator)
 => _particleForceGenerators.Remove(particleForceGenerator);
Beispiel #12
0
 /// <summary>
 /// 添加一个作用力发生器
 /// </summary>
 /// <param name="particleForceGenerator"></param>
 public void Add(ParticleForceGenerator particleForceGenerator)
 => _particleForceGenerators.Add(particleForceGenerator);