Пример #1
0
        private void Update()
        {
            if (IsRunning != (Runner != null))
            {
                IsRunning = Runner != null;
                OnRunningChanged?.Invoke(IsRunning);
                if (IsRunning)
                {
                    OnInit?.Invoke();
                    start = next = Utils.TimeGetTime();
                }
            }
            if (IsRunning)
            {
                updateWatch.Start();
                if (useNewUpdate)
                {
                    NewUpdate();
                }
                else
                {
                    OriginalUpdate();
                }
                updateWatch.Stop();

                OnStatus?.Invoke(Runner.GetStatus(updateWatch));
            }
        }
Пример #2
0
        public void Add(IServer server)
        {
            if (mServerMapper == null)
            {
                return;
            }
            if (!IsInited)
            {
                IsInited = true;
                OnInit?.Invoke();
                OnInit = default;
            }
            string serverName = (server != null) ? server.ServerName : string.Empty;

            if (!string.IsNullOrEmpty(serverName) && !mServerMapper.IsContainsKey(serverName))
            {
                SetAndInitServer(ref server);
                SetServerPriority(server);
                mNewServers.Add(server);

                if (!mCanCheckServers)
                {
                    mCanCheckServers = true;
                    ShipDockApp.CallLater(CheckServerList);
                }
                mServerPriorAttrs = null;
            }
        }
        private void Init()
        {
            try
            {
                using (var redis = ClientsManager.GetReadOnlyClient())
                {
                    startedAt         = Stopwatch.StartNew();
                    serverTimeAtStart = IsSentinelSubscription
                        ? DateTime.UtcNow
                        : redis.GetServerTime();
                }
            }
            catch (Exception ex)
            {
                OnError?.Invoke(ex);
            }

            DisposeHeartbeatTimer();

            if (HeartbeatInterval != null)
            {
                heartbeatTimer = new Timer(SendHeartbeat, null,
                                           TimeSpan.FromMilliseconds(0), HeartbeatInterval.Value);
            }

            Interlocked.CompareExchange(ref lastHeartbeatTicks, DateTime.UtcNow.Ticks, lastHeartbeatTicks);

            OnInit?.Invoke();
        }
Пример #4
0
        private async Task StartBotConversation()
        {
            try
            {
                client = new DirectLineClient(directLineSecret);

                conversation = await client.Conversations.StartConversationAsync();

                new System.Threading.Thread(async() =>
                {
                    try
                    {
                        await ReadBotMessagesAsync(client, conversation.ConversationId);
                    }
                    catch (Exception)
                    {
                    }
                }).Start();

                OnInit?.Invoke();
            }
            catch (Exception)
            {
            }
        }
Пример #5
0
        /// <summary>初始化</summary>
        public virtual void Init()
        {
            OnInit?.Invoke();
            AfterGridEffectFinished += BatchEffectCompleted;

            GameEffects effects = ElimlnateCore.Instance.GridEffects;

            string name;
            int    max = mRelateEffectName.Length;

            for (int i = 0; i < max; i++)
            {
                name = mRelateEffectName[i];
                if (i == 0)
                {
                    mStartGridEffectName = name;
                    CurGridEffectName    = mStartGridEffectName;
                }
                else
                {
                }

                if (!string.IsNullOrEmpty(name))
                {
                    effects.GetEffect(name).UpperStrata = this;
                }
                else
                {
                }
            }
        }
Пример #6
0
        private void Update()
        {
            if (IsRunning != (Runner != null))
            {
                IsRunning = Runner != null;
                OnRunningChanged?.Invoke(IsRunning);
                if (IsRunning)
                {
                    OnInit?.Invoke();
                }
            }
            if (Runner != null)
            {
                updateWatch.Start();
                var now     = Time.time;
                var extraMs = Mathf.Max(0, (int)((next - now) * 1000f) - 1);
                Runner.Idle(extraMs);
                Thread.Sleep(extraMs);

                if (now >= next)
                {
                    OnPreRunFrame();
                    Runner.RunFrame();
                    next = now + 1f / 60f;
                    OnStateChanged?.Invoke();
                }
                updateWatch.Stop();

                string status = Runner.GetStatus(updateWatch);
                OnStatus?.Invoke(status);
                OnChecksum?.Invoke(RenderChecksum(Runner.GameInfo.periodic) + RenderChecksum(Runner.GameInfo.now));
            }
        }
Пример #7
0
    public void Init()
    {
        if (active)
        {
            return;
        }

        transform.position = Vector3.zero;
        GridSize           = gridSize;

        // Deterministic if using set seed value
        if (useSeed)
        {
            Random.InitState(seed);
            Debug.Log($"Init with set seed: {seed}");
        }
        else
        {
            // Stochastic with (pseudo) random seed value
            randomSeed = (int)DateTime.Now.Ticks;
            Random.InitState(randomSeed);
            Debug.Log($"Init with random seed: {randomSeed}");
        }

        active = true;
        OnInit?.Invoke();

        SpawnOuterBorders();
        SpawnRoomPositions();
        StartGeneration();
    }
Пример #8
0
 public void Init(Entity e)
 {
     player = GameObject.FindGameObjectWithTag("Player")?.transform;
     t      = transform;
     entity = e;
     eT     = entity.transform;
     OnInit?.Invoke();
 }
Пример #9
0
 public override void PostInit()
 {
     //Since this system should be called last, this is the absolute last system called before game processing is enabled
     //This should be used to interface the game engine proper with all mod libraries post-compile.
     Console.WriteLine("Bootstrap entered.");
     OnInit?.Invoke(Manager);
     Console.WriteLine("Bootstrap exited.");
 }
Пример #10
0
        public override void Init()
        {
            OnInit?.Invoke(NestedScope);
            base.Init();

            SceneManager.activeSceneChanged += ActiveSceneChanged;
            SceneManager.sceneUnloaded      += s => { NestedScope.Save(); };
        }
Пример #11
0
 public GlobalScript()
 {
     if (_initalized)
     {
         return;
     }
     Singleton = this;
     OnInit?.Invoke(this);
 }
Пример #12
0
        /// <summary>
        /// 更新图表方法
        /// </summary>
        public async Task Update(string method = "")
        {
            if (OnInit != null)
            {
                var ds = await OnInit.Invoke();

                Interop?.Invoke(this, Chart, "chart", nameof(Completed), ds, method, ChartType.ToDescriptionString(), Angle);
            }
        }
Пример #13
0
        public AGSGameWindow(IGameSettings settings, IGameWindowSize windowSize)
        {
            _windowSize = windowSize;
            _gameWindow = new GameWindow(settings.WindowSize.Width, settings.WindowSize.Height,
                                         GraphicsMode.Default, settings.Title);
            OnInit?.Invoke();

            _updateFrameArgs         = new FrameEventArgs();
            _renderFrameArgs         = new FrameEventArgs();
            _gameWindow.UpdateFrame += onUpdateFrame;
            _gameWindow.RenderFrame += onRenderFrame;
        }
Пример #14
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="InitPosition">RH VectorInt</param>
    /// <param name="InitQ">RH Quaternion</param>
    public void Initialize(Vector3Int InitPosition, Quaternion InitQ, EntityData data)
    {
        Type                    = data.Type;
        IdealPosition           = InitPosition;
        IdealRotation           = InitQ;
        Data                    = data;
        IsActive                = true;
        transform.localPosition = SceneObjectManager.worldscale * (Vector3)IdealPosition;
        transform.localRotation = InitQ;

        OnInit?.Invoke();
    }
 protected override void Awake()
 {
     base.Awake();
     elementData = Resources.Load("ElementData") as ElementData;
     if (elementData != null)
     {
         if (onInit != null)
         {
             onInit.Invoke();
         }
         elementData.Init();
         GameController.Instance.Init();
     }
 }
Пример #16
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender)
            {
                if (OnInit == null) throw new InvalidOperationException("OnInit paramenter must be set");

                if (Interop == null) Interop = new JSInterop<Chart>(JSRuntime);

                var ds = await OnInit.Invoke();

                await Interop.InvokeVoidAsync(this, ChartElement, "chart", nameof(Completed), ds, "", ChartType.ToDescriptionString());
            }
        }
Пример #17
0
        /// <summary>
        /// Initialize the simulation run.
        /// </summary>
        /// <param name="model"></param>
        public void Init(string model)
        {
            _dataLogger          = new DataLogger(Instance.Proxy.ClassName, LogSubDirectory);
            Iteration            = 0;
            ElapsedTime          = 0;
            AverageIterationTime = 0;
            Initializations++;

            const string softwareName    = "charlie-simulation-framework";
            const string softwareVersion = "v1.0.0";
            const string softwareAuthor  = "Jakob Rieke";
            var          os = Environment.OSVersion;

            Log("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            Log("<simulation>\n");
            Log($"<software>{softwareName}; {softwareVersion}; " +
                $"{softwareAuthor}</software>\n");
            Log($"<system>{os.Platform}; {os.VersionString}; " +
                $"{os.Version}</system>\n");
            Log($"<datetime>{DateTime.Now.ToUniversalTime()}</datetime>\n");
            Log($"<title>{Instance.GetTitle()}</title>\n");
            Log($"<meta>{Instance.GetMeta()}</meta>\n");


            Log("<configuration>");
            foreach (var line in model.Split('\n'))
            {
                Log("\n  " + line + "");
            }
            Log("</configuration>\n");

            try
            {
                Instance.Init(ParseModel(model));
                ImageData = Instance.Render(RenderWidth, RenderHeight);

                RenderAllData();
                OnInit?.Invoke(this, EventArgs.Empty);
                OnUpdate?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception e)
            {
                var exc = SimplifyException(e.ToString());
                Log("<error>\n" + exc + "</error>\n");
                Console.WriteLine(exc);
            }
        }
Пример #18
0
        private async Task ListeningLoopAsync(IClient client)
        {
            AddClient(client);
            OnInit?.Invoke(this, new SocketEventArgs(client));
            try
            {
                await ReceiveAsync(client);
            }
            catch (IOException)
            {
                // connection unexpectedly closed
                // https://github.com/aspnet/WebSockets/issues/63
            }

            OnClose?.Invoke(this, new SocketEventArgs(client));
            RemoveClient(client);
        }
Пример #19
0
        private async Task ListeningLoopAsync(IClient client)
        {
            AddClient(client);
            OnInit?.Invoke(this, new SocketEventArgs(client));
            try
            {
                await ReceiveAsync(client);
            }
            catch (Exception e)
            {
                // connection unexpectedly closed
                // https://github.com/aspnet/WebSockets/issues/63
                _logger.LogDebug($"Client {client?.Id} with {client?.Ip} has been unexpectedly closed: {e}");
            }

            OnClose?.Invoke(this, new SocketEventArgs(client));
            RemoveClient(client);
        }
Пример #20
0
        public void Init(ShelfObject parent)
        {
            Creator = parent;
            OnInit?.Invoke();
            TimeManager.RegisterObject(this);

            foreach (var mf in GetComponentsInChildren <MeshFilter>())
            {
                mf.mesh = mf.sharedMesh;
            }

            foreach (var child in GetComponentsInChildren <Animatable>())
            {
                if (child.GetInstanceID() == GetInstanceID())
                {
                    continue;
                }

                child.Init(null);
            }
        }
Пример #21
0
        protected override void OnWidgetEvent(WidgetEventArgs e)
        {
            switch (e.Type)
            {
            case "key":
                lock (this)
                {
                    if (e.Data == "\r")
                    {
                        string cmd = sb.ToString();
                        sb.Clear();
                        OnLineFeed?.Invoke(this, cmd);
                    }
                    else if (e.Data == "\u007f")
                    {
                        if (sb.Length > 0)
                        {
                            sb.Remove(sb.Length - 1, 1);
                        }
                    }
                    else
                    {
                        sb.Append(e.Data);
                    }
                }
                break;

            case "init":
            {
                OnInit?.Invoke(this, EventArgs.Empty);
            }
            break;
            }

            base.OnWidgetEvent(e);
        }
Пример #22
0
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init(BootFlag flag, string confPath)
        {
            PrepareCms();
            BeforeInit();
            if (!IsInstalled())
            {
                return;
            }
            //初始化目录
            ChkCreate(CmsVariables.TEMP_PATH);
            // 加载配置
            Configuration.LoadCmsConfig(confPath);
            //设置数据库
            CmsDataBase.Initialize($"{Settings.DB_TYPE}://{Settings.DB_CONN}", Settings.DB_PREFIX, Settings.SQL_PROFILE_TRACE);
            //清空临时文件
            //resetTempFiles();
            // 初始化键值存储
            InitKvDb();
            // 加载其他配置
            LoadOtherConfig();
            //获取静态服务器
            //UpdateServerInfo();
            // 正常模式启动
            if ((flag & BootFlag.Normal) != 0)
            {
                BuildOEM = new BuildOEM();

                //
                //TODO:
                //
                //检查网站激活状态
                //SoftwareActivator.VerifyActivation();
                //如果不存在模板文件夹,则创建目录
                if (!Directory.Exists(PhysicPath + "templates/"))
                {
                    Directory.CreateDirectory(PhysicPath + "templates/").Create();
                    //暂时网络安装默认模板(后可使用资源代替)
                    Updater.InstallTemplate("default", "tpl_default.zip");
                }

                _templateManager = new TemplateManager(PhysicPath + CmsVariables.TEMPLATE_PATH);

                // 注册模板
                Template.Register("/" + CmsVariables.TEMPLATE_PATH, true);
                // 注册插件
                //PluginConfig.PLUGIN_FILE_PARTTERN = "*.dll,*.so";
                PluginConfig.PLUGIN_DIRECTORY         = CmsVariables.PLUGIN_PATH;
                PluginConfig.PLUGIN_TMP_DIRECTORY     = CmsVariables.TEMP_PATH + "plugin/";
                PluginConfig.PLUGIN_LOG_OPENED        = true;
                PluginConfig.PLUGIN_LOG_EXCEPT_FORMAT =
                    "** {time} **:{message}\r\nSource:{source}\r\nAddress:{addr}\r\nStack:{stack}\r\n\r\n";
                var pluginPhysicPath = PhysicPath + PluginConfig.PLUGIN_TMP_DIRECTORY;
                if (!Directory.Exists(pluginPhysicPath))
                {
                    Directory.CreateDirectory(pluginPhysicPath).Create();
                }
                // 连接插件
                //todo: plugin
                //CmsPluginContext.Connect();

                // 设置验证码字体
                VerifyCodeGenerator.SetFontFamily(PhysicPath + CmsVariables.FRAMEWORK_ASSETS_PATH + "fonts/comic.ttf");
            }

            OnInit?.Invoke();

            IsInitFinish = true;
        }
Пример #23
0
 protected override void Start()
 {
     OnInit?.Invoke();
     InvokeRepeating(nameof(UpdateTarget), 0, 0.5f);
     base.Start();
 }
 protected virtual void Init()
 {
     OnInit?.Invoke(RendWind);
 }
Пример #25
0
 public void Init()
 {
     OnInit?.Invoke();
 }
Пример #26
0
 protected void InvokeOnInit()
 {
     OnInit?.Invoke();
 }
Пример #27
0
 internal void _OnInit()
 {
     OnInit?.Invoke(this);
     Utils.Call("self.EventStarted = False");
 }
Пример #28
0
        public static void Run(string title, int width, int height, ErrorHandler errorHandler)
        {
            App.errorHandler = errorHandler;

            if (errorHandler != null)
            {
                try { Run(); }
                catch (Exception e) { errorHandler(e); }
            }
            else
            {
                Run();
            }

            void Run()
            {
                if (platform == null)
                {
                    throw new Exception("App has not been initialized.");
                }
                if (Running)
                {
                    throw new Exception("App is already running.");
                }

                Running = true;
                platform.Init(title, width, height);
                platform.CenterWindow();

                platform.OnQuit           += Quit;
                platform.OnWinClose       += Quit;
                platform.OnWinFocusGained += () => Focused = true;
                platform.OnWinFocusLost   += () => Focused = false;

                GL.Init();
                Time.Init(1f / 60f);
                Screen.Init();
                Mouse.Init();
                Keyboard.Init();
                Joystick.Init();

                OnInit?.Invoke();

                double prevTime   = platform.GetTime();
                double frameTimer = 0.0;

                while (Running)
                {
                    platform.PollEvents();

                    if (!Focused && !UpdateWhileFocused)
                    {
                        prevTime = (float)platform.GetTime();
                        continue;
                    }

                    if (Running)
                    {
                        double currTime  = platform.GetTime();
                        double deltaTime = currTime - prevTime;
                        if (deltaTime > 0.0)
                        {
                            FPS = (int)(1.0 / (currTime - prevTime));
                        }
                        prevTime = currTime;

                        if (FixedFramerate)
                        {
                            if (!Screen.VSync)
                            {
                                frameTimer += deltaTime;
                                while (frameTimer >= frameDuration)
                                {
                                    frameTimer -= frameDuration;
                                    Update(frameDuration);
                                }
                            }
                            else
                            {
                                Update(frameDuration);
                            }
                        }
                        else
                        {
                            Update(deltaTime);
                        }

                        void Update(double dt)
                        {
                            Time.PreUpdate((float)dt);
                            Mouse.PreUpdate();

                            OnUpdate?.Invoke();

                            Mouse.PostUpdate();
                            Keyboard.PostUpdate();
                            Joystick.PostUpdate();

                            Texture.UnbindAll();

                            DrawCall.Begin();
                            OnRender?.Invoke();
                            DrawCall.End();

                            platform.SwapBuffers();
                        }
                    }
                }

                OnQuit?.Invoke();

                platform.Quit();
            }
        }
Пример #29
0
 internal void OnConnectedToQuikCall(int port)
 {
     OnConnectedToQuik?.Invoke(port);
     OnInit?.Invoke(port);
 }
Пример #30
0
 protected void InvokeOnInit(bool continued, Direction direction, int seq, int seq2, Player[] players)
 {
     OnInit?.Invoke(continued, direction, seq, seq2, players);
 }