/// <summary> /// Remove the first surface with the specified ID if one exists in <see cref="SurfaceObjects"/>. /// </summary> /// <param name="surfaceID">The ID of the surface to remove.</param> /// <param name="destroyGameObject">True to destroy the <see cref="SurfaceObject.Object"/> associated with the surface, false otherwise.</param> /// <param name="destroyMeshes">True to destroy the meshes associated with the surface, false otherwise.</param> /// <returns>The surface object if one was found and removed or null if one was not found.</returns> protected SurfaceObject?RemoveSurfaceIfFound(int surfaceID, bool destroyGameObject = true, bool destroyMeshes = true) { SurfaceObject?removed = null; for (int iSurface = 0; iSurface < surfaceObjectsWriteable.Count; iSurface++) { SurfaceObject surface = surfaceObjectsWriteable[iSurface]; if (surface.ID == surfaceID) { surfaceObjectsWriteable.RemoveAt(iSurface); var handlers = SurfaceRemoved; if (handlers != null) { handlers(this, DataEventArgs.Create(surface)); } CleanUpSurface(surface, destroyGameObject, destroyMeshes); removed = surface; break; } } return(removed); }
private void OnApplicationQuit() { if (GameEntry.Event != null) { DataEventArgs dataEventArgs = DataEventArgs.Create(this, Convert.ToInt32(EventIds.ApplicationQuit)); GameEntry.Event.FireNow(dataEventArgs.EventId, dataEventArgs); } }
private void OnApplicationFocus(bool focusStatus) { if (GameEntry.Event != null) { DataEventArgs dataEventArgs = DataEventArgs.Create(this, Convert.ToInt32(EventIds.ApplicationFocus), focusStatus); GameEntry.Event.FireNow(dataEventArgs.EventId, dataEventArgs); } }
private void UpdateCore(T originalValue, Future<T> future) { if (null != FutureStarted) { FutureStarted(this, DataEventArgs.Create(future)); } m_pendingUpdateList.Add(Tuple.Create(originalValue, future)); future.AddCompletedCallback(m_context.BindAsPost<Future<T>>(OnUpdateCompleted)); }
private void AddCore(Future<T> future) { if (null != FutureStarted) { FutureStarted(this, DataEventArgs.Create(future)); } m_pendingAddList.Add(future); future.AddCompletedCallback(m_context.BindAsPost<Future<T>>(x => OnAddCompleted(x))); }
/// <summary> /// Add the surface to <see cref="SurfaceObjects"/>. /// </summary> /// <param name="toAdd">The surface to add.</param> protected void AddSurfaceObject(SurfaceObject toAdd) { surfaceObjectsWriteable.Add(toAdd); var handlers = SurfaceAdded; if (handlers != null) { handlers(this, DataEventArgs.Create(toAdd)); } }
protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown) { GameEntry.Event.Unsubscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess); GameEntry.Event.Unsubscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure); GameEntry.Event.Unsubscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate); GameEntry.Event.Unsubscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset); DataEventArgs dataEventArgs = DataEventArgs.Create(this, LoadingForm.UpdateProgressEventId, LoadingStep.ChangeScene, 1); GameEntry.Event.Fire(dataEventArgs.EventId, dataEventArgs); base.OnLeave(procedureOwner, isShutdown); }
private void OnLoadSceneUpdate(object sender, GameEventArgs e) { LoadSceneUpdateEventArgs ne = (LoadSceneUpdateEventArgs)e; if (ne.UserData != this) { return; } DataEventArgs dataEventArgs = DataEventArgs.Create(this, LoadingForm.UpdateProgressEventId, LoadingStep.ChangeScene, ne.Progress); GameEntry.Event.Fire(dataEventArgs.EventId, dataEventArgs); Log.Info("Load scene '{0}' update, progress '{1}'.", ne.SceneAssetName, ne.Progress.ToString("P2")); }
private void UpdateLoadedFlag(string assetName) { loadedFlag[assetName] = true; float i = 0; foreach (var item in loadedFlag) { i = item.Value ? i + 1 : i; } float progressNum = i / loadedFlag.Count; DataEventArgs dataEventArgs = DataEventArgs.Create(this, LoadingForm.UpdateProgressEventId, LoadingStep.Preload, progressNum); GameEntry.Event.Fire(dataEventArgs.EventId, dataEventArgs); }
private void ProcessFutureCompletion(Future<T> future, Action del) { try { del(); if (null != FutureCompleted) { FutureCompleted(this, DataEventArgs.Create(future)); } } catch (FutureException) { if (null != FutureErrored) { FutureErrored(this, DataEventArgs.Create(future)); } } }
/// <summary> /// Update the first surface with a matching ID if one exists in <see cref="SurfaceObjects"/>, otherwise add the surface as new. /// </summary> /// <param name="toUpdateOrAdd">The surface to be updated or added.</param> /// <param name="destroyGameObjectIfReplaced">If a surface is updated, and a game object is being replaced, pass true to destroy the outgoing game object or false otherwise.</param> /// <param name="destroyMeshesIfReplaced">If a surface is updated, and new meshes are replacing old meshes, pass true to destroy the outgoing meshes or false otherwise.</param> /// <returns>The surface object that was updated or null if one was not found meaning a new surface was added.</returns> protected SurfaceObject?UpdateOrAddSurfaceObject(SurfaceObject toUpdateOrAdd, bool destroyGameObjectIfReplaced = true, bool destroyMeshesIfReplaced = true) { SurfaceObject?replaced = null; for (int iSurface = 0; iSurface < surfaceObjectsWriteable.Count; iSurface++) { SurfaceObject existing = surfaceObjectsWriteable[iSurface]; if (existing.ID == toUpdateOrAdd.ID) { surfaceObjectsWriteable[iSurface] = toUpdateOrAdd; var handlers = SurfaceUpdated; if (handlers != null) { handlers(this, DataEventArgs.Create(new SurfaceUpdate { Old = existing, New = toUpdateOrAdd })); } CleanUpSurface( existing, destroyGameObjectIfReplaced, destroyMeshesIfReplaced, objectToPreserve: toUpdateOrAdd.Object, meshToPreserveA: toUpdateOrAdd.Filter.sharedMesh, meshToPreserveB: toUpdateOrAdd.Collider.sharedMesh ); replaced = existing; break; } } if (replaced == null) { AddSurfaceObject(toUpdateOrAdd); } return(replaced); }
static int _m_Create_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { object _sender = translator.GetObject(L, 1, typeof(object)); int _eventId = LuaAPI.xlua_tointeger(L, 2); object[] _param = translator.GetParams <object>(L, 3); DataEventArgs gen_ret = DataEventArgs.Create(_sender, _eventId, _param); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }