示例#1
0
 /// <summary>
 /// Creates a clone of this instance
 /// </summary>
 /// <returns>A clone of this instance</returns>
 public object Clone()
 {
     return(new BedOrChamber
     {
         Active = (float[])Active.Clone(),
         Standby = (float[])Standby.Clone(),
         Name = (Name != null) ? string.Copy(Name) : null,
         Heaters = (int[])Heaters.Clone()
     });
 }
        private void ResetStandby()
        {
            if ((DateTime.Now - _lastStandbyCall).TotalMinutes < 3)
            {
                return;
            }

            try
            {
                Standby.PreventSystemStandby();
                _lastStandbyCall = DateTime.Now;
            }
            catch
            {
            }
        }
示例#3
0
    //game manager will know that cards can only be accessed from certain locations/states via enums
    //ex. if cards are in discard, they are not in hand, deck or on field and cannot be accessed via normal draw, normal set or normal discard.
    //i.e there are "normal" actions and "effect" actions --> index identifier or seperate function?
    //they can only be accessed via "Card Effect" or "Reload"

    void PopulateArchons_Random()
    {
        UnityEngine.Random.state.Equals(Time.deltaTime);
        for (int i = 0; i < 5; i++)
        {
            var rng = UnityEngine.Random.Range(0, PlayerLibrary.archonLib.Count);
            All.Insert(i, PlayerLibrary.archonLib[rng]);
            Active.Insert(i, PlayerLibrary.archonLib[rng]);
        }

        for (int i = 0; i < 2; i++)
        {
            Standby.Insert(i, Active[i]);
            Active.RemoveRange(i, 1);
        }
    }
示例#4
0
 /// <summary>
 /// Creates a clone of this instance
 /// </summary>
 /// <returns>A clone of this instance</returns>
 public object Clone()
 {
     return(new Tool
     {
         Number = Number,
         Active = (float[])Active.Clone(),
         Standby = (float[])Standby.Clone(),
         Name = (Name != null) ? string.Copy(Name) : null,
         Filament = (Filament != null) ? string.Copy(Filament) : null,
         Fans = (int[])Fans.Clone(),
         Heaters = (int[])Heaters.Clone(),
         Mix = (float[])Mix.Clone(),
         Spindle = Spindle,
         Axes = Axes.Select(subAxes => (int[])subAxes.Clone()).ToList(),
         Offsets = (float[])Offsets.Clone()
     });
 }
示例#5
0
    // Use this for initialization
    void Start()
    {
        photonView = GetComponent <PhotonView>();
        battle     = GetComponent <Battle>();
        cointoss   = GetComponent <Cointoss>();
        result     = GetComponent <Result>();
        standby    = GetComponent <Standby>();
        scoreBoard = GetComponent <ScoreBoard>();

        player1P = new PlayerData(1, defBulletSpeed);
        player2P = new PlayerData(2, defBulletSpeed);

        if (PhotonNetwork.player.ID == 1)
        {
            myData = player1P;
        }
        else
        {
            myData = player2P;
        }
        PassPlayerUpdata();
    }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (RepositoryHome != null)
         {
             hashCode = hashCode * 59 + RepositoryHome.GetHashCode();
         }
         if (TarmkMode != null)
         {
             hashCode = hashCode * 59 + TarmkMode.GetHashCode();
         }
         if (TarmkSize != null)
         {
             hashCode = hashCode * 59 + TarmkSize.GetHashCode();
         }
         if (SegmentCacheSize != null)
         {
             hashCode = hashCode * 59 + SegmentCacheSize.GetHashCode();
         }
         if (StringCacheSize != null)
         {
             hashCode = hashCode * 59 + StringCacheSize.GetHashCode();
         }
         if (TemplateCacheSize != null)
         {
             hashCode = hashCode * 59 + TemplateCacheSize.GetHashCode();
         }
         if (StringDeduplicationCacheSize != null)
         {
             hashCode = hashCode * 59 + StringDeduplicationCacheSize.GetHashCode();
         }
         if (TemplateDeduplicationCacheSize != null)
         {
             hashCode = hashCode * 59 + TemplateDeduplicationCacheSize.GetHashCode();
         }
         if (NodeDeduplicationCacheSize != null)
         {
             hashCode = hashCode * 59 + NodeDeduplicationCacheSize.GetHashCode();
         }
         if (PauseCompaction != null)
         {
             hashCode = hashCode * 59 + PauseCompaction.GetHashCode();
         }
         if (CompactionRetryCount != null)
         {
             hashCode = hashCode * 59 + CompactionRetryCount.GetHashCode();
         }
         if (CompactionForceTimeout != null)
         {
             hashCode = hashCode * 59 + CompactionForceTimeout.GetHashCode();
         }
         if (CompactionSizeDeltaEstimation != null)
         {
             hashCode = hashCode * 59 + CompactionSizeDeltaEstimation.GetHashCode();
         }
         if (CompactionDisableEstimation != null)
         {
             hashCode = hashCode * 59 + CompactionDisableEstimation.GetHashCode();
         }
         if (CompactionRetainedGenerations != null)
         {
             hashCode = hashCode * 59 + CompactionRetainedGenerations.GetHashCode();
         }
         if (CompactionMemoryThreshold != null)
         {
             hashCode = hashCode * 59 + CompactionMemoryThreshold.GetHashCode();
         }
         if (CompactionProgressLog != null)
         {
             hashCode = hashCode * 59 + CompactionProgressLog.GetHashCode();
         }
         if (Standby != null)
         {
             hashCode = hashCode * 59 + Standby.GetHashCode();
         }
         if (CustomBlobStore != null)
         {
             hashCode = hashCode * 59 + CustomBlobStore.GetHashCode();
         }
         if (CustomSegmentStore != null)
         {
             hashCode = hashCode * 59 + CustomSegmentStore.GetHashCode();
         }
         if (SplitPersistence != null)
         {
             hashCode = hashCode * 59 + SplitPersistence.GetHashCode();
         }
         if (RepositoryBackupDir != null)
         {
             hashCode = hashCode * 59 + RepositoryBackupDir.GetHashCode();
         }
         if (BlobGcMaxAgeInSecs != null)
         {
             hashCode = hashCode * 59 + BlobGcMaxAgeInSecs.GetHashCode();
         }
         if (BlobTrackSnapshotIntervalInSecs != null)
         {
             hashCode = hashCode * 59 + BlobTrackSnapshotIntervalInSecs.GetHashCode();
         }
         if (Role != null)
         {
             hashCode = hashCode * 59 + Role.GetHashCode();
         }
         if (RegisterDescriptors != null)
         {
             hashCode = hashCode * 59 + RegisterDescriptors.GetHashCode();
         }
         if (DispatchChanges != null)
         {
             hashCode = hashCode * 59 + DispatchChanges.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if OrgApacheJackrabbitOakSegmentSegmentNodeStoreFactoryProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheJackrabbitOakSegmentSegmentNodeStoreFactoryProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheJackrabbitOakSegmentSegmentNodeStoreFactoryProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     RepositoryHome == other.RepositoryHome ||
                     RepositoryHome != null &&
                     RepositoryHome.Equals(other.RepositoryHome)
                     ) &&
                 (
                     TarmkMode == other.TarmkMode ||
                     TarmkMode != null &&
                     TarmkMode.Equals(other.TarmkMode)
                 ) &&
                 (
                     TarmkSize == other.TarmkSize ||
                     TarmkSize != null &&
                     TarmkSize.Equals(other.TarmkSize)
                 ) &&
                 (
                     SegmentCacheSize == other.SegmentCacheSize ||
                     SegmentCacheSize != null &&
                     SegmentCacheSize.Equals(other.SegmentCacheSize)
                 ) &&
                 (
                     StringCacheSize == other.StringCacheSize ||
                     StringCacheSize != null &&
                     StringCacheSize.Equals(other.StringCacheSize)
                 ) &&
                 (
                     TemplateCacheSize == other.TemplateCacheSize ||
                     TemplateCacheSize != null &&
                     TemplateCacheSize.Equals(other.TemplateCacheSize)
                 ) &&
                 (
                     StringDeduplicationCacheSize == other.StringDeduplicationCacheSize ||
                     StringDeduplicationCacheSize != null &&
                     StringDeduplicationCacheSize.Equals(other.StringDeduplicationCacheSize)
                 ) &&
                 (
                     TemplateDeduplicationCacheSize == other.TemplateDeduplicationCacheSize ||
                     TemplateDeduplicationCacheSize != null &&
                     TemplateDeduplicationCacheSize.Equals(other.TemplateDeduplicationCacheSize)
                 ) &&
                 (
                     NodeDeduplicationCacheSize == other.NodeDeduplicationCacheSize ||
                     NodeDeduplicationCacheSize != null &&
                     NodeDeduplicationCacheSize.Equals(other.NodeDeduplicationCacheSize)
                 ) &&
                 (
                     PauseCompaction == other.PauseCompaction ||
                     PauseCompaction != null &&
                     PauseCompaction.Equals(other.PauseCompaction)
                 ) &&
                 (
                     CompactionRetryCount == other.CompactionRetryCount ||
                     CompactionRetryCount != null &&
                     CompactionRetryCount.Equals(other.CompactionRetryCount)
                 ) &&
                 (
                     CompactionForceTimeout == other.CompactionForceTimeout ||
                     CompactionForceTimeout != null &&
                     CompactionForceTimeout.Equals(other.CompactionForceTimeout)
                 ) &&
                 (
                     CompactionSizeDeltaEstimation == other.CompactionSizeDeltaEstimation ||
                     CompactionSizeDeltaEstimation != null &&
                     CompactionSizeDeltaEstimation.Equals(other.CompactionSizeDeltaEstimation)
                 ) &&
                 (
                     CompactionDisableEstimation == other.CompactionDisableEstimation ||
                     CompactionDisableEstimation != null &&
                     CompactionDisableEstimation.Equals(other.CompactionDisableEstimation)
                 ) &&
                 (
                     CompactionRetainedGenerations == other.CompactionRetainedGenerations ||
                     CompactionRetainedGenerations != null &&
                     CompactionRetainedGenerations.Equals(other.CompactionRetainedGenerations)
                 ) &&
                 (
                     CompactionMemoryThreshold == other.CompactionMemoryThreshold ||
                     CompactionMemoryThreshold != null &&
                     CompactionMemoryThreshold.Equals(other.CompactionMemoryThreshold)
                 ) &&
                 (
                     CompactionProgressLog == other.CompactionProgressLog ||
                     CompactionProgressLog != null &&
                     CompactionProgressLog.Equals(other.CompactionProgressLog)
                 ) &&
                 (
                     Standby == other.Standby ||
                     Standby != null &&
                     Standby.Equals(other.Standby)
                 ) &&
                 (
                     CustomBlobStore == other.CustomBlobStore ||
                     CustomBlobStore != null &&
                     CustomBlobStore.Equals(other.CustomBlobStore)
                 ) &&
                 (
                     CustomSegmentStore == other.CustomSegmentStore ||
                     CustomSegmentStore != null &&
                     CustomSegmentStore.Equals(other.CustomSegmentStore)
                 ) &&
                 (
                     SplitPersistence == other.SplitPersistence ||
                     SplitPersistence != null &&
                     SplitPersistence.Equals(other.SplitPersistence)
                 ) &&
                 (
                     RepositoryBackupDir == other.RepositoryBackupDir ||
                     RepositoryBackupDir != null &&
                     RepositoryBackupDir.Equals(other.RepositoryBackupDir)
                 ) &&
                 (
                     BlobGcMaxAgeInSecs == other.BlobGcMaxAgeInSecs ||
                     BlobGcMaxAgeInSecs != null &&
                     BlobGcMaxAgeInSecs.Equals(other.BlobGcMaxAgeInSecs)
                 ) &&
                 (
                     BlobTrackSnapshotIntervalInSecs == other.BlobTrackSnapshotIntervalInSecs ||
                     BlobTrackSnapshotIntervalInSecs != null &&
                     BlobTrackSnapshotIntervalInSecs.Equals(other.BlobTrackSnapshotIntervalInSecs)
                 ) &&
                 (
                     Role == other.Role ||
                     Role != null &&
                     Role.Equals(other.Role)
                 ) &&
                 (
                     RegisterDescriptors == other.RegisterDescriptors ||
                     RegisterDescriptors != null &&
                     RegisterDescriptors.Equals(other.RegisterDescriptors)
                 ) &&
                 (
                     DispatchChanges == other.DispatchChanges ||
                     DispatchChanges != null &&
                     DispatchChanges.Equals(other.DispatchChanges)
                 ));
        }
示例#8
0
        public SystemEventNotifier(int maxIdleSeconds = 60 * 15)
        {
            _cts = new CancellationTokenSource();
            _ct  = _cts.Token;

            this._maxIdleSeconds = maxIdleSeconds;
            Display   = X11.Xlib.XOpenDisplay(null);
            xsi       = new X11.XScreenSaverInfo();
            lastCheck = DateTime.Now;
            _pollTask = new Task(() =>
            {
                Log.Information("SystemEventNotifier polling task started");

                while (!_ct.IsCancellationRequested)
                {
                    // Check system idle time
                    X11.Xlib.XScreenSaverQueryInfo(Display, X11.Xlib.XRootWindow(Display, 0), ref xsi);

                    Log.Debug("Idle time: {IdleTime}", xsi.idle.ToString());
                    if ((xsi.idle / 1000) > (ulong)_maxIdleSeconds)
                    {
                        if (!_idleDetected)
                        {
                            Idle?.Invoke(this, new SystemEventArgs("Idle Timeout"));
                            Log.Information("Detected idle timeout");
                            _idleDetected = true;
                        }
                    }
                    else
                    {
                        if (_idleDetected)
                        {
                            _idleDetected = false;
                        }
                    }

                    if ((ScreenSaverState)xsi.state == ScreenSaverState.ScreenSaverOn)
                    {
                        if (!_screenSaver)
                        {
                            Screensaver?.Invoke(this, new SystemEventArgs("Screen Saver"));
                            Log.Information("Detected Screen Saver On");
                            _screenSaver = true;
                        }
                    }
                    else if (_screenSaver)
                    {
                        _screenSaver = false;
                    }


                    //Since we can't check for Lock, Logout or Restart we are going to
                    //Do a bit of  a hack and assume that if our loop took longer than triple the standard time to run
                    //then we want to go ahead and clear the quick pass;
                    if ((DateTime.Now - lastCheck).TotalSeconds > (POLL_INTERVAL / 1000) * 3)
                    {
                        Log.Information("Detected an Anommaly System Loop took > 3X to run, clearing quick pass");
                        Standby?.Invoke(this, new SystemEventArgs("System Hiccup Clearing QuickPass Just in Case"));
                    }
                    lastCheck = DateTime.Now;


                    Thread.Sleep(POLL_INTERVAL);
                }

                Log.Information("SystemEventNotifier polling task ending");
            }, _ct);

            _pollTask.Start();
        }
        /// <summary>
        /// Creates a new <c>SystemEventNotifier</c> instance and sets up some
        /// required resources.
        /// </summary>
        /// <param name="maxIdleSeconds">The maximum system idle time in seconds before the
        /// <c>Idle</c> event is being raised.</param>
        public SystemEventNotifier(int maxIdleSeconds = 60 * 15)
        {
            Log.Information($"Instanciating System Event Notifier");
            _cts = new CancellationTokenSource();
            _ct  = _cts.Token;

            this._maxIdleSeconds = maxIdleSeconds;

            //Subscribe to an apple notification fired when the screen is locked
            ((NSDistributedNotificationCenter)NSDistributedNotificationCenter.DefaultCenter).AddObserver(new NSString("com.apple.screenIsLocked"), (obj) =>
            {
                Log.Information("Detected session lock");
                SessionLock?.Invoke(this, new SystemEventArgs("Session Lock"));
            });

            //Subscribe to an apple notification fired when the screen saver starts
            ((NSDistributedNotificationCenter)NSDistributedNotificationCenter.DefaultCenter).AddObserver(new NSString("com.apple.screensaver.didstart"), (obj) =>
            {
                Log.Information("Detected Screen Saver");
                Screensaver?.Invoke(this, new SystemEventArgs("Screensaver"));
            });


            //Subscribe to an apple notification fired when the System goes to Sleep
            NSWorkspace.Notifications.ObserveWillSleep((s, e) =>
            {
                Log.Information("Detected Standy");
                Standby?.Invoke(this, new SystemEventArgs("Stand By"));
            });


            //Subscribe to an apple notification fired when the System goes to power off / reboot
            NSWorkspace.Notifications.ObserveWillPowerOff((s, e) =>
            {
                Log.Information("Detected PowerOff / Reboot");
                ShutdownOrRestart?.Invoke(this, new SystemEventArgs("System ShutDown / Reboot"));
            });



            //Subscribe to an apple notification fired when the System goes to Log off the current User
            NSWorkspace.Notifications.ObserveSessionDidResignActive((s, e) =>
            {
                Log.Information("Detected PowerOff / Reboot");
                SessionLogoff?.Invoke(this, new SystemEventArgs("Session Log Off"));
            });


            // Start a task to poll Idle Time Global Environment Variable
            _pollTask = new Task(() =>
            {
                Log.Information("SystemEventNotifier polling task started");
                Thread.Sleep(POLL_INTERVAL); //Sleep at first to give Mac Delegate time
                while (!_ct.IsCancellationRequested)
                {
                    // Check system idle time
                    TimeSpan idletime = AppDelegate.CheckIdleTime();
                    Log.Debug("Idle time: {IdleTime}", idletime.ToString());
                    if (idletime.TotalSeconds > _maxIdleSeconds)
                    {
                        if (!_idleDetected)
                        {
                            Idle?.Invoke(this, new SystemEventArgs("Idle Timeout"));
                            Log.Information("Detected idle timeout");
                            _idleDetected = true;
                        }
                    }
                    else
                    {
                        if (_idleDetected)
                        {
                            _idleDetected = false;
                        }
                    }

                    Thread.Sleep(POLL_INTERVAL);
                }

                Log.Information("SystemEventNotifier polling task ending");
            }, _ct);

            _pollTask.Start();
            Log.Information($"System Event Notifier was Innitialized Successfully");
        }
 protected override IEnumerator MainRoutine()
 {
     if (base.battleMode != BattleMode.PvP && base.battleMode != BattleMode.Multi)
     {
         yield break;
     }
     if (this.isFirst)
     {
         if (base.battleMode == BattleMode.PvP)
         {
             IEnumerator runAlreadyLoseEvent = base.stateManager.pvpFunction.CheckAlreadyLoseBeforeBattle();
             while (runAlreadyLoseEvent.MoveNext())
             {
                 yield return(null);
             }
             this.pvpBattleSyncWaitGO = (base.stateManager.battleUiComponents as BattleUIComponentsPvP).pvpBattleSyncWaitUi.gameObject;
             NGUITools.SetActiveSelf(this.pvpBattleSyncWaitGO, false);
             NGUITools.SetActiveSelf(this.pvpBattleSyncWaitGO, true);
             this.standby = (this.standby ?? this.pvpBattleSyncWaitGO.GetComponent <Standby>());
         }
         else if (base.battleMode == BattleMode.Multi)
         {
             base.stateManager.uiControlMultiBasic.ShowPrepareMessage();
         }
         if (base.hierarchyData.batteWaves[base.battleStateData.currentWaveNumber].cameraType == 1)
         {
             base.stateManager.cameraControl.PlayCameraMotionAction("BigBoss/0007_commandCharaView", base.battleStateData.stageSpawnPoint, true);
         }
         else
         {
             base.stateManager.cameraControl.PlayCameraMotionAction("0007_commandCharaView", base.battleStateData.stageSpawnPoint, true);
         }
     }
     else if (base.battleMode == BattleMode.Multi)
     {
         base.stateManager.uiControlMulti.ShowLoading(false);
     }
     if (base.stateManager.multiBasicFunction.IsOwner)
     {
         IEnumerator wait = base.stateManager.multiBasicFunction.SendRandomSeedSync();
         while (wait.MoveNext())
         {
             object obj = wait.Current;
             yield return(obj);
         }
     }
     else
     {
         IEnumerator wait2 = base.stateManager.multiBasicFunction.WaitAllPlayers(TCPMessageType.RandomSeedSync);
         while (wait2.MoveNext())
         {
             object obj2 = wait2.Current;
             yield return(obj2);
         }
     }
     if (this.isFirst && base.battleMode == BattleMode.PvP)
     {
         this.standby.PlayHideAnimation();
         IEnumerator asdWait = base.stateManager.time.WaitForCertainPeriodTimeAction(1.5f, null, null);
         while (asdWait.MoveNext())
         {
             yield return(null);
         }
     }
     this.isFirst = false;
     yield break;
 }
        public IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            Log.Debug("SystemEventNotifier WndProc: MSG={Msg}, wParam={wParam}, lParam={lParam}",
                      ((UnmanagedMethods.WindowsMessage)msg).ToString(),
                      ((UnmanagedMethods.WindowsMessage)wParam.ToInt32()).ToString(),
                      ((UnmanagedMethods.WindowsMessage)lParam.ToInt32()).ToString());

            switch (msg)
            {
            case (uint)UnmanagedMethods.WindowsMessage.WM_WTSSESSION_CHANGE:
                switch (wParam.ToInt32())
                {
                case UnmanagedMethods.WTS_SESSION_LOGOFF:
                    SessionLogoff?.Invoke(this, new SystemEventArgs("Session Logoff"));
                    Log.Information("Detected session logoff");
                    break;

                case UnmanagedMethods.WTS_SESSION_LOCK:
                    SessionLock?.Invoke(this, new SystemEventArgs("Session Lock"));
                    Log.Information("Detected session lock");
                    break;
                }
                break;

            case (uint)UnmanagedMethods.WindowsMessage.WM_ENDSESSION:

                // If the session is being ended, the wParam parameter is TRUE;
                // the session can end any time after all applications have returned
                // from processing this message. Otherwise, it is FALSE.
                if (wParam.ToInt32() == 0)
                {
                    break;
                }

                switch (lParam.ToInt32())
                {
                case 0:         //Shutdown or restart
                    ShutdownOrRestart?.Invoke(this, new SystemEventArgs("System Shutdown/Restart"));
                    Log.Information("Detected system shutdown/restart");
                    break;

                case UnmanagedMethods.ENDSESSION_LOGOFF:
                case UnmanagedMethods.ENDSESSION_CLOSEAPP:
                case UnmanagedMethods.ENDSESSION_CRITICAL:
                    SessionLogoff?.Invoke(this, new SystemEventArgs("Session Ending"));
                    Log.Information("Detected end of session");
                    break;
                }
                break;

            case (uint)UnmanagedMethods.WindowsMessage.WM_POWERBROADCAST:

                switch (wParam.ToInt32())
                {
                case UnmanagedMethods.PBT_APMSUSPEND:
                case UnmanagedMethods.PBT_APMSTANDBY:
                    Standby?.Invoke(this, new SystemEventArgs("Standby"));
                    Log.Information("Detected entering sleep mode");
                    break;
                }
                break;

            default:
                break;
            }
            return(IntPtr.Zero);
        }
示例#12
0
    public TroopStateController(TroopOnField troop)
    {
        //Declare all states and put them in List<TroopState>
        Standby s = new Standby();
        March m = new March();

        //Declare all possible transitions
        T_S_M t_s_m = new T_S_M(s, m);
        T_M_S t_m_s = new T_M_S(m, s);

        //Create transition list for each state
        List<Transition> transition_s = new List<Transition>();
        transition_s.Add(t_s_m);
        List<Transition> transition_m = new List<Transition>();
        transition_m.Add(t_m_s);

        //Put relevant transitions in each of the state
        s.initialize(troop, transition_s);
        m.initialize(troop, transition_m);

        //Set up the first state
        activeState = s;
    }
示例#13
0
 /// <summary>
 /// Return to standby mode
 /// </summary>
 /// <param name="sender">Event source</param>
 /// <param name="e">Event args</param>
 private void FileStandby_Click(object sender, EventArgs args)
 {
     Standby?.Invoke(this, args);
 }