Esempio n. 1
0
        private GameObject CreateFlatObject(DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord blockRecord)
        {
            GameObject go = LocationEditorHelper.AddFlatObject(blockRecord);

            go.transform.parent = parent.transform;
            go.AddComponent <LocationEditorObject>().CreateData(blockRecord, false);

            // Add point lights
            if (blockRecord.TextureArchive == DaggerfallWorkshop.Utility.TextureReader.LightsTextureArchive)
            {
                LocationEditorHelper.AddLight(go.transform, blockRecord);
            }

            return(go);
        }
Esempio n. 2
0
        private void AddItemWindow()
        {
            GUI.BeginGroup(new Rect(8, 64, Screen.width - 16, 32), lightGrayBG);
            chooseFileMode = GUI.SelectionGrid(new Rect(8, 4, 312, 24), chooseFileMode, chooseFileModeString, 2);
            GUI.EndGroup();

            GUI.BeginGroup(new Rect(8, 104, Screen.width - 16, 32), lightGrayBG);
            listMode = GUI.SelectionGrid(new Rect(8, 4, (listModeString.Length * 80) + 8, 24), listMode, listModeString, listModeString.Length);
            GUI.EndGroup();

            if (chooseFileMode == 0)
            {
                if (listMode == 0)
                {
                    GUI.BeginGroup(new Rect(8, 144, Screen.width - 16, 32), lightGrayBG);
                    modelSubList = GUI.SelectionGrid(new Rect(8, 4, (modelSubListString.Length * 80) + 8, 24), modelSubList, modelSubListString, modelSubListString.Length);
                    GUI.EndGroup();
                }


                else if (listMode == 1)
                {
                    GUI.BeginGroup(new Rect(8, 144, Screen.width - 16, 32), lightGrayBG);
                    billboardSubList = GUI.SelectionGrid(new Rect(8, 4, (billboardSubListString.Length * 80) + 8, 24), billboardSubList, billboardSubListString, billboardSubListString.Length);
                    GUI.EndGroup();
                }

                if (listMode != 3)
                {
                    GUI.Label(new Rect(new Rect(16, 190, 64, 16)), "Search: ");
                    searchField = EditorGUI.TextField(new Rect(70, 190, 156, 16), searchField);

                    if (GUI.changed)
                    {
                        UpdateSearchList();
                    }

                    scrollPosition2 = GUI.BeginScrollView(new Rect(4, 210, 312, 418), scrollPosition2, new Rect(0, 0, 256, 20 + (searchListNames.Count * 24)));
                    objectPicker    = GUI.SelectionGrid(new Rect(10, 10, 256, searchListNames.Count * 24), objectPicker, searchListNames.ToArray(), 1);
                    GUI.EndScrollView();
                }
            }

            else if (chooseFileMode == 1)
            {
                GUI.Label(new Rect(new Rect(16, 160, 96, 16)), "Object ID : ");
                selectedObjectID = EditorGUI.TextField(new Rect(128, 160, 156, 16), selectedObjectID);
            }

            if (GUI.Button(new Rect(16, 642, 96, 20), "OK"))
            {
                if (chooseFileMode == 0)
                {
                    selectedObjectID = searchListID[objectPicker];
                }

                GameObject go = null;

                if (listMode == 0 || listMode == 4)
                {
                    DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord();

                    blockRecord.XScale = 1;
                    blockRecord.YScale = 1;
                    blockRecord.ZScale = 1;

                    blockRecord.ModelIdNum = uint.Parse(selectedObjectID);

                    if (isExteriorMode)
                    {
                        blockRecord.ObjectType = LocationEditorHelper.ExteriorBuilding;
                    }

                    else if (listMode == 4)
                    {
                        blockRecord.ObjectType = LocationEditorHelper.InteriorHousePart;
                    }

                    blockRecord.ModelId = blockRecord.ModelIdNum.ToString();
                    go = LocationEditorHelper.Add3dObject(blockRecord);

                    //Rotate Carpets
                    if (blockRecord.ModelId == "74800")
                    {
                        go.transform.rotation = Quaternion.Euler(270, 0, 0);
                    }

                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                else if (listMode == 1)
                {
                    DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord();
                    blockRecord.TextureArchive = int.Parse(selectedObjectID.Split('.')[0]);
                    blockRecord.TextureRecord  = int.Parse(selectedObjectID.Split('.')[1]);
                    go = LocationEditorHelper.AddFlatObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);

                    // Add point lights
                    if (blockRecord.TextureArchive == DaggerfallWorkshop.Utility.TextureReader.LightsTextureArchive)
                    {
                        LocationEditorHelper.AddLight(go.transform, blockRecord);
                    }
                }

                else if (listMode == 2)
                {
                    DaggerfallConnect.DFBlock.RmbBlockPeopleRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockPeopleRecord();
                    blockRecord.TextureArchive = int.Parse(selectedObjectID.Split('.')[0]);
                    blockRecord.TextureRecord  = int.Parse(selectedObjectID.Split('.')[1]);
                    go = LocationEditorHelper.AddPersonObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                else if (listMode == 3)
                {
                    DaggerfallConnect.DFBlock.RmbBlockDoorRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockDoorRecord();
                    blockRecord.OpenRotation = 95; //Seems to be the default rotation used in the game
                    go = LocationEditorHelper.AddDoorObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                if (go != null)
                {
                    go.transform.parent = parent.transform;

                    Ray        newRay = new Ray(SceneView.lastActiveSceneView.camera.transform.position, SceneView.lastActiveSceneView.camera.transform.forward);
                    RaycastHit hit    = new RaycastHit();
                    if (Physics.Raycast(newRay, out hit, 200))
                    {
                        go.transform.position = hit.point;
                    }
                }

                editMode = EditMode.EditMode;
            }

            if (GUI.Button(new Rect(128, 642, 96, 20), "Cancel"))
            {
                editMode = EditMode.EditMode;
            }
        }