// Update is called once per frame void Update() { VCGameMediator.Update(); // Update mediator if (!s_Active) { return; } RunOpenCloseTime(); RenderSettings.fog = false; RenderSettings.ambientLight = Color.white * 0.35f; if (DocumentOpen()) { UserInput(); UpdateBrushLogic(); UpdateMirror(); s_Scene.PreventRenderTextureLost(); s_Scene.m_MeshComputer.ReqMesh(); } #if false if (Input.GetKeyDown(KeyCode.C) && s_Ready) { Debug.LogWarning("Color count: " + s_Scene.m_IsoData.m_Colors.Count); } #endif }
// Quit the Voxel Creation finally public static void QuitFinally() { if (s_Instance == null) { return; } if (!s_Active) { return; } // close current scene CloseScene(); // Reset gameobjects Debug.Log("VCE hide ui."); s_Instance.m_UI.HideUI(); Debug.Log("VCE disable editor go."); s_Instance.m_GLGroup.SetActive(false); s_Instance.m_EditorGO.SetActive(false); // Material Icons // FreeAllMaterialIcons(); // Revert outside camera Debug.Log("VCE trying to revert outside camera."); VCGameMediator.RevertGameMainCamera(); Debug.Log("VCE revert outside camera succeed."); // Reset states s_Active = false; s_Ready = false; if (OnCloseFinally != null) { OnCloseFinally(); } Debug.Log("VCE is closed."); }
void UpdateMeshLoader() { if (Valid) { if (m_ShowNow) { m_ShowNow = false; m_DebugCommand = "show"; } if (m_HideNow) { m_HideNow = false; m_DebugCommand = "hide"; } if (m_DebugCommand.ToLower().Trim() == "show") { m_DebugCommand = ""; LoadMesh(); } else if (m_DebugCommand.ToLower().Trim() == "hide") { m_DebugCommand = ""; FreeMesh(); } m_Visible = VCGameMediator.MeshVisible(this); if (m_lastVisible != m_Visible) { m_lastVisible = m_Visible; if (m_Visible) { LoadMesh(); } else { FreeMesh(); } } } }
// Open the Voxel Creation Editor public static void Open() { if (s_Instance == null) { return; } if (s_Active) { return; } Debug.Log("VCE open."); // Material Icons // GenerateAllMaterialIcons(); // Begin a default scene NewScene(VCConfig.FirstSceneSetting); s_Instance.m_EditorGO.SetActive(true); s_Instance.m_GLGroup.SetActive(true); s_Instance.m_UI.ShowUI(); s_Active = true; s_OpenTime = 0f; // Close outside camera if (Camera.main != null) { Debug.Log("VCE set main camera layer nothing."); VCGameMediator.CloseGameMainCamera(); } if (OnOpen != null) { OnOpen(); } }
public static void CopyCretion(ECreation type) { Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>(); if (null == pkg) { return; } List <int> creationInstanceid = pkg.package.GetCreationInstanceId(type); if (creationInstanceid == null || creationInstanceid.Count == 0) { return; } CreationData cd = CreationMgr.GetCreation(creationInstanceid[0]); if (Pathea.PeGameMgr.IsMulti) { ulong hash = CRC64.Compute(cd.m_Resource); ulong fileId = SteamWorkShop.GetFileHandle(hash); VCGameMediator.SendIsoDataToServer(cd.m_IsoData.m_HeadInfo.Name, cd.m_IsoData.m_HeadInfo.SteamDesc, cd.m_IsoData.m_HeadInfo.SteamPreview, cd.m_Resource, SteamWorkShop.AddNewVersionTag(cd.m_IsoData.m_HeadInfo.ScenePaths()), true, fileId, true); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = cd.m_Resource; new_creation.ReadRes(); // Attr new_creation.GenCreationAttr(); if (new_creation.m_Attribute.m_Type == ECreation.Null) { Debug.LogWarning("Creation is not a valid type !"); new_creation.Destroy(); return; } // SaveRes if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); ItemAsset.ItemObject item; int send_retval = new_creation.SendToPlayer(out item); Debug.Log("Make creation succeed !"); if (send_retval == 0) { return; // Error } else if (send_retval == -1) { return; // Item Package Full } else { return; // Succeed } } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return; } } }
public static int MakeCreation(string path) { TextAsset aseet = Resources.Load <TextAsset>(path); VCIsoData iso = new VCIsoData(); iso.Import(aseet.bytes, new VCIsoOption(false)); // Multi player if (s_MultiplayerMode) { if (!VCConfig.s_Categories.ContainsKey(iso.m_HeadInfo.Category)) { return(-1); } byte[] isodata = iso.Export(); if (isodata == null || isodata.Length <= 0) { return(-1); } ulong hash = CRC64.Compute(isodata); ulong fileId = SteamWorkShop.GetFileHandle(hash); VCGameMediator.SendIsoDataToServer(iso.m_HeadInfo.Name, iso.m_HeadInfo.SteamDesc, iso.m_HeadInfo.SteamPreview, isodata, SteamWorkShop.AddNewVersionTag(iso.m_HeadInfo.ScenePaths()), true, fileId, true); return(0); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = iso.Export(); new_creation.ReadRes(); // Attr new_creation.GenCreationAttr(); if (new_creation.m_Attribute.m_Type == ECreation.Null) { Debug.LogWarning("Creation is not a valid type !"); new_creation.Destroy(); return(-1); } // SaveRes if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); ItemAsset.ItemObject item; int send_retval = new_creation.SendToPlayer(out item); Debug.Log("Make creation succeed !"); if (send_retval == 0) { return(-1); // Error } else if (send_retval == -1) { return(-4); // Item Package Full } else { if (OnMakeCreation != null) { OnMakeCreation(); } return(0); // Succeed } } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return(-3); } } }
public static void ExportRandIso(string fullpath, int dungeonId, int index) { if (fullpath == "") { return; } if (!File.Exists(fullpath)) { return; } ulong fileId = DungeonIsos.GetFileId(dungeonId, index); VCIsoData iso = new VCIsoData(); using (FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read)) { byte[] iso_buffer = new byte[(int)(fs.Length)]; fs.Read(iso_buffer, 0, (int)(fs.Length)); fs.Close(); iso.Import(iso_buffer, new VCIsoOption(true)); if (Pathea.PeGameMgr.IsMulti) { ulong hash = CRC64.Compute(iso_buffer); VCGameMediator.SendIsoDataToServer(iso.m_HeadInfo.Name, iso.m_HeadInfo.SteamDesc, iso.m_HeadInfo.SteamPreview, iso_buffer, SteamWorkShop.AddNewVersionTag(iso.m_HeadInfo.ScenePaths()), true, fileId, true); NetworkManager.SyncServer(EPacketType.PT_Common_SendRandIsoHash, dungeonId, index, hash); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = iso_buffer; new_creation.ReadRes(); ulong hash = CRC64.Compute(iso_buffer); // Attr new_creation.GenCreationAttr(); if (new_creation.m_Attribute.m_Type == ECreation.Null) { Debug.LogWarning("Creation is not a valid type !"); new_creation.Destroy(); return; } // SaveRes if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); ItemObject item; new_creation.SendToPlayer(out item, false); Debug.Log("Make creation succeed !"); RandomDungenMgr.Instance.ReceiveIsoObj(dungeonId, hash, item.instanceId); } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return; } } } }