Example #1
0
        private static void handle_owner(string owner, TES5.REFR refr)
        {
            if (owner == null)
            {
                return;
            }

            uint owner_id = TES5.FormID.get(owner);

            if (owner_id != 0)
            {
                refr.add_owner(owner_id);
                return;
            }

            //Log.confirm("OWNER: '" + owner + "' has not been converted. Will not be assigned to owned references.");
        }
Example #2
0
        public static TES5.REFR get_addon(TES5.REFR obj)
        {
            Addon addon         = dict[obj.base_id];
            uint  addon_base_id = addon.formid;

            float x = obj.loc.x + addon.x;
            float y = obj.loc.y + addon.y;
            float z = obj.loc.z + addon.z;

            float xR = obj.loc.xR + addon.xR;
            float yR = obj.loc.yR + addon.yR;
            float zR = obj.loc.zR + addon.zR;

            TES5.REFR addon_ref = new TES5.REFR(addon_base_id, x, y, z, xR, yR, zR);

            return(addon_ref);
        }
Example #3
0
        private static TES5.REFR make_exit(TES3.REFR refr)
        {
            // Place the exit marker in the world
            TES5.REFR exit_marker = new TES5.REFR(DOOR.marker_id, refr.portal.x, refr.portal.y, refr.portal.z, refr.portal.xR, refr.portal.yR, refr.portal.zR, 1);

            if (String.IsNullOrEmpty(refr.portal.destination_cell)) // teleports to exterior
            {
                // TODO: Remove after testing
                //add_exterior_references(exit_marker);
            }

            else // teleports to interior
            {
                add_interior_references(exit_marker, Text.editor_id_string(refr.portal.destination_cell));
            }

            return(exit_marker);
        }
Example #4
0
        private static void add_exterior_references(TES5.REFR refr)
        {
            int cell_x = (int)(refr.loc.x / 4096f);
            int cell_y = (int)(refr.loc.y / 4096f);

            if (refr.loc.x < 0f)
            {
                cell_x--;
            }

            if (refr.loc.y < 0f)
            {
                cell_y--;
            }


            TES5.Group reference_group = ext_index.get_reference_group(cell_x, cell_y);

            reference_group.addRecord(refr);
        }
Example #5
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);
                        }
                    }
                }
            }
        }
Example #6
0
 private static void add_interior_references(TES5.REFR refr, string cell_id)
 {
     TES5.Group reference_group = int_index.get_reference_group(cell_id);
     reference_group.addRecord(refr);
 }