/// <summary> /// Updates this leader state by the given amount of time. Returns true if a new stone was introduced. /// </summary> public bool Update(World World, Stone Stone, double Time, double Expansion, out Stone Introduced) { Vector dir; if (World._Pressure(Stone, out dir) < this.PressureThreshold) { if (World.ContainsEntry(this.Next)) { this.Next = GetNext(World, Stone); if (this.Next == null) { Introduced = null; return true; } } Introduced = new Stone(this.Next); Introduced.Position = Stone.Position; double dirlen = dir.Length; if (dirlen > 0.001) { dir = dir.Normal; Introduced.Velocity = Stone.Velocity + dir * Settings.Current.StoneIntroductionSpeed; Introduced.Position += dir * Stone.Radius; } _Tweak(this.Next, ref Introduced.Position); return true; } else { this.PressureThreshold *= Expansion; this.Timeout -= Time; Introduced = null; return false; } }
/// <summary> /// Gets the next entry to be introduced by the given stone, or null if there are none left. /// </summary> public static Entry GetNext(World World, Stone Stone) { Entry entry = Stone.Entry; Entry n = entry.Next; if (n != null && !World.ContainsEntry(n)) return n; uint maxweight = 0; Entry next = null; foreach (Entry p in entry.Previous) if (!World.ContainsEntry(p) && p.Weight > maxweight) { maxweight = p.Weight; next = p; } return next; }