Ejemplo n.º 1
0
        protected void CreateInstancesFromArea(NWN2GameArea area)
        {
            if (!Utils.Nwn2ToolsetFunctions.ToolsetIsOpen())
            {
                return;
            }

            if (area == null)
            {
                throw new ArgumentNullException("area");
            }
            if (!NWN2Toolset.NWN2ToolsetMainForm.App.Module.Areas.Contains(area))
            {
                throw new ArgumentException("Given area is not part of this module.", "area");
            }
            if (!area.Loaded)
            {
                throw new ArgumentException("Area must be open in the toolset to create instances from it.", "area");
            }

            foreach (NWN2ObjectType type in Enum.GetValues(typeof(NWN2ObjectType)))
            {
                string bag = String.Format(InstanceBagNamingFormat, type.ToString());
                if (!manager.HasBag(bag))
                {
                    continue;
                }

                NWN2InstanceCollection instances = area.GetInstancesForObjectType(type);

                if (instances == null)
                {
                    return;
                }

                foreach (INWN2Instance instance in instances)
                {
                    ObjectBlock block = blocks.CreateInstanceBlock(instance, area);
                    manager.AddMoveable(bag, block);
                }
            }
        }