public void Stop() { Puase(); mTime = 0; UpdaterNotice.RemoveSceneUpdater(this); }
private void SendLoadedNotice() { if (m_LoadedNoticeInfo.IsSendIDAsNotice && !m_LoadedNoticeInfo.IsReadyNoticeSend) { if (m_LoadedNoticeInfo.ApplyDefaultNoticeType) { mIDAsNotice = Pooling <Notice> .From(); } else { ApplyCustomNotice(); } if (m_LoadedNoticeInfo.ApplyCallLate) { UpdaterNotice.SceneCallLater(SendLoadedNoticeAndRelease); } else { SendLoadedNoticeAndRelease(0); } } else { } }
/// <summary> /// 解压功能(下载后直接解压压缩文件到指定目录) /// </summary> public void SaveZip(string ID, byte[] zipByte, string password) { Operation = ZipOperation.Decompress; ZipID = ID; mPassword = password; //直接使用 将byte转换为Stream,省去先保存到本地在解压的过程 Stream stream = new MemoryStream(zipByte); mZipInputStream = new ZipInputStream(stream); if (!string.IsNullOrEmpty(mPassword)) { mZipInputStream.Password = mPassword; } else { } if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } else { } UpdaterNotice.AddUpdater(this); }
public static void AddUpdater(IUpdate target) { UpdaterNotice notice = Pooling <UpdaterNotice> .From(); notice.ParamValue = target; ShipDockConsts.NOTICE_ADD_UPDATE.Broadcast(notice); Pooling <UpdaterNotice> .To(notice); }
public static void RemoveSceneUpdater(IUpdate target) { UpdaterNotice notice = Pooling <UpdaterNotice> .From(); notice.ParamValue = target; ShipDockConsts.NOTICE_REMOVE_SCENE_UPDATE.Broadcast(notice); Pooling <UpdaterNotice> .To(notice); }
public void Stop() { Pause(); Time = 0; IsStarted = false; IsPause = false; UpdaterNotice.RemoveSceneUpdater(this); }
public void Recreate(float totalTime, Action method, Func <bool> cancelCondition = default, int repeats = 0) { TotalRepeats = repeats; TotalTime = totalTime; Completion = method; mRepeats = repeats; Repeatable = mRepeats > 0; mCancelChecker = cancelCondition; UpdaterNotice.RemoveSceneUpdater(this); }
public void RemoveUpdate(Action <int> method) { if (mUpdaterMapper.ContainsKey(method)) { MethodUpdater updater = mUpdaterMapper.GetValue(method, true); UpdaterNotice.RemoveSceneUpdater(updater); updater.Dispose(); } else { } }
/// <summary>移除一个需要刷帧的对象</summary> protected virtual void RemoveUpdate(INoticeBase <int> param) { mNoticeRemoved = param as UpdaterNotice; if (mNoticeRemoved != null || mNoticeRemoved.ParamValue == null || (mNoticeAdded.NotifcationSender != null && !mNoticeAdded.CheckSender(this))) { return; } mItemRemoved = mNoticeRemoved.ParamValue; RemoveUpdaterItem(0); mNoticeRemoved = null; }
public void Start() { HasStart = true; IsTimeCounting = true; IsStarted = true; if (IsPause) { IsPause = false; } else { UpdaterNotice.AddSceneUpdater(this); } }
private void OnRemoveItem(INoticeBase <int> param) { if (IsDisposed) { return; } UpdaterNotice notice = param as UpdaterNotice; IUpdate target = notice.ParamValue; if (!mDeleted.Contains(target)) { mDeleted.Add(target); } }
public void AddUpdate(Action <int> method) { if (!mUpdaterMapper.ContainsKey(method)) { MethodUpdater updater = new MethodUpdater { Update = method }; mUpdaterMapper[method] = updater; UpdaterNotice.AddSceneUpdater(updater); } else { } }
public void OnUpdate(int dTime) { Uncompress(); if (IsCompleted) { UpdaterNotice.RemoveUpdater(this); FileStream.Close(); FileStream.Dispose(); mZipInputStream = default; } else { } }
public void AddLateUpdate(Action method) { if (!mLateUpdaterMapper.ContainsKey(method)) { MethodUpdater updater = new MethodUpdater { LateUpdate = method, IsLateUpdate = true, IsUpdate = false, }; mLateUpdaterMapper[method] = updater; UpdaterNotice.AddSceneUpdater(updater); } else { } }
public void Dispose() { mIsDisposed = true; ShipDockConsts.NOTICE_REMOVE_UPDATE.Remove(RemoveUpdate); ShipDockConsts.NOTICE_ADD_UPDATE.Remove(AddUpdate); Utils.Reclaim(ref mTicksList); Utils.Reclaim(ref mListDeleted); Utils.Reclaim(mTicksLater); Utils.Reclaim(mThreadTicks); mItem = null; mItemAdded = null; mItemRemoved = null; mNoticeAdded = null; mNoticeRemoved = null; mTicksLater = null; mThreadTicks = null; }
private void OnStateFrameUpdater(IState state, bool isAdd) { if (isAdd) { if (!mStateUpdaters.IsContainsKey(state)) { MethodUpdater updater = new MethodUpdater { Update = state.UpdateState }; mStateUpdaters[state] = updater; UpdaterNotice.AddSceneUpdater(updater); } } else { IUpdate updater = mStateUpdaters[state]; UpdaterNotice.RemoveSceneUpdater(updater); } }
private void OnSceneUpdateReady(INoticeBase <int> obj) { ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Remove(OnSceneUpdateReady); MethodUpdater updater = ShipDockComponentManagerSetting.isMergeUpdateMode ? new MethodUpdater { Update = MergeComponentUpdateModeInScene } : new MethodUpdater { Update = SingleFrameComponentUpdateModeInScene }; UpdaterNotice notice = Pooling <UpdaterNotice> .From(); notice.ParamValue = updater; ShipDockConsts.NOTICE_ADD_SCENE_UPDATE.Broadcast(notice); Pooling <UpdaterNotice> .To(notice); }
private void OnFSMFrameUpdater(IStateMachine fsm, bool isAdd) { if (mFSMUpdaters == default) { return; } if (isAdd) { MethodUpdater updater = new MethodUpdater { Update = fsm.UpdateState }; mFSMUpdaters[fsm] = updater; UpdaterNotice.AddSceneUpdater(updater); } else { IUpdate updater = mFSMUpdaters[fsm]; UpdaterNotice.RemoveSceneUpdater(updater); } }
public void Clean() { MethodUpdater updater; int max = mUpdaterMapper.Size; for (int i = 0; i < max; i++) { updater = mUpdaterMapper.GetValueByIndex(i); UpdaterNotice.RemoveSceneUpdater(updater); updater.Dispose(); } max = mUpdaterMapper.Size; for (int i = 0; i < max; i++) { updater = mLateUpdaterMapper.GetValueByIndex(i); UpdaterNotice.RemoveSceneUpdater(updater); updater.Dispose(); } mUpdaterMapper?.Clear(); mLateUpdaterMapper?.Clear(); }
private void OnFSMFrameUpdater(IStateMachine fsm, bool isAdd) { if (isAdd) { if (!mFSMUpdaters.ContainsKey(fsm)) { MethodUpdater updater = new MethodUpdater { Update = fsm.UpdateState }; mFSMUpdaters[fsm] = updater; UpdaterNotice.AddSceneUpdater(updater); } else { } } else { IUpdate updater = mFSMUpdaters.GetValue(fsm, true); UpdaterNotice.RemoveSceneUpdater(updater); } }
private void OnServersInit() { Components = new ShipDockComponentManager { FrameTimeInScene = (int)(UnityEngine.Time.deltaTime * 1000) }; MethodUpdater updater = ShipDockComponentManagerSetting.isMergeUpdateMode ? new MethodUpdater { Update = MergeComponentUpdateMode } : new MethodUpdater { Update = SingleFrameComponentUpdateMode }; UpdaterNotice notice = Pooling <UpdaterNotice> .From(); notice.ParamValue = updater; ShipDockConsts.NOTICE_ADD_UPDATE.Broadcast(notice); Pooling <UpdaterNotice> .To(notice); ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Add(OnSceneUpdateReady); }
private void ComponentUnitUpdateInScene(Action <int> target) { UpdaterNotice.SceneCallLater(target); }
public void Start() { HasStart = true; IsTimeCounting = true; UpdaterNotice.AddSceneUpdater(this); }
private void DuringDecompress() { if (!IsCompleted) { try { int size; int fixSize = 2048; byte[] data; string fileName; while ((mEnt = mZipInputStream.GetNextEntry()) != null) { if (!string.IsNullOrEmpty(mEnt.Name)) { fileName = Path.Combine(SavePath, mEnt.Name); #region Android fileName = fileName.Replace('\\', '/'); "log:Start uncompress zip, file name is {0}".Log(fileName); if (fileName.EndsWith(StringUtils.PATH_SYMBOL)) { Directory.CreateDirectory(fileName); continue; } else { } #endregion FileStream = File.Create(fileName); size = fixSize; data = new byte[size]; while (true) { size = mZipInputStream.Read(data, 0, data.Length); #if LOG_UNPRESS_ZIP bool isReadAll = size <= 0; if (isReadAll) { "log:File {0} uncompress end.".Log(fileName); } else { "log:Zip stream read size {0}".Log(size.ToString()); } #endif if (size > 0) { FileStream.Write(data, 0, size);//解决读取不完整情况 } else { break; } } } else { "error".Log("Next Entry name is empty.."); } } } catch (Exception e) { "error:Zip exception {0}".Log(e.ToString()); } finally { if (FileStream != null) { FileStream.Close(); FileStream.Dispose(); } else { } if (mZipInputStream != null) { mZipInputStream.Close(); mZipInputStream.Dispose(); } else { } if (mEnt != null) { mEnt = null; } else { } GC.Collect(); GC.Collect(1); IsCompleted = true; Operation = ZipOperation.None; UpdaterNotice.SceneCallLater((t) => { OnCompleted?.Invoke(); }); } } else { } }