public void OnCompleted(Action continuation) { Internal.Logger.Log("YieldAwaiter.OnCompleted"); var runner = ICoroutineRunner.GetContext(); runner.Post(continuation); }
public static void Context(this ICoroutineRunner runner, Action action) { if (runner is null) { ThrowHelper.ArgNull(nameof(runner)); } if (action is null) { ThrowHelper.ArgNull(nameof(action)); } var prev = ICoroutineRunner.Instance; if (prev == runner) { action.Invoke(); } else { ICoroutineRunner.Instance = runner; try { action.Invoke(); } finally { ICoroutineRunner.Instance = prev; } } }
internal void AddOnCanceled(Action onCanceled) { if (onCanceled is null) { ThrowHelper.ArgNull(nameof(onCanceled)); } if (IsCompleted) { ThrowHelper.InvalidOp("Coroutine is already completed"); } if (IsCanceled) { onCanceled.Invoke(); return; } var runner = ICoroutineRunner.GetContext(); if (Runner == runner) { OnCalceled += onCanceled; } else { OnCalceled += () => runner.Context(onCanceled); } }
internal void ContinueWith(Action action) { if (action is null) { ThrowHelper.ArgNull(nameof(action)); } if (IsCanceled) { ThrowHelper.InvalidOp("Coroutine is already canceled"); } if (IsCompleted) { action.Invoke(); return; } var runner = ICoroutineRunner.GetContext(); if (Runner == runner) { OnCompleted += action; } else { OnCompleted += () => runner.Context(action); } }
public AnimalFactory(IAssetProvider assetProvider, ILevelMediator levelMediator, ICoroutineRunner coroutineRunner, IRandomService randomService) { _assetProvider = assetProvider; _levelMediator = levelMediator; _coroutineRunner = coroutineRunner; _randomService = randomService; }
public static T Context <T>(this ICoroutineRunner runner, Func <T> init) { if (runner is null) { ThrowHelper.ArgNull(nameof(runner)); } if (init is null) { ThrowHelper.ArgNull(nameof(init)); } var prev = ICoroutineRunner.Instance; if (prev == runner) { return(init.Invoke()); } else { ICoroutineRunner.Instance = runner; try { return(init.Invoke()); } finally { ICoroutineRunner.Instance = prev; } } }
public CoroutineRunner(IGameObjectFactory gameObjectFactory) { this.gameObjectFactory = gameObjectFactory; var go = this.gameObjectFactory.Create("CoroutineRunnerPrefab"); coroutineRunnerBehaviour = go.GetComponent<ICoroutineRunner>(); }
public static void ModPatch_Reset(ResourceManager __instance, ICoroutineRunner runner) { string[] paths = modList.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (paths.Length > 0) { var provider = Traverse.Create(__instance).Field("provider").GetValue <IChainedResourceProvider>(); var assetBundleProvider = provider.Successor.Successor; var modResourceProvider = new ModResourceProvider(runner, modBasePath.Value, paths); if (modResourceProvider.ModDirectories.Count > 0) { // 替换原版ExternalResourceProvider GlobalLib.ModResource = modResourceProvider; provider.Successor = modResourceProvider; modResourceProvider.Successor = assetBundleProvider; BindSubConfig(); } else { // 官方目前没做外部资源,所以可直接跳过原版ExternalResourceProvider provider.Successor = assetBundleProvider; } // Debug Console.WriteLine("当前ResourceProvider链表: "); while (provider != null) { Console.WriteLine(provider.GetType().ToString()); provider = provider.Successor; } } }
public Game(ICoroutineRunner coroutineRunner, LoadingCurtain loadingCurtain) { StateMachine = new GameStateMachine( new TextureLoader(coroutineRunner), new SceneLoader(coroutineRunner), loadingCurtain, AllServices.Container); }
public LevelFactory(IAssetProvider assetProvider, IMainHeroFactory mainHeroFactory, IAnimalFactory animalFactory, ILevelMediator gameMediator, ICoroutineRunner coroutineRunner) { _mainHeroFactory = mainHeroFactory; _animalFactory = animalFactory; _assetProvider = assetProvider; _gameMediator = gameMediator; _coroutineRunner = coroutineRunner; }
public CoroutineRunner(IGameObjectFactory gameObjectFactory) { this.gameObjectFactory = gameObjectFactory; var go = this.gameObjectFactory.Create("CoroutineRunnerPrefab"); coroutineRunnerBehaviour = go.GetComponent <ICoroutineRunner>(); }
public static ConsoleInputDetectorModel Create( ICoroutineRunner runner, IConsoleStateProvider console, IConsoleSettings settings ) { return(new ConsoleInputDetectorModel(runner, new UnityInput(), console, settings)); }
public GameStateMachine(SceneLoader sceneLoader, AllServices services, ICoroutineRunner coroutineRunner) { states = new Dictionary <Type, IExitableState> { [typeof(BootstrapState)] = new BootstrapState(this, sceneLoader, services, coroutineRunner), [typeof(LoadLevelState)] = new LoadLevelState(this, sceneLoader, services.Single <ILevelFactory>()) }; }
public GameController(IBlockSetProvider blockSetProvider, ICoroutineRunner coroutineRunner) { _blockSetProvider = blockSetProvider; _coroutineRunner = coroutineRunner; _settledBlocks = new Dictionary <Vector2Int, IBlock>(); Begin(); }
public void Construct(IRandomService randomService, ICoroutineRunner coroutineRunner) { _randomService = randomService; _coroutineRunner = coroutineRunner; _rotationCenter = MainRect.anchoredPosition - new Vector2(RotationRadius, RotationRadius); _circleRotation = _coroutineRunner.StartCoroutine(CircleRotate()); }
public static UnityWebRequestProcessorMiddleware <T> Create(Option <T> nextMiddleware, ICoroutineRunner runner, RequestProcessorMiddlewareManifest manifest) { var middleware = new UnityWebRequestProcessorMiddleware <T>(nextMiddleware, manifest); middleware._coroutineRunner = runner; return(middleware); }
public CameraCaptureSystem( Canvas canvas, ICoroutineRunner coroutineRunner, IDatabase database) { this.canvas = canvas; this.coroutineRunner = coroutineRunner; this.database = database; }
internal static void Register(this ICoroutineRunner runner, AwaitableCoroutineBase coroutine) { if (coroutine.IsCompleted) { return; } runner.OnRegistering(coroutine); }
void OnEnable() { _timelineData = new TimelineData(); _timelineView = new TimelineView(LoadSkin()); wantsMouseMove = true; CFunc.CoroutineCreatedListeners += HandleCoroutineCreated; _runner = new CoroutineRunner("CoroutineDebuggerWindow"); _runner.Start(UpdateCoroutine()); }
private void Construct( ICoroutineRunner coroutineRunner, IPhotoGallery photoGallery, IPermissions permissions) { this.coroutineRunner = coroutineRunner; this.photoGallery = photoGallery; this.permissions = permissions; }
public BootstrapState(GameStateMachine stateMachine, SceneLoader sceneLoader, AllServices services, ICoroutineRunner coroutineRunner) { _stateMachine = stateMachine; _sceneLoader = sceneLoader; _services = services; _coroutineRunner = coroutineRunner; RegisterServices(); }
private static void Initialize() { if (!_isInitialized) { _isInitialized = true; GameObject obj = new GameObject(); Object.DontDestroyOnLoad(obj); obj.hideFlags = HideFlags.HideInHierarchy; _runner = obj.AddComponent <CoroutineRunnerGameObject>(); } }
void Start() { coroutineRunner = Instantiate(coroutineRunnerPrefab).GetComponent <ICoroutineRunner>(); BombManager bombManager = new BombManager(coroutineRunner, bombPrefab, canvas, timerAndDisplay.GetComponent <TimerAndDisplay>().EndGameActions, explosionManager.GetComponent <ExplosionManager>()); screenSpaceManager.bombManager = bombManager; screenSpaceManager.CalculateGameplayArea(); // przesyla policzone dane do bombManagera timerAndDisplay.GetComponent <TimerAndDisplay>().ObtainCoroutineRunner(coroutineRunner); bombManager.StartRunning(); }
private void Awake() { coroutineRunner = Instantiate(coroutineRunnerPrefab).GetComponent <ICoroutineRunner>(); pointsManagerScript = pointsManager.GetComponent <PointsManager>(); uiManagerScript = uiManager.GetComponent <UIManager>(); gameManagerScript = gameManager.GetComponent <GameManager>(); mineManagerScript = mineManager.GetComponent <MineManager>(); pointsManagerScript.Initialize(pointsToEarn, uiManagerScript, coroutineRunner); gameManagerScript.Initialize(pointsManagerScript); mineManagerScript.Initialize(pointsManagerScript); }
public ConsoleInputDetectorModel( ICoroutineRunner runner, IInput input, IConsoleStateProvider console, IConsoleSettings settings ) { this.input = input; this.console = console; this.runner = runner; this.settings = settings; }
private void Awake() { coroutineRunner = Instantiate(CoroutineRunnerPrefab) .GetComponent <ICoroutineRunner>(); ObjectPoool objectPoool = new ObjectPoool(meteorPrefab, PoolRootTransform, optimumPoolCount); CreateShip(); MeteorSpawner meteorSpawner = new MeteorSpawner(meteorPrefab, spawnTime, minMeteoSpeed, maxMeteoSpeed, xMapConstraint, -xMapConstraint, yMapConstraint, -yMapConstraint, 0.01f, coroutineRunner, objectPoool); }
Action endTheGame; // callback do wszystkiego ze gra sie skonczyla public BombManager(ICoroutineRunner coroutineRunner, GameObject bombPrefab, Canvas spawningCanvas, Action endGameHighscore, ExplosionManager explosionManager) { endTheGame += endGameHighscore; this.coroutineRunner = coroutineRunner; this.bombPrefab = bombPrefab; this.spawningCanvas = spawningCanvas; this.explosionManager = explosionManager; bombInterval = Constants.STARTING_BOMB_INTERVAL; bombTimerMin = Constants.STARTING_MIN_TIMER; bombTimerMax = Constants.STARTING_MAX_TIMER; nonDisarmableTimer = Constants.NON_DISARMABLE_TIMER; bombPool = new BombPool(ActiveBombs, bombPrefab); }
public RequestCreator(string baseAddress, string apiKey, ICoroutineRunner coroutineRunner) { if (string.IsNullOrEmpty(baseAddress)) { throw new ArgumentNullException(nameof(baseAddress)); } if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException(nameof(apiKey)); } this.baseAddress = baseAddress; this.apiKey = apiKey; runner = coroutineRunner ?? throw new ArgumentNullException(nameof(coroutineRunner)); }
public MeteorSpawner(GameObject meteorPrefab, float spawnTime, float minMeteoSpeed, float maxMeteoSpeed, float xSpawn, float xMin, float yMax, float yMin, float timeSpeedUp, ICoroutineRunner coroutineRunner, ObjectPoool objectPoool) { this.meteorPrefab = meteorPrefab; this.spawnTime = spawnTime; this.minMeteoSpeed = minMeteoSpeed; this.maxMeteoSpeed = maxMeteoSpeed; this.xSpawn = xSpawn; this.yMax = yMax; this.yMin = yMin; this.xMin = xMin; this.timeSpeedUp = timeSpeedUp; this.coroutineRunner = coroutineRunner; this.objectPoool = objectPoool; coroutineRunner.StartCoroutine(SpawnMeteosInLoop()); }
public ModResourceProvider(ICoroutineRunner runner, string modBaseDir, string[] modPaths) : base(runner) { for (int i = 0; i < modPaths.Length; ++i) { string dir = Path.Combine(modBaseDir, modPaths[i]); if (Directory.Exists(dir)) { Console.WriteLine("检测到Mod路径: " + dir); ModDirectories.Add(dir); string zip = Path.Combine(dir, "Config.zip"); if (File.Exists(zip)) { Console.WriteLine("检测到压缩格式Mod档案: " + zip); ZipFile zipFile = ZipFile.Read(zip); ZipEntries.Add(dir, zipFile.ToDictionary((ZipEntry x) => x.FileName.ToLower(), (ZipEntry x) => x)); } // 扩展AssetBundleSheet string extraSheetFile = Path.Combine(dir, "AssetBundleSheet.sheet"); if (File.Exists(extraSheetFile)) { Console.WriteLine("检测到扩展AssetBundleSheet: " + extraSheetFile); byte[] array = File.ReadAllBytes(extraSheetFile); AssetBundleSheet modSheet = JsonConvert.DeserializeObject <AssetBundleSheet>(Encoding.UTF8.GetString(array)); AssetBundleSheet sourceSheet = Traverse.Create(BundleManagerBySheet.Instance()).Field("bundleSheet").GetValue <AssetBundleSheet>(); Console.WriteLine(string.Format("扩展Sheet bundle={0}, file={1}", modSheet.BundleList.Count, modSheet.FilesInfo.Count)); Console.WriteLine(string.Format("原始Sheet bundle={0}, file={1}", sourceSheet.BundleList.Count, sourceSheet.FilesInfo.Count)); foreach (var bundle in modSheet.BundleList) { sourceSheet.BundleList.Add(bundle.Key, bundle.Value); } foreach (var file in modSheet.FilesInfo) { sourceSheet.FilesInfo.Add(file.Key, file.Value); } Console.WriteLine(string.Format("合并Sheet bundle={0}, file={1}", sourceSheet.BundleList.Count, sourceSheet.FilesInfo.Count)); } } } }
public NetworkNode(IPEndPoint remoteEndpoint, IPEndPoint localEndpoint, ICoroutineRunner coroutineRunner, INetworkMessageRegistry messageRegistry) { this.remoteEndpoint = remoteEndpoint; this.localEndpoint = localEndpoint; this.coroutineRunner = coroutineRunner; this.messageRegistry = messageRegistry; transmissionSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); receptionSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); try { if (remoteEndpoint != null) { if (remoteEndpoint.Address.Equals(IPAddress.Broadcast)) { transmissionSocket.EnableBroadcast = true; } } if (localEndpoint != null) { if (localEndpoint.Address.Equals(IPAddress.Broadcast) || localEndpoint.Address.Equals(IPAddress.Any)) { receptionSocket.EnableBroadcast = true; } receptionSocket.Bind(localEndpoint); } } catch (Exception e) { Log.Output(Network.LogCategory, e.Message, LogLevel.Error); } senderIpEp = new IPEndPoint(IPAddress.Any, localEndpoint?.Port ?? 0); }