/// <summary> /// Connect to DF, and register basic RPC functions. /// </summary> void Connect() { blockRequest.blocks_needed = BlocksToFetch; networkClient = new DFHack.RemoteClient(dfNetworkOut); bool success = networkClient.connect(); if (!success) { networkClient.disconnect(); networkClient = null; ModalPanel.Instance.Choice( "Armok Vision could not find a running instance of Dwarf Fortress!\n\n" + "Please make sure you have Dwarf Fortress running, with the latest version of DFHack installed.", Connect, QuitGame, "Retry", "Quit"); throw new UnityException("DF Connection Failure"); } BindStaticMethods(); if (dfWorldInfoCall != null) { dfWorldInfoCall.TryExecute(null, out netWorldInfo); if (netWorldInfo == null) { Debug.Log("World not loaded."); } else { Debug.Log("World Mode: " + netWorldInfo.mode); WorldMode = netWorldInfo.mode; } } if (GameSettings.Instance.game.askToUpdatePlugin) { CheckPlugin(); } else { Init(); } }
// Update is called once per frame void Update() { if (DFConnection.Instance.WorldMode != prevMode) { prevMode = DFConnection.Instance.WorldMode; switch (prevMode) { case dfproto.GetWorldInfoOut.Mode.MODE_DWARF: foreach (var item in dwarfUI) { item.SetActive(true); } foreach (var item in adventureUI) { item.SetActive(false); } break; case dfproto.GetWorldInfoOut.Mode.MODE_ADVENTURE: foreach (var item in dwarfUI) { item.SetActive(false); } foreach (var item in adventureUI) { item.SetActive(true); } break; default: foreach (var item in dwarfUI) { item.SetActive(false); } foreach (var item in adventureUI) { item.SetActive(false); } break; } } }