public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f, Tuple <Vector2, Vector2> tracerPoints = null) { if (prefab == null || prefab.Sprites.Count == 0) { return(null); } if (particleCount >= MaxParticles) { for (int i = 0; i < particleCount; i++) { if (particles[i].Prefab.Priority < prefab.Priority) { RemoveParticle(i); break; } } if (particleCount >= MaxParticles) { return(null); } } Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity); Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y)); Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y)); if (tracerPoints != null) { minPos = new Vector2( Math.Min(Math.Min(minPos.X, tracerPoints.Item1.X), tracerPoints.Item2.X), Math.Min(Math.Min(minPos.Y, tracerPoints.Item1.Y), tracerPoints.Item2.Y)); maxPos = new Vector2( Math.Max(Math.Max(maxPos.X, tracerPoints.Item1.X), tracerPoints.Item2.X), Math.Max(Math.Max(maxPos.Y, tracerPoints.Item1.Y), tracerPoints.Item2.Y)); } Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist); if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X) { return(null); } if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height) { return(null); } if (particles[particleCount] == null) { particles[particleCount] = new Particle(); } particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer, tracerPoints: tracerPoints); particleCount++; return(particles[particleCount - 1]); }
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f) { if (particleCount >= MaxParticles || prefab == null || prefab.Sprites.Count == 0) { return(null); } Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity); Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y)); Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y)); Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist); if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X) { return(null); } if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height) { return(null); } if (particles[particleCount] == null) { particles[particleCount] = new Particle(); } particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer); particleCount++; return(particles[particleCount - 1]); }
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null) { if (particleCount >= MaxParticles || prefab == null || GameMain.NilMod.DisableParticles || !GameMain.NilMod.RenderOther) { return(null); } if (((Rand.Range(1, 100) <= GameMain.NilMod.ParticleSpawnPercent) || GameMain.NilMod.ParticleWhitelist.Find(p => p == prefab.Name) != null)) { Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity); Vector2 minPos = new Vector2(Math.Min(position.X, particleEndPos.X), Math.Min(position.Y, particleEndPos.Y)); Vector2 maxPos = new Vector2(Math.Max(position.X, particleEndPos.X), Math.Max(position.Y, particleEndPos.Y)); Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist); if (!(Screen.Selected is ParticleEditorScreen)) { if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X) { return(null); } if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height) { return(null); } } if (particles[particleCount] == null) { particles[particleCount] = new Particle(); } particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess); particleCount++; return(particles[particleCount - 1]); } else { return(null); } }