public static IAddressableObservable <Object> ToObservable(this AssetReference reference) { var observable = ClassPool.Spawn <AddressableObservable <AssetReference, Object, Object> >(); observable.Initialize(reference); return(observable); }
public IUniRoutineTask AddRoutine(IEnumerator enumerator, bool moveNextImmediately = true, Action finalAction = null) { if (enumerator == null) { return(null); } var routine = ClassPool.Spawn <UniRoutineTask>(); #if UNITY_EDITOR if (routine.IsCompleted == false) { GameLog.LogError("ROUTINE: routine task is not completed"); } #endif var id = idCounter++; routine.Initialize(id, enumerator, moveNextImmediately); if (finalAction != null) { routine.LifeTime.AddCleanUpAction(finalAction); } routineTasks.Add(routine); activeRoutines[id] = routine; return(routine); }
public override ActorModel Create() { var cellModel = ClassPool.Spawn <CellItemModel>(); cellModel.Initialize(this); return(cellModel); }
public IEnumerable <T> LoadCommands <T>(Func <T, bool> filter = null) where T : IUnityBuildCommand { var commandsBuffer = ClassPool.Spawn <List <IUnityBuildCommand> >(); commandsBuffer.AddRange(PreBuildCommands); commandsBuffer.AddRange(PostBuildCommands); foreach (var command in commandsBuffer) { if (command.IsActive == false) { continue; } if (!(command is T targetCommand)) { continue; } if (filter != null && !filter(targetCommand)) { continue; } yield return(targetCommand); } commandsBuffer.Despawn(); }
public static IDisposableItem AsDisposable(this RoutineHandle handler) { var disposable = ClassPool.Spawn <DisposableAction>(); disposable.Initialize(() => UniRoutineManager.TryToStopRoutine(handler)); return(disposable); }
public static void InitPooler() { if (s_Pooler == null) { s_Pooler = new ClassPool <T>(); } }
public override void Validate() { if (string.IsNullOrEmpty(guid)) { guid = System.Guid.NewGuid().ToString(); } _allNodes?.Clear(); nodes.Clear(); serializableNodes.RemoveAll(x => x == null || x is Object); nodes.AddRange(GetComponents <Node>()); nodes.RemoveAll(x => !x); nodes.Remove(this); var nodeItems = ClassPool.Spawn <List <INode> >(); nodeItems.AddRange(serializableNodes); nodeItems.AddRange(nodes); foreach (var nodeItem in nodeItems) { nodeItem.SetUpData(this); nodeItem.Validate(); } nodeItems.Despawn(); }
public static IAddressableObservable <TApi> ToObservable <TApi>(this AssetReferenceGameObject reference) where TApi : class { var observable = ClassPool.Spawn <AddressableObservable <AssetReference, GameObject, TApi> >(); observable.Initialize(reference); return(observable); }
public static IAddressableObservable <TData> ToObservable <TData>(this AssetReferenceT <TData> reference) where TData : Object { var observable = ClassPool.Spawn <AddressableObservable <AssetReferenceT <TData>, TData, TData> >(); observable.Initialize(reference); return(observable); }
public static IEnumerator WaitForEndOfFrame(this object source) { var waitForEndFrame = ClassPool.Spawn <WaitForEndOfFrame>().Initialize(); yield return(waitForEndFrame); waitForEndFrame.Despawn(); }
public Actor Create(int type, int width, int height) { var actor = ClassPool.Spawn <Actor>(); var model = _info.Create(type, width, height); actor.SetModel(model); return(actor); }
public static IEnumerator WaitForSeconds(this object source, float delay) { var waitForSeconds = ClassPool. Spawn <WaitForSecondRoutine>(). Initialize(delay); yield return(waitForSeconds); waitForSeconds.Despawn(); }
private IEnumerable <IUnityBuildCommand> FilterActiveCommands(IEnumerable <BuildCommandStep> commands) { var commandsBuffer = ClassPool.Spawn <List <IUnityBuildCommand> >(); foreach (var command in commands) { commandsBuffer.AddRange(command.GetCommands()); } return(commandsBuffer); }
public static void UpdatePorts(this INode node, NodeGraph data) { var portList = ClassPool.Spawn <List <INodePort> >(); node.Initialize(data); portList.AddRange(node.Ports); node.UpdateNodePorts(); portList.Despawn(); }
/// <summary> /// Creates a new Interaction Result pool with the given key and size. /// </summary> /// <typeparam name="T">The IPoolable type to use.</typeparam> /// <param name="key">The name of the pool, used to retrieve objects.</param> /// <returns>The newly created pool, or the existing pool if there is one with the same key.</returns> public ClassPool CreateInteractionResultPool <T>(string key) where T : class, IPoolable, new() { if (interactionResultPools.ContainsKey(key)) { return(interactionResultPools[key]); } ClassPool pool = new ClassPool(); interactionResultPools.Add(key, pool); return(pool); }
public static RemoteDataChange Create(string FullPath, string FieldName, object FieldValue, Action <RemoteDataChange> ApplyCallback) { var change = ClassPool.SpawnOrCreate(() => new RemoteDataChange()); change.FullPath = FullPath; change.FieldName = FieldName; change.FieldValue = FieldValue; change.ApplyCallback = ApplyCallback; return(change); }
public void CloseAll() { var buffer = ClassPool.Spawn <List <IView> >(); buffer.AddRange(_views); _views.Clear(); foreach (var view in buffer) { view.Close(); } buffer.Despawn(); }
public BinaryModule ToBinary() { // 生成methods的时候可能依然会修改常量池,因此先做 BinaryMethod[] binaryMethods = Methods.Select(m => m?.ToBinary()).ToArray(); return(new BinaryModule { ModuleNameIndex = ModuleNameIndex, StringPool = StringPool.ToArray(), ClassPool = ClassPool.ToArray(), MethodPool = MethodPool.ToArray(), FieldPool = FieldPool.ToArray(), Methods = binaryMethods }); }
private void CreatePortConnections() { var portsConnections = ClassPool.Spawn <List <NodePortConnection> >(); foreach (var nodeItem in uniNodes) { var nodeView = nodeItem.Value; var node = nodeView.SourceNode; foreach (var outputPortView in nodeView.outputPorts) { var portData = outputPortView.portData; var sourcePort = node.GetPort(portData.displayName); foreach (var connection in sourcePort.Connections) { if (!uniNodes.TryGetValue(connection.NodeId, out var connectionNode)) { continue; } var targetNode = connectionNode.SourceNode; var port = targetNode.GetPort(connection.PortName); if (port.Direction != PortIO.Input) { continue; } var inputPortView = connectionNode.GetPort(nameof(connectionNode.inputs), connection.PortName); portsConnections.Add(new NodePortConnection() { source = inputPortView, target = outputPortView }); } } } foreach (var nodePortConnection in portsConnections) { var inputPortView = nodePortConnection.source; var outputPortView = nodePortConnection.target; Connect(inputPortView, outputPortView); } portsConnections.Despawn(); }
protected override async UniTask OnContextActivate(IContext context) { var results = ClassPool.Spawn <List <AsyncContextDataSource> >(); await sources.LoadAssetsTaskAsync(results, LifeTime); foreach (var dataSource in results) { await dataSource.RegisterAsync(context); } results.Despawn(); Complete(); }
public virtual void notifyConstructDone() { mGameFramework = GameFramework.mGameFramework; mCommandSystem = mGameFramework.getSystem(Typeof <CommandSystem>()) as CommandSystem; mAudioManager = mGameFramework.getSystem(Typeof <AudioManager>()) as AudioManager; mGameSceneManager = mGameFramework.getSystem(Typeof <GameSceneManager>()) as GameSceneManager; mCharacterManager = mGameFramework.getSystem(Typeof <CharacterManager>()) as CharacterManager; mLayoutManager = mGameFramework.getSystem(Typeof <LayoutManager>()) as LayoutManager; mKeyFrameManager = mGameFramework.getSystem(Typeof <KeyFrameManager>()) as KeyFrameManager; mGlobalTouchSystem = mGameFramework.getSystem(Typeof <GlobalTouchSystem>()) as GlobalTouchSystem; mShaderManager = mGameFramework.getSystem(Typeof <ShaderManager>()) as ShaderManager; #if !UNITY_IOS && !NO_SQLITE mSQLite = mGameFramework.getSystem(Typeof <SQLite>()) as SQLite; #endif mDataBase = mGameFramework.getSystem(Typeof <DataBase>()) as DataBase; mCameraManager = mGameFramework.getSystem(Typeof <CameraManager>()) as CameraManager; mResourceManager = mGameFramework.getSystem(Typeof <ResourceManager>()) as ResourceManager; mApplicationConfig = mGameFramework.getSystem(Typeof <ApplicationConfig>()) as ApplicationConfig; mFrameConfig = mGameFramework.getSystem(Typeof <FrameConfig>()) as FrameConfig; mObjectPool = mGameFramework.getSystem(Typeof <ObjectPool>()) as ObjectPool; mInputManager = mGameFramework.getSystem(Typeof <InputManager>()) as InputManager; mSceneSystem = mGameFramework.getSystem(Typeof <SceneSystem>()) as SceneSystem; mClassPool = mGameFramework.getSystem(Typeof <ClassPool>()) as ClassPool; mClassPoolThread = mGameFramework.getSystem(Typeof <ClassPoolThread>()) as ClassPoolThread; mListPool = mGameFramework.getSystem(Typeof <ListPool>()) as ListPool; mListPoolThread = mGameFramework.getSystem(Typeof <ListPoolThread>()) as ListPoolThread; mDictionaryPool = mGameFramework.getSystem(Typeof <DictionaryPool>()) as DictionaryPool; mDictionaryPoolThread = mGameFramework.getSystem(Typeof <DictionaryPoolThread>()) as DictionaryPoolThread; mBytesPool = mGameFramework.getSystem(Typeof <BytesPool>()) as BytesPool; mBytesPoolThread = mGameFramework.getSystem(Typeof <BytesPoolThread>()) as BytesPoolThread; mAndroidPluginManager = mGameFramework.getSystem(Typeof <AndroidPluginManager>()) as AndroidPluginManager; mAndroidAssetLoader = mGameFramework.getSystem(Typeof <AndroidAssetLoader>()) as AndroidAssetLoader; mHeadTextureManager = mGameFramework.getSystem(Typeof <HeadTextureManager>()) as HeadTextureManager; mTimeManager = mGameFramework.getSystem(Typeof <TimeManager>()) as TimeManager; mMovableObjectManager = mGameFramework.getSystem(Typeof <MovableObjectManager>()) as MovableObjectManager; mEffectManager = mGameFramework.getSystem(Typeof <EffectManager>()) as EffectManager; mTPSpriteManager = mGameFramework.getSystem(Typeof <TPSpriteManager>()) as TPSpriteManager; mSocketFactory = mGameFramework.getSystem(Typeof <SocketFactory>()) as SocketFactory; mSocketFactoryThread = mGameFramework.getSystem(Typeof <SocketFactoryThread>()) as SocketFactoryThread; mPathKeyframeManager = mGameFramework.getSystem(Typeof <PathKeyframeManager>()) as PathKeyframeManager; mEventSystem = mGameFramework.getSystem(Typeof <EventSystem>()) as EventSystem; mStringBuilderPool = mGameFramework.getSystem(Typeof <StringBuilderPool>()) as StringBuilderPool; mStringBuilderPoolThread = mGameFramework.getSystem(Typeof <StringBuilderPoolThread>()) as StringBuilderPoolThread; #if USE_ILRUNTIME mILRSystem = mGameFramework.getSystem(Typeof <ILRSystem>()) as ILRSystem; #endif }
private void ValidateGraph() { var removed = ClassPool.Spawn <List <BaseNode> >(); foreach (var node in nodes) { if (node is UniBaseNode uniBaseNode && !uniNodes.ContainsKey(uniBaseNode.sourceId)) { removed.Add(node); } } removed.ForEach(RemoveNode); removed.Despawn(); uniExposedParameters.RemoveAll(x => x == null); }
public static Getter generateGetter(OgnlContext context, string code) // throws OgnlException { string className = NAME_FACTORY.getNewClassName(); try { ClassPool pool = (ClassPool)pools [(context.getClassResolver())]; EnhancedClassLoader loader = (EnhancedClassLoader)loaders [(context.getClassResolver())]; CtClass newClass; CtClass ognlContextClass; CtClass objectClass; CtClass stringClass; CtMethod method; byte[] byteCode; Type compiledClass; if ((pool == null) || (loader == null)) { ClassLoader classLoader = new ContextClassLoader(typeof(OgnlContext).getClassLoader(), context); pool = ClassPool.getDefault(); pool.insertClassPath(new LoaderClassPath(classLoader)); pools.Add(context.getClassResolver(), pool); loader = new EnhancedClassLoader(classLoader); loaders.Add(context.getClassResolver(), loader); } newClass = pool.makeClass(className); ognlContextClass = pool.get(typeof(OgnlContext).Name); objectClass = pool.get(typeof(object).Name); stringClass = pool.get(typeof(string).Name); newClass.addInterface(pool.get(typeof(Getter).Name)); method = new CtMethod(objectClass, "get", new CtClass[] { ognlContextClass, objectClass, stringClass }, newClass); method.setBody("{" + code + "}"); newClass.addMethod(method); byteCode = newClass.toBytecode(); compiledClass = loader.defineClass(className, byteCode); return((Getter)compiledClass.newInstance()); } catch (Exception ex) { throw new OgnlException("Cannot create class", ex); } }
/// <summary> /// WARNING complex types for field values not supported /// </summary> /// <param name="changes"></param> /// <returns></returns> public override async Task PerformBatchUpdate(IEnumerable <RemoteDataChange> changes) { var changeDictionary = ClassPool.SpawnOrCreate <Dictionary <string, object> >(() => new Dictionary <string, object>()); foreach (var change in changes) { changeDictionary.Add(change.FullPath, change.FieldValue); } var rootRef = FirebaseDatabase.DefaultInstance.RootReference; await rootRef.UpdateChildrenAsync(changeDictionary); foreach (var change in changes) { change.ApplyCallback?.Invoke(change); change.Dispose(); } ClassPool.Despawn <Dictionary <string, object> >(changeDictionary, null); }
public void ClearConnections() { var removedConnections = ClassPool.Spawn <List <PortConnection> >(); removedConnections.AddRange(connections); foreach (var connection in removedConnections) { if (connection.Port == null) { continue; } Disconnect(connection.Port); } connections.Clear(); removedConnections.Despawn(); }
/// <summary> Checks all connections for invalid references, and removes them. </summary> public void VerifyConnections() { var removedConnections = ClassPool.Spawn <List <PortConnection> >(); for (var i = connections.Count - 1; i >= 0; i--) { var connection = connections[i]; var targetPort = connection.Port; if (targetPort != null) { continue; } removedConnections.Add(connection); } removedConnections.ForEach(x => connections.Remove(x)); removedConnections.Despawn(); }
private EcsWorld ActivateWorld(ILifeTime lifeTime) { if (_world != null) { return(_world); } var world = CreateWorld(); world.InitializeWorld(); var destroyAction = ClassPool.Spawn <DisposableAction>(); destroyAction.Initialize(world.Destroy); lifeTime.AddDispose(destroyAction); return(world); }
public override void Validate() { _allNodes?.Clear(); OnInnerValidate(); var nodeItems = ClassPool.Spawn <List <INode> >(); nodeItems.AddRange(serializableNodes); nodeItems.AddRange(nodes); foreach (var nodeItem in nodeItems) { nodeItem.SetUpData(this); nodeItem.Validate(); } nodeItems.Despawn(); }
/// <summary> /// Отправляет все локально записанные изменения на сервер. /// ВАЖНО: все операции в рамках одной комманды не должны прерыватья вызовом /// метода /// </summary> /// <returns></returns> public async Task CommitChanges() { var updateTasks = ClassPool.SpawnOrCreate <List <Task> >(() => new List <Task>()); List <RemoteDataChange> changes; lock (_pendingChanges) { changes = _pendingChanges.ToList(); _pendingChanges.Clear(); } foreach (var change in changes) { updateTasks.Add(_objectHandler.ApplyChange(change)); } await Task.WhenAll(updateTasks.ToArray()); changes.ForEach((ch) => ch.Dispose()); changes.Clear(); }
private List <UiViewReference> FindItemsByType(Type type, bool strongMatching) { var result = ClassPool.Spawn <List <UiViewReference> >(); if (strongMatching) { if (views.TryGetValue(type, out var items)) { result.AddRange(items); } return(result); } foreach (var view in views) { var viewType = view.Key; if (type.IsAssignableFrom(viewType)) { result.AddRange(view.Value); } } return(result); }