Okay so I decided to check this new system out and I been updating my shard to use it but. I ran into a problem or more less misunderstanding of the system.

Am I doing this correctly?

Code:
        public static void PutSpawner(Spawner s, Point3D loc, Map map)
        {
            string name = String.Format("MLQS-{0}", s.Name);

            // Auto cleanup on regeneration
            List<Item> toDelete = new List<Item>();

            foreach (Item item in map.GetItemsInRange(loc, 0))
            {
                if (item is Spawner && item.Name == name)
                    WeakEntityCollection.Delete("bmquest");
                    toDelete.Add(item);
            }

            foreach (Item item in toDelete)
                item.Delete();

            s.Name = name;
            WeakEntityCollection.Add("bmquest", s);
            s.MoveToWorld(loc, map);
        }

every time this code runs it autocleans up the spawner before replacing it. I did this to cut down on save times.

What I am wanting to know is did I use the WeakEntityCollection correctly.

thank you in advance
 
No. I guess the Delete() method needs a more descriptive name. It deletes all entities that have been placed under that key. If you just want to clean up one item, just call item.Delete(). The WeakEntityCollection will remove the item from its collection the next time it attempts to serialize. Also, because you didn't put curly braces around your If statement, you are putting every item in toDelete.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back