partial void pBeforeRemoveVob(BaseVob vob) { if (!vob.IsStatic) { vob.RemoveFromCell(); } }
partial void pAfterAddVob(BaseVob vob) { // add the vob to the gothic world gWorld.AddVob(vob.gVob); // add the gothic-object's address to the dictionary vobAddr.Add(vob.gVob.Address, vob); }
/// <summary> /// 1000 ingame units accuracy /// </summary> public void ForEachNPCRough(BaseVob vob, float radius, Action <NPC> action) { if (vob == null) { throw new ArgumentException("Vob is null!"); } this.ForEachNPCRough(vob.Position, radius, action); }
public static void ReadVobSpawn(PacketReader stream) { byte type = stream.ReadByte(); BaseVob vob = ScriptManager.Interface.CreateVob(type); vob.ReadStream(stream); vob.ScriptObject.Spawn(current); }
/// <summary> /// 5000 units accuracy /// </summary> public void ForEachClientRougherPredicate(BaseVob vob, float radius, Predicate <GameClient> predicate) { if (vob == null) { throw new ArgumentNullException("Vob is null!"); } this.ForEachClientRougherPredicate(vob.Position, radius, predicate); }
/// <summary> /// 1000 ingame units accuracy /// </summary> public void ForEachNPCRoughPredicate(BaseVob vob, float radius, Predicate <NPC> predicate) { if (vob == null) { throw new ArgumentException("Vob is null!"); } this.ForEachNPCRoughPredicate(vob.Position, radius, predicate); }
/// <summary> /// 5000 units accuracy /// </summary> public void ForEachClientRougher(BaseVob vob, float radius, Action <GameClient> action) { if (vob == null) { throw new ArgumentNullException("Vob is null!"); } this.ForEachClientRougher(vob.Position, radius, action); }
partial void pBeforeRemoveVob(BaseVob vob) { var gVob = vob.gVob; // update position & direction one last time //vob.UpdateOrientation(); //vob.UpdateEnvironment(); // remove gothic-object from the gothic-world gWorld.RemoveVob(gVob); // remove the gothic-object's address from the dictionary vobAddr.Remove(gVob.Address); }
partial void pAfterAddVob(BaseVob vob) { if (!vob.IsStatic) { // find the cell for this vob Vec2i coords = BigCell.GetCoords(vob.Position); int coord = BigCell.GetCoordinate(coords.X, coords.Y); BigCell cell; if (!cells.TryGetValue(coord, out cell)) { cell = new BigCell(this, coords.X, coords.Y); cells.Add(coord, cell); } vob.AddToCell(cell); } }
internal void RemoveVob(BaseVob vob) { if (vob == null) { throw new ArgumentNullException("Vob is null!"); } if (vob.World != this) { throw new ArgumentException("Vob is not in this world!"); } pBeforeRemoveVob(vob); vobsByID.Remove(vob); // sets the vob ID to -1 on the server!!! vobs.Remove(ref vob.collID); pAfterRemoveVob(vob); }
internal void AddVob(BaseVob vob) { if (vob == null) { throw new ArgumentNullException("Vob is null!"); } if (vob.IsSpawned) { throw new ArgumentException("Vob is already in a world!"); } if (vob.Instance == null) { throw new ArgumentException("Vob has no instance!"); } pBeforeAddVob(vob); vobsByID.Add(vob); // sets or checks the vob ID on the server vobs.Add(vob, ref vob.collID); pAfterAddVob(vob); }
internal void UpdateVobCell(BaseVob vob, Vec3f pos) { if (vob == null) { throw new ArgumentNullException("Vob is null!"); } Vec2i coords = BigCell.GetCoords(pos); if (coords.X != vob.Cell.X || coords.Y != vob.Cell.Y) { vob.RemoveFromCell(); int coord = BigCell.GetCoordinate(coords.X, coords.Y); BigCell cell; if (!cells.TryGetValue(coord, out cell)) { cell = new BigCell(this, coords.X, coords.Y); cells.Add(coord, cell); } vob.AddToCell(cell); } }
/// <summary> Gets a vob by ID from this world. </summary> public bool TryGetVob(int id, out BaseVob vob) { return(vobsByID.TryGet(id, out vob)); }
partial void pAfterRemoveVob(BaseVob vob);
partial void pBeforeRemoveVob(BaseVob vob);
partial void pAfterAddVob(BaseVob vob);
DynamicCollection <BaseVob> vobs = new DynamicCollection <BaseVob>(); // all vobs for fast foreach loops #region Add & Remove partial void pBeforeAddVob(BaseVob vob);
public bool TryGetVobByAddress(int address, out BaseVob vob) { return(vobAddr.TryGetValue(address, out vob)); }