public SpriteParticleSystem(IParticleEmitter emitter, Texture2D texture, Rectangle?sourceRectangle = null, Vector2?origin = null) : base(emitter, new SpriteParticleRenderer(texture, sourceRectangle, origin)) { }
/// <summary> /// Changes the order of an <see cref="IParticleEmitter"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to change the order of.</param> /// <param name="newIndex">The new index to give the <paramref name="emitter"/>. Other <see cref="IParticleEmitter"/>s will be /// shifted accordingly. If this value is less than or equal to 0, the <paramref name="emitter"/> will be placed at the head. /// If greater than or equal to the number of <see cref="IParticleEmitter"/>s in this collection, it will be placed at the /// tail.</param> /// <exception cref="ArgumentNullException">The <paramref name="emitter"/> is null.</exception> /// <exception cref="ArgumentException">The <paramref name="emitter"/> is not in this <see cref="IParticleEffect"/>.</exception> public void ChangeEmitterOrder(IParticleEmitter emitter, int newIndex) { if (emitter == null) { throw new ArgumentNullException("emitter"); } var currIndex = GetEmitterOrder(emitter); if (currIndex == -1) { const string errmsg = "IParticleEmitter `{0}` not found in this collection."; throw new ArgumentException(string.Format(errmsg, emitter), "emitter"); } // Clamp newIndex = newIndex.Clamp(0, _emitters.Count - 1); if (currIndex == newIndex) { return; } // Remove then re-add at the given index Debug.Assert(_emitters[currIndex] == emitter); _emitters.RemoveAt(currIndex); _emitters.Insert(newIndex, (ParticleEmitter)emitter); Debug.Assert(_emitters[newIndex] == emitter); }
/// <summary> /// 设置粒子发射器 /// </summary> /// <param name="emitter"></param> public virtual void SetParticleEmitter(IParticleEmitter emitter) { _emitter = emitter; if (_generator != null) { _emitter.AttachGenerator(_generator); } }
/// <summary> /// Emit new particles. /// </summary> /// <param name="deltaTime">The time since the last frame.</param> protected void EmitParticles(float deltaTime) { // emit new particles for (int i = 0; i < emitters.Count; i++) { IParticleEmitter emitter = (IParticleEmitter)emitters[i]; emitter.Update(this, deltaTime); } }
//--------------------------------------------------------------------------- public ParticleSpawnerComponent(Guid entity) : base(entity) { Emitter = new PointParticleEmitter(Vector3.Zero) { SpawnRate = (time) => 60, Sprite = new Sprite(AssetManager.Get().Find <Texture2D>(ETilesetAssets.Particles), 9, 1, 0), Light = new Sprite(AssetManager.Get().Find <Texture2D>(ELightAssets.CircleLight)) }; }
private void Start() { raycastController = GetComponent <IRayCastController>(); emitterLeft = touchControllerLeft.GetComponentInChildren <IParticleEmitter>(); emitterRight = touchControllerRight.GetComponentInChildren <IParticleEmitter>(); shootSoundLeft = audioControl.FindAudioClipByName("Shoot_2").AudioClip; shootSoundRight = audioControl.FindAudioClipByName("Shoot_1").AudioClip; }
/// <summary> /// Adds a particle emitter to this system. /// </summary> /// <param name="emitter">A particle emitter.</param> public void Add(IParticleEmitter emitter) { if (this.emitters.Contains(emitter)) { return; } this.emitters.Add(emitter); this.numRequiredParticles += emitter.MaxParticles; }
/// <summary> /// Removes a particle emitter from this system. /// </summary> /// <param name="emitter">The particle emitter to remove.</param> public void Remove(IParticleEmitter emitter) { if (!this.emitters.Contains(emitter)) { return; } this.emitters.Remove(emitter); this.numRequiredParticles -= emitter.MaxParticles; }
/// <summary> /// Gets the 0-based order index of a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to get the order index of.</param> /// <returns>The 0-based order index of a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>.</returns> public int GetEmitterOrder(IParticleEmitter emitter) { var e = emitter as ParticleEmitter; if (e == null) { return(-1); } return(_emitters.IndexOf(e)); }
/// <summary> /// Increments the order of an <see cref="IParticleEmitter"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to decrement the order of.</param> /// <exception cref="ArgumentNullException">The <paramref name="emitter"/> is null.</exception> /// <exception cref="ArgumentException">The <paramref name="emitter"/> is not in this <see cref="IParticleEffect"/>.</exception> public void IncrementEmitterOrder(IParticleEmitter emitter) { var index = GetEmitterOrder(emitter); if (index < 0) { return; } ChangeEmitterOrder(emitter, index + 1); }
/// <summary> /// Handles when a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/> is disposed. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void emitter_Disposed(IParticleEmitter sender, EventArgs e) { sender.Disposed -= emitter_Disposed; Debug.Assert(_emitters.Contains(sender)); Debug.Assert(sender.Owner == this); Debug.Assert(sender is ParticleEmitter); _emitters.Remove((ParticleEmitter)sender); if (EmitterRemoved != null) { EmitterRemoved.Raise(this, EventArgsHelper.Create(sender)); } }
void ILoad.Load() { //Add(new SkyBackground()); // emitter _emitter = Add(new CompositeParticleEmitter ( new ParticleEmitter(DataPack.Textures.Circle, () => new CloudParticle()) { EmittingCount = new IntRange(5, 10) }, new PhysicParticleEmitter(DataPack.Textures.Circle, () => new PhysicCloudParticle()) { EmittingCount = new IntRange(1, 5) } )); /*_emitter = Add(new ParticleEmitter(DataPack.Textures.Circle, new CloudBehavior()) { Frequency = .00001f, EmittingCountRange = new IntRange(1, 10) }); (_emitter.Layer as SpriteLayer).BlendState = BlendState.NonPremultiplied;*/ // shader /**var effectLayer = Add(new ShaderLayer(new Shaders.Bloom() {BloomIntensity = 1, BloomSaturation = 1})); effectLayer.Add(_emitter.Layer); Add(_emitter);*/ /* var blur = new Shaders.GrowablePoissonDisk { DiskRadius = 1000, InputSize = new Vector2(5000, 5000) }; var shaderLayer = Add(new ShaderLayer(blur)); shaderLayer.Add(_emitter.Layer);*/ /* var timeline = Create<Timer>(); timeline.Wait(1f).Repeat(_emitter.Start, 1, 100); timeline.Wait(1.5f).Repeat(_emitter.Stop, 1, 100); timeline.Repeat(() => timeline.Tween(v => _emitter.Position = new Vector2(v, 0), -50, 50, 3, Sine.EaseInOut, true), 3, 100); */ Add(new GameUI { new MouseButtonBinding(MouseButton.Left, Emit, _emitter.StopEmitting) }); _lastPosition = UI.Mouse.WorldPosition; //Add(new EditorCamera()); }
/// <summary> /// Initializes a new instance of the <see cref="ParticleEffect"/> class. /// </summary> public ParticleEffect(GraphicsDevice graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } this.Enabled = true; this.Visible = true; this.Stretch = 1; this.GraphicsDevice = graphics; this.emitter = new PointEmitter(); this.boundingBox = this.emitter.BoundingBox; this.Controllers = new ParticleControllerCollection(); this.Controllers.ParticleEffect = this; }
public void SetEmitter(IParticleEmitter emit) { OnNativeEmit del = delegate(uint now, uint timeSinceLastCall, IntPtr emitter) { Particle[] outParticles; emit.Emit(now, timeSinceLastCall, out outParticles); IntPtr[] array = new IntPtr[outParticles.Length]; for (int i = 0; i < outParticles.Length; i++) array[i] = outParticles[i].Raw; Emitter_AddParticle(emitter, array, array.Length); for (int i = 0; i < outParticles.Length; i++) outParticles[i].Dispose(); outParticles = null; }; AntiGC.Add(del); Particle_SetEmitterA(_raw, del); }
public static void Bind(INode node, IDictionary <string, IParticleSystem> particleSystems) { IParticleEmitter emitter = node as IParticleEmitter; if (emitter != null && !string.IsNullOrEmpty(emitter.ParticleSystemName)) { IParticleSystem particleSystem; if (particleSystems.TryGetValue(emitter.ParticleSystemName, out particleSystem)) { emitter.ParticleSystem = particleSystem; } } for (int i = 0; i < node.Children.Count; i++) { Bind(node.Children[i], particleSystems); } }
/// <summary> /// Tries to rename an <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to rename.</param> /// <param name="newName">The new name to give the <paramref name="emitter"/>.</param> /// <returns>True if the <paramref name="emitter"/> was successfully renamed; false if the <paramref name="newName"/> /// was invalid or already in use, or if the <paramref name="emitter"/> was invalid.</returns> public bool TryRenameEmitter(IParticleEmitter emitter, string newName) { var e = emitter as ParticleEmitter; // Ensure the emitter is valid if (e == null || e.Owner != this) { Debug.Fail("Invalid emitter."); return(false); } if (string.IsNullOrEmpty(newName)) { Debug.Fail("Invalid name."); return(false); } // Check if the emitter already has that name if (ParticleEmitter.EmitterNameComparer.Equals(e.Name, newName)) { return(true); } // Check if the name is free if (Contains(newName)) { return(false); } // Add the emitter if not already in the collection if (!_emitters.Contains(e)) { _emitters.Add(e); } // Set the new name e.ChangeName(newName); Debug.Assert(ParticleEmitter.EmitterNameComparer.Equals(e.Name, newName)); Debug.Assert(_emitters.Contains(e)); return(true); }
/// <summary> /// Copies the values in this <see cref="ParticleEmitter"/> to another. /// </summary> /// <param name="destination">The <see cref="ParticleEmitter"/> to copy the values to.</param> public void CopyValuesTo(IParticleEmitter destination) { var d = (ParticleEmitter)destination; d.BlendMode = BlendMode; d.Budget = Budget; d.EmitterLife = EmitterLife; d.ParticleLife = ParticleLife; d.Origin = Origin; d.Name = Name; d.ReleaseAmount = ReleaseAmount; d.ReleaseColor = ReleaseColor; d.ReleaseRate = ReleaseRate; d.ReleaseRotation = ReleaseRotation; d.ReleaseScale = ReleaseScale; d.ReleaseSpeed = ReleaseSpeed; d.Sprite.SetGrh(Sprite.GrhData, Sprite.AnimType, Sprite.LastUpdated); d.ParticleModifiers.Clear(); d.ParticleModifiers.AddRange(ParticleModifiers.Select(x => x.DeepCopy())); d.EmitterModifiers.Clear(); d.EmitterModifiers.AddRange(EmitterModifiers.Select(x => x.DeepCopy())); }
public LandingParticleSystem(IParticleEmitter emitter, Color color) : base(120) { _emitter = emitter; DirtColor = color; }
public virtual void OnEmit(IParticleEmitter emitter) { }
/// <summary> /// Adds an emitter /// </summary> /// <param name="emitter">Emitter to add</param> public void AddEmitter(IParticleEmitter emitter) { emitter.ParticleSystem = this; emitters.Add(emitter); }
public DragonSparksParticleSystem(Game g, IParticleEmitter emitter) : base(g, 200) { _emitter = emitter; }
public void run() { /* At first, we let the user select the driver type, * then start up the engine, set a caption, and get a * pointer to the video driver. */ // ask user for driver DriverType driverType; // Ask user to select driver: StringBuilder sb = new StringBuilder(); sb.Append("Please select the driver you want for this example:\n"); sb.Append("\n(a) Direct3D 9.0c\n(b) Direct3D 8.1\n(c) OpenGL 1.5"); sb.Append("\n(d) Software Renderer\n(e) Apfelbaum Software Renderer"); sb.Append("\n(f) Null Device\n(otherKey) exit\n\n"); // Get the user's input: TextReader tIn = Console.In; TextWriter tOut = Console.Out; string input = string.Empty; bool shadows = false; tOut.Write("Do you want to use realtime shadows? (y/n)"); input = tIn.ReadLine(); if (input == "y") { shadows = true; } tOut.Write(sb.ToString()); input = tIn.ReadLine(); // Select device based on user's input: switch (input) { case "a": driverType = DriverType.DIRECT3D9; break; case "b": driverType = DriverType.DIRECT3D8; break; case "c": driverType = DriverType.OPENGL; break; case "d": driverType = DriverType.SOFTWARE; break; case "e": driverType = DriverType.SOFTWARE2; break; case "f": driverType = DriverType.NULL_DRIVER; break; default: return; } /* We start like in some tutorials before. Please note that this time, the * 'shadows' flag in createDevice() is set to true, for we want to have a * dynamic shadow casted from an animated character. If your this example * runs to slow, set it to false. The Irrlicht Engine checks if your hardware * doesn't support the stencil buffer, and disables shadows by itself, but * just in case the demo runs slow on your hardware.*/ /* * From the unmanaged API documentation: * stencilbuffer: * Specifies if the stencil buffer should be enabled. * Set this to true, if you want the engine be able to draw stencil buffer shadows. * Note that not all devices are able to use the stencil buffer. * If they don't no shadows will be drawn. */ device = new IrrlichtDevice(driverType, new Dimension2D(1024, 768), 32, false, shadows, true); if (device == null) { tOut.Write("Device creation failed."); return; } ISceneManager smgr = device.SceneManager; IVideoDriver driver = device.VideoDriver; /* For our environment, we load a .3ds file. It is a small room I modelled with * Anim8or and exported it into the 3ds format because the Irrlicht Engine did * not support the .an8 format when I wrote this tutorial. I am a very bad 3d * graphic artist, and so the texture mapping is not very nice in this model. * Luckily I am a better programmer than artist, and so the Irrlicht Engine is * able to create a cool texture mapping for me: Just use the mesh manipulator * and create a planar texture mapping for the mesh. If you want to see the * mapping I made with Anim8or, uncomment this line. I also did not figure out * how to set the material right in Anim8or, it has an emissive light color * which I don't really like. I'll switch it off too with this code.*/ IAnimatedMesh mesh = smgr.GetMesh( path + "room.3ds"); smgr.MeshManipulator.MakePlanarTextureMapping( mesh.GetMesh(0), 0.008f); ISceneNode node = smgr.AddAnimatedMeshSceneNode(mesh, null, 0); node.SetMaterialTexture( 0, driver.GetTexture(path + "wall.jpg")); node.GetMaterial(0).EmissiveColor.Set(0, 0, 0, 0); // Add a shadow to the room if it is not dark enough /* The result is interesting but not exactly what I was expecting! * Try for yourself... I think this could be a little problem in the * Irrlicht.NET wrapper but I promise I will investigate further to see * if I can make it work as intended * Forum Article (http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=10584) */ // IAnimatedMeshSceneNode xnode = (IAnimatedMeshSceneNode)node; // xnode.AddShadowVolumeSceneNode(); // /*Now, for the first special effect: Animated water. It works like this: The * WaterSurfaceSceneNode takes a mesh as input and makes it wave like a water * surface. And if we let this scene node use a nice material like the * MT_REFLECTION_2_LAYER, it looks really cool. We are doing this with the * next few lines of code. As input mesh, we create a hill plane mesh, without * hills. But any other mesh could be used for this, you could even use the * room.3ds (which would look really strange) if you wanted to.*/ mesh = smgr.AddHillPlaneMesh("myHill", new Dimension2Df(20, 20), new Dimension2D(40, 40), new Material(), 0, new Dimension2Df(0, 0), new Dimension2Df(10, 10)); node = smgr.AddWaterSurfaceSceneNode(mesh.GetMesh(0), 3.0f, 300.0f, 30.0f, null, 0); node.Position = new Vector3D(0, 7, 0); node.SetMaterialTexture(0, driver.GetTexture(path + "water.jpg")); node.SetMaterialTexture(1, driver.GetTexture(path + "stones.jpg")); node.SetMaterialType(MaterialType.REFLECTION_2_LAYER); /*The second special effect is very basic, I bet you saw it already in some * Irrlicht Engine demos: A transparent billboard combined with a dynamic light. * We simply create a light scene node, let it fly around, an to make it look * more cool, we attach a billboard scene node to it.*/ // create light node = smgr.AddLightSceneNode(null, new Vector3D(0, 0, 0), new Colorf(1.0f, 0.6f, 0.7f, 1.0f), 600.0f, 0); ISceneNodeAnimator anim = smgr.CreateFlyCircleAnimator(new Vector3D(0, 150, 0), 250.0f, 0.0005f); node.AddAnimator(anim); // attach billboard to light node = smgr.AddBillboardSceneNode(node, new Dimension2Df(50, 50), new Vector3D(), 0); node.SetMaterialFlag(MaterialFlag.LIGHTING, false); node.SetMaterialType(MaterialType.TRANSPARENT_ADD_COLOR); node.SetMaterialTexture(0, driver.GetTexture(path + "particlewhite.bmp")); /* The next special effect is a lot more interesting: A particle system. The * particle system in the Irrlicht Engine is quit modular and extensible and * yet easy to use. There is a particle system scene node into which you can * put particle emitters, which make particles come out of nothing. These * emitters are quite flexible and usually have lots of parameters like * direction, amount and color of the particles they should create. * There are different emitters, for example a point emitter which lets * particles pop out at a fixed point. If the particle emitters available * in the engine are not enough for you, you can easily create your own ones, * you'll simply have to create a class derived from the IParticleEmitter * interface and attach it to the particle system using setEmitter(). * In this example we create a box particle emitter, which creates particles * randomly inside a box. The parameters define the box, direction of the * articles, minimal and maximal new particles per second, color and minimal * and maximal livetime of the particles. Because only with emitters particle * system would be a little bit boring, there are particle affectors, which * modify particles during they fly around. They can be added to the particle * system, simulating additional effects like gravity or wind. The particle * affector we use in this example is an affector, which modifies the color * of the particles: It lets them fade out. Like the particle emitters, * additional particle affectors can also be implemented by you, simply derive * a class from IParticleAffector and add it with addAffector(). After we set * a nice material to the particle system, we have a cool looking camp fire. * By adjusting material, texture, particle emitter and affector parameters, * it is also easily possible to create smoke, rain, explosions, snow, and * so on.*/ IParticleSystemSceneNode ps = smgr.AddParticleSystemSceneNode( false, null, 0, new Vector3D(-70, 60, 40), new Vector3D(), new Vector3D(2, 2, 2)); ps.ParticleSize = new Dimension2Df(20, 10); IParticleEmitter em = ps.CreateBoxEmitter( new Box3D(-7, 0, -7, 7, 1, 7), new Vector3D(0.0f, 0.03f, 0.0f), 80, 100, new Color(0, 255, 255, 255), new Color(0, 255, 255, 255), 800, 2000, 0); ps.SetEmitter(em); IParticleAffector paf = ps.CreateFadeOutParticleAffector(new Color(), 1500); ps.AddAffector(paf); ps.SetMaterialFlag(MaterialFlag.LIGHTING, false); ps.SetMaterialTexture(0, driver.GetTexture(path + "particle.bmp")); ps.SetMaterialType(MaterialType.TRANSPARENT_VERTEX_ALPHA); /*As our last special effect, we want a dynamic shadow be casted from an animated * character. For this we load a quake 2 .md2 model and place it into our world. * For creating the shadow, we simply need to call addShadowVolumeSceneNode(). The * color of shadows is only adjustable globally for all shadows, by calling * ISceneManager::setShadowColor(). Voila, here is our dynamic shadow. Because * the character is a little bit too small for this scene, we make it bigger * using setScale(). And because the character is lighted by a dynamic light, * we need to normalize the normals to make the lighting on it correct. This * is always necessary if the scale of a dynamic lighted model is not (1,1,1). * Otherwise it would get too dark or too bright because the normals will be * scaled too.*/ mesh = smgr.GetMesh(path + "faerie.md2"); IAnimatedMeshSceneNode anode = smgr.AddAnimatedMeshSceneNode(mesh, null, 0); anode.Position = new Vector3D(-50, 45, -60); anode.SetMD2Animation(MD2AnimationType.STAND); anode.SetMaterialTexture(0, driver.GetTexture(path + "Faerie5.BMP")); // add shadow anode.AddShadowVolumeSceneNode(); smgr.ShadowColor = new Color(220, 0, 0, 0); // make the model a little bit bigger and normalize its normals // because of this for correct lighting anode.Scale = new Vector3D(2, 2, 2); anode.SetMaterialFlag(MaterialFlag.NORMALIZE_NORMALS, true); /*Finally we simply have to draw everything, that's all.*/ ICameraSceneNode camera = smgr.AddCameraSceneNodeFPS(); camera.Position = new Vector3D(-50, 50, -150); // Remove the mouse cursor: device.CursorControl.Visible = false; int lastFPS = -1; while (device.Run()) { if (device.WindowActive) { device.VideoDriver.BeginScene(true, true, new Color(0, 200, 200, 200)); device.SceneManager.DrawAll(); device.VideoDriver.EndScene(); int fps = device.VideoDriver.FPS; if (lastFPS != fps) { device.WindowCaption = "Irrlicht Engine - SpecialFX tutorial [" + device.VideoDriver.Name + "] FPS:" + fps.ToString(); lastFPS = fps; } } } /* * In the end, delete the Irrlicht device. */ // Instead of device->drop, we'll use: GC.Collect(); }
public ParticleSystem(IParticleEmitter emitter, IParticleRenderer renderer) { _particles = new List <Particle>(); _emitter = emitter; _renderer = renderer; }
public SparksParticleSystem(Game game, IParticleEmitter emitter) : base(game, 500) { _emitter = emitter; }
public void Start() { emitter = GetComponentInChildren <IParticleEmitter>(); }
internal ParticleEmitter(IParticleEmitter nativeHandle) { NativeHandle = nativeHandle; }
public PixieParticleSystem(Game game, IParticleEmitter emitter) : base(game, 2000) { _emitter = emitter; }
/// <summary> /// Changes the order of an <see cref="IParticleEmitter"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to change the order of.</param> /// <param name="newIndex">The new index to give the <paramref name="emitter"/>. Other <see cref="IParticleEmitter"/>s will be /// shifted accordingly. If this value is less than or equal to 0, the <paramref name="emitter"/> will be placed at the head. /// If greater than or equal to the number of <see cref="IParticleEmitter"/>s in this collection, it will be placed at the /// tail.</param> /// <exception cref="ArgumentNullException">The <paramref name="emitter"/> is null.</exception> /// <exception cref="ArgumentException">The <paramref name="emitter"/> is not in this <see cref="IParticleEffect"/>.</exception> public void ChangeEmitterOrder(IParticleEmitter emitter, int newIndex) { if (emitter == null) throw new ArgumentNullException("emitter"); var currIndex = GetEmitterOrder(emitter); if (currIndex == -1) { const string errmsg = "IParticleEmitter `{0}` not found in this collection."; throw new ArgumentException(string.Format(errmsg, emitter), "emitter"); } // Clamp newIndex = newIndex.Clamp(0, _emitters.Count - 1); if (currIndex == newIndex) return; // Remove then re-add at the given index Debug.Assert(_emitters[currIndex] == emitter); _emitters.RemoveAt(currIndex); _emitters.Insert(newIndex, (ParticleEmitter)emitter); Debug.Assert(_emitters[newIndex] == emitter); }
public static bool TryCreateEmitter(string name, IKeyValueCollection baseProperties, IKeyValueCollection emitterInfo, out IParticleEmitter emitter) { if (EmitterDictionary.TryGetValue(name, out var factory)) { emitter = factory(baseProperties, emitterInfo); return(true); } emitter = default; return(false); }
/// <summary> /// Gets if an <see cref="IParticleEmitter"/> exists in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to look for.</param> /// <returns>True if the <see cref="IParticleEmitter"/> exists in this collection; otherwise false.</returns> public bool Contains(IParticleEmitter emitter) { return _emitters.Contains(emitter); }
/// <summary> /// Removes an emitter /// </summary> /// <param name="emitter">Emitter to add</param> public void RemoveEmitter(IParticleEmitter emitter) { emitters.Remove(emitter); }
/// <summary> /// Gets the 0-based order index of a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to get the order index of.</param> /// <returns>The 0-based order index of a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>.</returns> public int GetEmitterOrder(IParticleEmitter emitter) { var e = emitter as ParticleEmitter; if (e == null) return -1; return _emitters.IndexOf(e); }
/// <summary> /// Gets if an <see cref="IParticleEmitter"/> exists in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to look for.</param> /// <returns>True if the <see cref="IParticleEmitter"/> exists in this collection; otherwise false.</returns> public bool Contains(IParticleEmitter emitter) { return(_emitters.Contains(emitter)); }
/// <summary> /// Increments the order of an <see cref="IParticleEmitter"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to decrement the order of.</param> /// <exception cref="ArgumentNullException">The <paramref name="emitter"/> is null.</exception> /// <exception cref="ArgumentException">The <paramref name="emitter"/> is not in this <see cref="IParticleEffect"/>.</exception> public void IncrementEmitterOrder(IParticleEmitter emitter) { var index = GetEmitterOrder(emitter); if (index < 0) return; ChangeEmitterOrder(emitter, index + 1); }
/// <summary> /// Handles when a <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/> is disposed. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void emitter_Disposed(IParticleEmitter sender, EventArgs e) { sender.Disposed -= emitter_Disposed; Debug.Assert(_emitters.Contains(sender)); Debug.Assert(sender.Owner == this); Debug.Assert(sender is ParticleEmitter); _emitters.Remove((ParticleEmitter)sender); if (EmitterRemoved != null) EmitterRemoved.Raise(this, EventArgsHelper.Create(sender)); }
/// <summary> /// Tries to rename an <see cref="IParticleEmitter"/> in this <see cref="IParticleEffect"/>. /// </summary> /// <param name="emitter">The <see cref="IParticleEmitter"/> to rename.</param> /// <param name="newName">The new name to give the <paramref name="emitter"/>.</param> /// <returns>True if the <paramref name="emitter"/> was successfully renamed; false if the <paramref name="newName"/> /// was invalid or already in use, or if the <paramref name="emitter"/> was invalid.</returns> public bool TryRenameEmitter(IParticleEmitter emitter, string newName) { var e = emitter as ParticleEmitter; // Ensure the emitter is valid if (e == null || e.Owner != this) { Debug.Fail("Invalid emitter."); return false; } if (string.IsNullOrEmpty(newName)) { Debug.Fail("Invalid name."); return false; } // Check if the emitter already has that name if (ParticleEmitter.EmitterNameComparer.Equals(e.Name, newName)) return true; // Check if the name is free if (Contains(newName)) return false; // Add the emitter if not already in the collection if (!_emitters.Contains(e)) _emitters.Add(e); // Set the new name e.ChangeName(newName); Debug.Assert(ParticleEmitter.EmitterNameComparer.Equals(e.Name, newName)); Debug.Assert(_emitters.Contains(e)); return true; }
public TeleportParticleSystem(IParticleEmitter emitter) : base(600) { _emitter = emitter; }
/// <inheritdoc /> public bool Equals(IParticleEmitter other) { return(ReferenceEquals(this, other) || this.ID == other?.ID); }