Beispiel #1
0
 partial void pBeforeRemoveVob(BaseVob vob)
 {
     if (!vob.IsStatic)
     {
         vob.RemoveFromCell();
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 /// <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);
 }
Beispiel #4
0
            public static void ReadVobSpawn(PacketReader stream)
            {
                byte    type = stream.ReadByte();
                BaseVob vob  = ScriptManager.Interface.CreateVob(type);

                vob.ReadStream(stream);
                vob.ScriptObject.Spawn(current);
            }
Beispiel #5
0
 /// <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);
 }
Beispiel #6
0
 /// <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);
 }
Beispiel #7
0
 /// <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);
 }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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);
            }
        }
Beispiel #13
0
 /// <summary> Gets a vob by ID from this world. </summary>
 public bool TryGetVob(int id, out BaseVob vob)
 {
     return(vobsByID.TryGet(id, out vob));
 }
Beispiel #14
0
 partial void pAfterRemoveVob(BaseVob vob);
Beispiel #15
0
 partial void pBeforeRemoveVob(BaseVob vob);
Beispiel #16
0
 partial void pAfterAddVob(BaseVob vob);
Beispiel #17
0
        DynamicCollection <BaseVob> vobs    = new DynamicCollection <BaseVob>(); // all vobs for fast foreach loops

        #region Add & Remove

        partial void pBeforeAddVob(BaseVob vob);
Beispiel #18
0
 public bool TryGetVobByAddress(int address, out BaseVob vob)
 {
     return(vobAddr.TryGetValue(address, out vob));
 }