public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { if (!Configuration.Current.Fermenter.IsEnabled) { return(instructions); } List <CodeInstruction> il = instructions.ToList(); int hitCount = 0; bool found = false; for (int i = 0; i < il.Count; i++) { if (il[i].Calls(method_GameObject_SetActive)) { hitCount++; } if (hitCount == 3) { il.Insert(++i, new CodeInstruction(OpCodes.Ldarg_0)); il.Insert(++i, new CodeInstruction(OpCodes.Call, method_AddItemFromNearbyChests)); found = true; break; } } if (!found) { ZLog.LogError("Failed to apply Fermenter_SlowUpdate_Transpiler 1"); return(instructions); } found = false; for (int i = il.Count - 1; i >= 0; i--) { if (il[i].Calls(method_GameObject_SetActive)) { il.Insert(++i, new CodeInstruction(OpCodes.Ldarg_0)); il.Insert(++i, new CodeInstruction(OpCodes.Call, method_InvokeRPCTap)); return(il.AsEnumerable()); } } ZLog.LogError("Failed to apply Fermenter_SlowUpdate_Transpiler 2"); return(instructions); }
public Sprite GetSprite(uint bundle, string path, string suffix) { if (string.IsNullOrEmpty(path)) { return(null); } try { Sprite sprite = null; for (int i = 0; i < spriteList.Count; i++) { if (spriteList[i].path == path && spriteList[i].bundle == bundle) { sprite = spriteList[i].image; break; } } if (sprite == null) { if (bundle > 0) { sprite = LoadResource <Sprite>(bundle, path, suffix); } else { sprite = LoadResource <Sprite>(path, suffix, BundleType.Sprite); } if (sprite == null) { ZLog.Log("sprite is null!!! path = " + path); return(null); } PoolImageInfo <Sprite> info = new PoolImageInfo <Sprite>(); info.path = path; info.image = sprite; info.bundle = bundle; spriteList.Add(info); } return(sprite); } catch (Exception e) { Debug.LogException(e); return(null); } }
public static void Prefix(World world) { if (world.m_menu) { return; } FileStream biomeStream = null; try { biomeStream = File.OpenRead(SavingData.GetBiomeSavePath(world)); } catch { if (biomeStream == null) { UnityEngine.Debug.Log("No biome data found."); WorldGenOptions.GenOptions.hasBiomeData = false; WorldGenOptions.GenOptions.usingData = WorldGenOptions.GenOptions.defaultData; return; } } UnityEngine.Debug.Log("Biome data found for " + world.m_name + "."); WorldGenOptions.GenOptions.hasBiomeData = true; WorldGenData data = new WorldGenData(); try { BinaryReader reader = new BinaryReader(biomeStream); int count = reader.ReadInt32(); ZPackage package = new ZPackage(reader.ReadBytes(count)); data.ReadBiomeData(ref package); } catch { ZLog.LogWarning("Incomplete biome data for " + world.m_name); } finally { if (biomeStream != null) { biomeStream.Dispose(); } WorldGenOptions.GenOptions.usingData = data; } }
public Texture2D GetTexture2D(uint bundle, string path, string suffix) { if (string.IsNullOrEmpty(path)) { return(null); } try { Texture2D texture = null; for (int i = 0; i < spriteList.Count; i++) { if (spriteList[i].path == path && spriteList[i].bundle == bundle) { texture = textureList[i].image; break; } } if (texture == null) { if (bundle > 0) { texture = LoadResource <Texture2D>(bundle, path, suffix); } else { texture = LoadResource <Texture2D>(path, suffix, BundleType.Texture2D); } if (texture == null) { ZLog.Log("Texture is null!!! path = " + path); return(null); } PoolImageInfo <Texture2D> info = new PoolImageInfo <Texture2D>(); info.path = path; info.image = texture; info.bundle = bundle; textureList.Add(info); } return(texture); } catch (Exception e) { Debug.LogException(e); return(null); } }
// Token: 0x060009A6 RID: 2470 RVA: 0x000467D8 File Offset: 0x000449D8 public void Close() { ZLog.Log("Closing socket " + this.GetEndPointString()); if (this.m_peerID != CSteamID.Nil) { this.Flush(); ZLog.Log(" send queue size:" + this.m_sendQueue.Count); Thread.Sleep(100); P2PSessionState_t p2PSessionState_t; SteamNetworking.GetP2PSessionState(this.m_peerID, out p2PSessionState_t); ZLog.Log(" P2P state, bytes in send queue:" + p2PSessionState_t.m_nBytesQueuedForSend); SteamNetworking.CloseP2PSessionWithUser(this.m_peerID); SteamUser.EndAuthSession(this.m_peerID); this.m_peerID = CSteamID.Nil; } this.m_listner = false; }
// Token: 0x06000966 RID: 2406 RVA: 0x00045248 File Offset: 0x00043448 public void QueueLobbyJoin(CSteamID lobbyID) { uint num; ushort num2; CSteamID csteamID; if (SteamMatchmaking.GetLobbyGameServer(lobbyID, out num, out num2, out csteamID)) { ZLog.Log(" hostid: " + csteamID); this.m_joinUserID = csteamID; this.m_queuedJoinLobby = CSteamID.Nil; return; } ZLog.Log("Failed to get lobby data for lobby " + lobbyID + ", requesting lobby data"); this.m_queuedJoinLobby = lobbyID; SteamMatchmaking.RequestLobbyData(lobbyID); }
public string ReadTasks() { try { string path = Path.Combine(rootDirectory, "tasks.json"); if (File.Exists(path) == false) { return(""); } return(File.ReadAllText(path)); } catch (Exception e) { ZLog.Error("read flie error : " + e.Message); return(""); } }
public void ClearFile(string path) { if (string.IsNullOrEmpty(path)) { return; } try { if (File.Exists(path) == false) { return; } File.Delete(path); }catch (Exception e) { ZLog.Error("delete flie Error : " + e.Message); } }
/// <summary> /// 一次性将cache所有条目保存到某个位置,然后清除缓存。 /// </summary> public void saveCacheTo(DataLocation location) { if (location == DataLocation.local) { Directory.CreateDirectory(_persistPath); //如果已经有了就不会创建 string path = _persistPath + "/" + "cache.bytes"; FileStream stream = new FileStream(path, FileMode.Create); //create new or overwritten BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, _dataCache); _dataCache.Clear(); stream.Close(); } else if (location == DataLocation.remote) { ZLog.error("not yet"); } }
private readonly string _streamPath = Application.streamingAssetsPath; //r #region public public void save(string tag, BaseSerializableData data, DataLocation location) { data.dataTag = tag; if (location == DataLocation.memory) { writeCache(tag, data); } else if (location == DataLocation.local) { writeFile(_persistPath, tag, data); } else if (location == DataLocation.remote) { ZLog.error("not yet"); } }
// Token: 0x060002AE RID: 686 RVA: 0x00015520 File Offset: 0x00013720 public void SetModel(int index) { if (this.m_modelIndex == index) { return; } if (index < 0 || index >= this.m_models.Length) { return; } ZLog.Log("Vis equip model set to " + index); this.m_modelIndex = index; if (this.m_nview.GetZDO() != null) { this.m_nview.GetZDO().Set("ModelIndex", this.m_modelIndex); } }
void Awake() { // MCE ConfigManager.RegisterMod(pluginid, Config); VConfigMCE.Configuration.SetConfig(); harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "br.com.castcodes.vac"); ZLog.LogWarning("===================== Configuration synchronization initiated by MCE!"); // ========================= ANTI-CHEAT logger = Logger; posMap = new Dictionary <ZNetPeer, Vector3>(); toKick = new List <ZNetPeer>(); string newerversionused = IsNewVersionAvailable(); if (newerversionused == "new") { Logger.LogError("There is a newer version available of Valheim Anti Cheat."); Logger.LogWarning("Please visit " + VACPlugin.Repository + "."); } else if (newerversionused == "same") { Logger.LogInfo("AntiMods [" + version + "] is up to date."); } else if (newerversionused == "old") { Logger.LogError("You are in a version ahead of the most current one."); Logger.LogWarning( "If you are not a developer, please switch back to the most current stable version published."); Logger.LogWarning("Please visit " + VACPlugin.Repository + "."); } else if (newerversionused == "fail") { Logger.LogError("There was a fail in stipulating the version."); Logger.LogWarning("Please visit " + VACPlugin.Repository + "."); } else { Logger.LogError("There was a fail in stipulating the version."); Logger.LogWarning("Please visit " + VACPlugin.Repository + "."); } // By RaIŇİ᎐#0213 ^^ AntiMods(); }
// Token: 0x060002DD RID: 733 RVA: 0x00017358 File Offset: 0x00015558 private void OnTriggerStay(Collider collider) { if (this.m_triggerEnterOnly) { return; } if (!this.m_useTriggers) { ZLog.LogWarning("AOE got OnTriggerStay but trigger damage is disabled in " + base.gameObject.name); return; } if (this.m_nview != null && (!this.m_nview.IsValid() || !this.m_nview.IsOwner())) { return; } this.OnHit(collider, collider.transform.position); }
private async Task DownServerBundle() { while (true) { try { using (this.webRequest = ComponentFactory.Create<UnityWebRequestAsync>()) { DownloadInfo.IsStart = true; if (ETModel.Define.IsABNotFromServer) { await this.webRequest.DownloadAsync(GetUrlWithPlatform(ETModel.Define.SelfResourceServerIpAndPort + "/") + "StreamingAssets/" + this.downloadingBundle); } else { await this.webRequest.DownloadAsync(GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + this.downloadingBundle); } //await this.webRequest.DownloadAsync(GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + this.downloadingBundle); byte[] data = this.webRequest.Request.downloadHandler.data; string path = Path.Combine(PathHelper.AppHotfixResPath, this.downloadingBundle); if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } using (FileStream fs = new FileStream(path, FileMode.Create)) { fs.Write(data, 0, data.Length); ZLog.Info($"更新Bundle:{path} 完成"); } var p = this.Progress; BundleRealProgress?.Invoke(p); } } catch (Exception e) { Log.Error($"download bundle error: {this.downloadingBundle}\n{e}"); //如果报错了,等1秒 await UniRx.Async.UniTask.Delay(1); continue; } break; } }
// Token: 0x06000736 RID: 1846 RVA: 0x0003A40C File Offset: 0x0003860C private ZBroastcast() { ZLog.Log("opening zbroadcast"); this.m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.m_socket.EnableBroadcast = true; try { this.m_listner = new UdpClient(6542); this.m_listner.EnableBroadcast = true; this.m_listner.BeginReceive(new AsyncCallback(this.GotPackage), null); } catch (Exception ex) { this.m_listner = null; ZLog.Log("Error creating zbroadcast socket " + ex.ToString()); } }
// Token: 0x060006A7 RID: 1703 RVA: 0x00037590 File Offset: 0x00035790 public void Print() { for (int i = 0; i < this.m_inventory.Count; i++) { ItemDrop.ItemData itemData = this.m_inventory[i]; ZLog.Log(string.Concat(new object[] { i.ToString(), ": ", itemData.m_shared.m_name, " ", itemData.m_stack, " / ", itemData.m_shared.m_maxStackSize })); } }
// Token: 0x060006D7 RID: 1751 RVA: 0x0003891C File Offset: 0x00036B1C private void PickupUpdate() { if (!this.m_nview.IsValid()) { return; } if (this.CanPickup()) { ZLog.Log("Im finally the owner"); base.CancelInvoke("PickupUpdate"); this.Load(); (this.m_pickupRequester as Player).Pickup(base.gameObject); this.Save(); return; } ZLog.Log("Im still nto the owner"); }
// Token: 0x060008BD RID: 2237 RVA: 0x00042420 File Offset: 0x00040620 public void Dispose() { if (this.m_ntpThread != null) { ZLog.Log("Stoping ntp thread"); this.m_lock.WaitOne(); this.m_stop = true; this.m_ntpThread.Abort(); this.m_lock.ReleaseMutex(); this.m_ntpThread = null; } if (this.m_lock != null) { this.m_lock.Close(); this.m_lock = null; } }
private void BundleCompleteHandle(string uid, bool success) { if (success) { AssetBundle bundle = ZBundleManager.Instance.GetBundle(uid); if (bundle == null || bundle.GetAllScenePaths() == null || bundle.GetAllScenePaths().Length < 1) { return; } ShowLoading = true; TryLoad(bundle, LoadSceneMode.Additive, true); } else { ZLog.Warning("SceneController...can not load bundle!!! try check path = " + uid + " is valid!!"); } }
public bool CanPassTypeTest(CollisionAbility me, CollisionAbility other) { if (me == null || other == null) { return(false); } if (_collisionConfig != null) { return(_collisionConfig[(int)me.Type, (int)other.Type]); } else { ZLog.warn("no collison config file attached."); return(true); } }
public long GetFileSize(string path) { try { if (!File.Exists(path)) { return(0); } FileInfo info = new FileInfo(path); return(info.Length); } catch (Exception e) { ZLog.Error("get file size Error : " + e.Message); return(0); } }
// Token: 0x06000DB0 RID: 3504 RVA: 0x00061B64 File Offset: 0x0005FD64 public void Dispose() { if (this.m_builder != null) { ZLog.Log("Stoping build thread"); this.m_lock.WaitOne(); this.m_stop = true; this.m_builder.Abort(); this.m_lock.ReleaseMutex(); this.m_builder = null; } if (this.m_lock != null) { this.m_lock.Close(); this.m_lock = null; } }
private AudioInfo GetAudioModel(long id) { if (audioDataList == null || audioDataList.Count < 1) { Debug.LogError("Can not find all the audio data!!!"); return(new AudioInfo()); } for (int i = 0; i < audioDataList.Count; i++) { if (audioDataList[i].id == id) { return(audioDataList[i]); } } ZLog.Warning("Can not find the audio data!!!that id = " + id); return(new AudioInfo()); }
private EffectInfo GetEffectModel(long id) { if (effectDataList == null || effectDataList.Count < 1) { Debug.LogError("Can not find all the effect data!!!"); return(new EffectInfo()); } for (int i = 0; i < effectDataList.Count; i++) { if (effectDataList[i].id == id) { return(effectDataList[i]); } } ZLog.Warning("Can not find the effect data!!!that id = " + id); return(new EffectInfo()); }
private T GetPrefab <T>(uint bundle, string path, BundleType type) where T : Component { if (string.IsNullOrEmpty(path)) { return(null); } try { GameObject obj; prefabDic.TryGetValue(path, out obj); if (obj == null) { if (bundle > 0) { obj = LoadResource <GameObject>(bundle, path, "prefab"); } else { obj = LoadResource <GameObject>(path); } if (obj == null) { ZLog.Log("Can not find prefab !!!! that name = " + path); return(null); } if (prefabDic.ContainsKey(path)) { prefabDic[path] = obj; } else { prefabDic.Add(path, obj); } } if (obj != null) { return(obj.GetComponent <T>()); } return(null); } catch (Exception e) { Debug.LogException(e); return(null); } }
private IEnumerator GetRequest(string url, System.Action <Dictionary <string, object> > callback) { UnityWebRequest unityWebRequest = UnityWebRequest.Get(url); var webRequest = unityWebRequest.SendWebRequest(); if (!unityWebRequest.isHttpError && !unityWebRequest.isNetworkError) { ZLog.Info("[Get] URL: " + url); while (!webRequest.isDone) { yield return(new WaitForSeconds(0.1f)); if (EditorUtility.DisplayCancelableProgressBar("Downloading...", "", webRequest.progress)) { ZLog.Error(string.Format("[Get] URL: {0}\n{1}", url, unityWebRequest.error)); CancelDownload(); } } EditorUtility.ClearProgressBar(); string json = unityWebRequest.downloadHandler.text; ZLog.Info("Data: " + json); Dictionary <string, object> dic = new Dictionary <string, object>(); // try { dic = Json.Deserialize(json) as Dictionary <string, object>; if (callback != null) { callback(dic); } } catch (Exception e) { ZLog.Error("[Get] URL: " + url + "\n" + "[Parse Data] Error: " + e.ToString()); } } else { ZLog.Error("[Error] Load Fail: " + unityWebRequest.error); } }
// Token: 0x0600068F RID: 1679 RVA: 0x00036C30 File Offset: 0x00034E30 private bool AddItem(ItemDrop.ItemData item, int amount, int x, int y) { amount = Mathf.Min(amount, item.m_stack); if (x < 0 || y < 0 || x >= this.m_width || y >= this.m_height) { return(false); } ItemDrop.ItemData itemAt = this.GetItemAt(x, y); bool result; if (itemAt != null) { if (itemAt.m_shared.m_name != item.m_shared.m_name || (itemAt.m_shared.m_maxQuality > 1 && itemAt.m_quality != item.m_quality)) { return(false); } int num = itemAt.m_shared.m_maxStackSize - itemAt.m_stack; if (num <= 0) { return(false); } int num2 = Mathf.Min(num, amount); itemAt.m_stack += num2; item.m_stack -= num2; result = (num2 == amount); ZLog.Log(string.Concat(new object[] { "Added to stack", itemAt.m_stack, " ", item.m_stack })); } else { ItemDrop.ItemData itemData = item.Clone(); itemData.m_stack = amount; itemData.m_gridPos = new Vector2i(x, y); this.m_inventory.Add(itemData); item.m_stack -= amount; result = true; } this.Changed(); return(result); }
// Token: 0x060006D6 RID: 1750 RVA: 0x00038894 File Offset: 0x00036A94 private void RPC_RequestOwn(long uid) { ZLog.Log(string.Concat(new object[] { "Player ", uid, " wants to pickup ", base.gameObject.name, " im: ", ZDOMan.instance.GetMyID() })); if (!this.m_nview.IsOwner()) { ZLog.Log(" but im not the owner"); return; } this.m_nview.GetZDO().SetOwner(uid); }
// Token: 0x06000909 RID: 2313 RVA: 0x00043220 File Offset: 0x00041420 private void UpdatePing(float dt) { this.m_pingTimer += dt; if (this.m_pingTimer > ZRpc.m_pingInterval) { this.m_pingTimer = 0f; this.m_pkg.Clear(); this.m_pkg.Write(0); this.m_pkg.Write(true); this.SendPackage(this.m_pkg); } this.m_timeSinceLastPing += dt; if (this.m_timeSinceLastPing > ZRpc.m_timeout) { ZLog.LogWarning("ZRpc timeout detected"); this.m_socket.Close(); } }
/// <summary> /// 初始化摄像头 /// </summary> public IEnumerator InitInspector() { ZLog.Log("InitInspector web camera!!!! "); render.enabled = true; vcamera.enabled = true; yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { InitCamera(); yield break; } else { render.enabled = false; vcamera.enabled = false; } }