Beispiel #1
0
        public static void add_references(string filename, List <TES5.Group> interiors, List <TES5.Group> exteriors)
        {
            make_indices(interiors, exteriors);

            TES3.ESM.open(filename);

            while (TES3.ESM.find("CELL"))
            {
                TES3.CELL cell = new TES3.CELL();
                cell.read();

                // TODO: Remove after testing
                if (!cell.interior)
                {
                    continue;
                }

                Lighting_Module.Shadow shadower = new Lighting_Module.Shadow();
                shadower.mark_shadow_lights(cell.references);

                foreach (TES3.REFR refr in cell.references)
                {
                    string refr_id = refr.editor_id;
                    uint   formid  = TES5.FormID.get(refr_id);
                    if (formid == 0)
                    {
                        continue;   // Reference Base not converted, so skip
                    }


                    Log.info("Adding Reference: " + refr_id);

                    TES5.REFR skyrim_reference;

                    if (refr.isPortal)
                    {
                        TES5.REFR exit = make_exit(refr);
                        skyrim_reference = new TES5.REFR(formid, refr.x, refr.y, refr.z, refr.xR, refr.yR, refr.zR, refr.scale);

                        exit.attach_portal(skyrim_reference);
                        skyrim_reference.attach_portal(exit);
                    }
                    else
                    {
                        skyrim_reference = new TES5.REFR(formid, refr.x, refr.y, refr.z, refr.xR, refr.yR, refr.zR, refr.scale);

                        if (TypeIndex.getInstance().get(refr.editor_id) == TypeIndex.TYPE.LIGH)
                        {
                            skyrim_reference.configure_light();
                        }
                    }

                    handle_owner(refr.owner, skyrim_reference);

                    if (cell.interior)
                    {
                        if (Addon_Rules.addon_defined(skyrim_reference.base_id))
                        {
                            TES5.REFR addon = Addon_Rules.get_addon(skyrim_reference);
                            add_interior_references(addon, Text.editor_id_string(cell.cell_name));
                        }

                        add_interior_references(skyrim_reference, Text.editor_id_string(cell.cell_name));
                    }

                    if (!cell.interior)
                    {
                        add_exterior_references(skyrim_reference);

                        if (Addon_Rules.addon_defined(skyrim_reference.base_id))
                        {
                            TES5.REFR addon = Addon_Rules.get_addon(skyrim_reference);
                            add_exterior_references(addon);
                        }
                    }
                }
            }
        }