public bool Tick(World world, RealmTime time) { remain -= time.thisTickTimes; if (remain < 1) { cb(world, time); return true; } return false; }
public void Oryx(World world, string text) { world.BroadcastPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "#Oryx the Mad God", Text = text }, null); }
//Null for player public static void AOE(World world, Entity self, float radius, bool players, Action<Entity> callback) { if (players) foreach (var i in world.PlayersCollision.HitTest(self.X, self.Y, radius)) { var d = Dist(i, self); if (d < radius) callback(i); } else foreach (var i in world.EnemiesCollision.HitTest(self.X, self.Y, radius)) { if (!(i is Enemy)) continue; var d = Dist(i, self); if (d < radius) callback(i); } }
//Null for player protected void AOE(World world, float radius, short? objType, Action<Entity> callback) { if (objType == null) foreach (var i in world.PlayersCollision.HitTest(Host.Self.X, Host.Self.Y, radius)) { var d = Dist(i, Host.Self); if (d < radius) callback(i); } else foreach (var i in world.EnemiesCollision.HitTest(Host.Self.X, Host.Self.Y, radius)) { if (i.ObjectType != objType.Value) continue; var d = Dist(i, Host.Self); if (d < radius) callback(i); } }
public static bool HasPlayerNearby(World world, double x, double y) { foreach (var i in world.PlayersCollision.HitTest(x, y, 16)) { var d = Dist(i.X, i.Y, x, y); if (d < 16 * 16) return true; } return false; }
public static World AddWorld(World world) { world.Id = Interlocked.Increment(ref nextWorldId); Worlds[world.Id] = world; if (world is GameWorld) Monitor.WorldAdded(world); return world; }