コード例 #1
0
ファイル: DefaultWorld.cs プロジェクト: ramseur/MudDesigner
        /// <summary>
        /// Sets up the world clock.
        /// </summary>
        /// <param name="initialState">The initial state.</param>
        private void SetupWorldClock(TimeOfDayState initialState)
        {
            // We want to reset our current state before we set up the next state
            // The next state starts on a background thread and can cause listeners to access
            // the old state before the new state is assigned preventing a proper reset.
            if (this.CurrentTimeOfDay != null)
            {
                this.CurrentTimeOfDay.TimeUpdated -= this.CurrentTimeOfDayState_TimeUpdated;
            }

            // Register for event updates
            initialState.TimeUpdated += this.CurrentTimeOfDayState_TimeUpdated;

            // Initialize the state.
            // TODO: This could potentially reset an in-use state if a zone has a large time-zone offset. An exception should be thrown if still in-use.
            initialState.Initialize(this.GameTimeAdjustmentFactor, this.HoursPerDay);

            this.CurrentTimeOfDay = initialState;
        }
コード例 #2
0
ファイル: DefaultWorld.cs プロジェクト: ramseur/MudDesigner
        /// <summary>
        /// Sets up the world clock.
        /// </summary>
        /// <param name="initialState">The initial state.</param>
        private void SetupWorldClock(TimeOfDayState initialState)
        {
            // We want to reset our current state before we set up the next state
            // The next state starts on a background thread and can cause listeners to access
            // the old state before the new state is assigned preventing a proper reset.
            if (this.CurrentTimeOfDay != null)
            {
                this.CurrentTimeOfDay.TimeUpdated -= this.CurrentTimeOfDayState_TimeUpdated;
            }

            // Register for event updates
            initialState.TimeUpdated += this.CurrentTimeOfDayState_TimeUpdated;

            // Initialize the state.
            // TODO: This could potentially reset an in-use state if a zone has a large time-zone offset. An exception should be thrown if still in-use.
            initialState.Initialize(this.GameTimeAdjustmentFactor, this.HoursPerDay);

            this.CurrentTimeOfDay = initialState;
        }