Ejemplo n.º 1
0
        public static Texture2D CreatePreviewIcon(string jsonData)
        {
            Build.BuildSave buildSave = JsonUtility.FromJson <Build.BuildSave>(jsonData);
            Vector2         zero      = Vector2.zero;

            PartGrid.CenterToPositon(buildSave.parts, Build.main.partDatabase, ref zero, new Vector2(0f, -200f));
            List <GameObject> list = new List <GameObject>();

            foreach (Build.BuildSave.PlacedPartSave placedPartSave in buildSave.parts)
            {
                PartData partByName = Build.main.partDatabase.GetPartByName(placedPartSave.partName);
                if (partByName != null)
                {
                    list.Add(PartGrid.LoadIcon(Build.main.buildGrid.iconPrefab, partByName.prefab, placedPartSave.position, partByName.prefab.localScale, null, 0, placedPartSave.orientation, Color.white, true).gameObject);
                }
            }
            Build.main.previewIconCamera.transform.position = new Vector3(0f, -200f, Mathf.Clamp(-Mathf.Max(zero.x, zero.y), -100f, -1f) * 0.52f);
            Build.main.previewIconCamera.Render();
            while (list.Count > 0)
            {
                UnityEngine.Object.DestroyImmediate(list[0]);
                list.RemoveAt(0);
            }
            Texture2D texture2D = new Texture2D(Build.main.previewIconCamera.targetTexture.width, Build.main.previewIconCamera.targetTexture.height, TextureFormat.RGB24, false);

            RenderTexture.active = Build.main.previewIconCamera.targetTexture;
            texture2D.ReadPixels(new Rect(0f, 0f, (float)Build.main.previewIconCamera.targetTexture.width, (float)Build.main.previewIconCamera.targetTexture.height), 0, 0);
            texture2D.Apply();
            return(texture2D);
        }
Ejemplo n.º 2
0
 public void LoadSave(Build.BuildSave buildSaveToLoad)
 {
     this.buildGrid.DeleteAllIcons();
     Camera.main.transform.position = buildSaveToLoad.cameraPosition;
     this.buildGrid.parts           = Build.BuildSave.PlacedPartSave.FromSave(buildSaveToLoad.parts, this.partDatabase);
     this.buildGrid.LoadAllIcons();
 }
Ejemplo n.º 3
0
            public static void AddQuicksave(Build.BuildSave newSave)
            {
                MyVesselSavedHook myVesselSavedHook = new MyVesselSavedHook(newSave);

                myVesselSavedHook = MyHookSystem.executeHook <MyVesselSavedHook>(myVesselSavedHook);
                if (myVesselSavedHook.isCanceled())
                {
                    return;
                }
                Build.BuildQuicksaves buildQuicksaves = Build.BuildQuicksaves.LoadBuildQuicksaves();
                buildQuicksaves.buildSaves.Add(newSave);
                Build.BuildQuicksaves.SaveBuildQuicksaves(buildQuicksaves);
            }
Ejemplo n.º 4
0
        public void LoadSave(Build.BuildSave buildSaveToLoad)
        {
            MyVesselLoadedHook myVesselLoadedHook = new MyVesselLoadedHook(Build.BuildSave.PlacedPartSave.FromSave(buildSaveToLoad.parts, this.partDatabase));

            myVesselLoadedHook = MyHookSystem.executeHook <MyVesselLoadedHook>(myVesselLoadedHook);
            if (myVesselLoadedHook.isCanceled())
            {
                return;
            }
            this.buildGrid.DeleteAllIcons();
            Camera.main.transform.position = buildSaveToLoad.cameraPosition;
            this.buildGrid.parts           = myVesselLoadedHook.parts;
            this.buildGrid.LoadAllIcons();
            this.MoveCamera(Vector3.zero);
        }
Ejemplo n.º 5
0
 public static void AddQuicksave(Build.BuildSave newSave)
 {
     Build.BuildQuicksaves buildQuicksaves = Build.BuildQuicksaves.LoadBuildQuicksaves();
     buildQuicksaves.buildSaves.Add(newSave);
     Build.BuildQuicksaves.SaveBuildQuicksaves(buildQuicksaves);
 }