示例#1
0
        public void UpdateObject(WorldObject obj)
        {
            if (this.Grids.ContainsKey(obj.Grid.Value)) //Already associated
            {
                Grid current = this.Grids[obj.Grid.Value];
                if (current.Contains(obj)) //Same grid
                {
                    return;
                }

                if (current.TryRemove(obj))
                {
                    current.SendAll(obj.BuildDestroy());
                }
            }

            GridCoords coords = new GridCoords(obj.Location, obj.Map);

            if (this.Grids.ContainsKey(coords.Key))
            {
                this.Grids[coords.Key].TryAdd(obj);
            }
            else
            {
                AddOrGet(obj, true);
            }
        }