void Coordinator_Tick() { if (!mTransitioning) { return; } #if DEBUG mStatistics.Begin(); #endif double time = DateTime.UtcNow.Subtract(mTransitionStart).TotalMilliseconds; if (time > mLengthMS) { mTransitioning = false; //Manager.Opacity = mFadeIn ? 1.0 : 0.0; Manager.Opacity = 1.0; if (Finished != null) { Finished(this); } } else { double done = time / mLengthMS; Manager.Opacity = mFadeIn ? done : 1.0 - done; } #if DEBUG mStatistics.End(); #endif }
/// <summary> /// Update the position of the camera. /// </summary> /// <param name="position">The new position for the camera.</param> /// <param name="postionDelta">The delta to be applied to the position for interpolation.</param> /// <param name="orientation">The look at vector for the camera orientation.</param> /// <param name="orientationDelta">The delta to be applied to the look at vector for interpolation.</param> /// <param name="mode">How the camera is to be updated. Can override the current global ControlMode setting.</param> public void Update(Vector3 position, Vector3 postionDelta, Rotation orientation, Rotation orientationDelta, ControlMode mode) { if (mEnableUpdates) { #if DEBUG mUpdateStats.Begin(); #endif mPositionDelta = postionDelta; mOrientationDelta.Update(mRotationLock, orientationDelta); if (mode == Chimera.ControlMode.Absolute) { int x = (int)position.X; int y = (int)position.Y; float height = x >= 0 && x < mHeightmap.GetLength(0) && y >= 0 && y < mHeightmap.GetLength(1) ? mHeightmap[x, y] : mDefaultHeight; height += .5f; if (position.Z < height) { position.Z = height; postionDelta.Z = 0f; } mPosition = position; mOrientation.Update(mRotationLock, orientation); if (CameraUpdated != null && mAlive) { CameraUpdateEventArgs args = new CameraUpdateEventArgs(position, postionDelta, orientation, orientationDelta); #if DEBUG mCameraStats.Begin(); #endif CameraUpdated(this, args); #if DEBUG mCameraStats.End(); #endif //Console.WriteLine("TickFrequency - time since update: " + (mTickLength - DateTime.Now.Subtract(mLastUpdate).TotalMilliseconds)); mLastUpdate = DateTime.UtcNow; } } else if (DeltaUpdated != null && mAlive) { DeltaUpdateEventArgs args = new DeltaUpdateEventArgs(postionDelta, orientationDelta); #if DEBUG mDeltaStats.Begin(); #endif DeltaUpdated(this, args); #if DEBUG mDeltaStats.End(); #endif } #if DEBUG mUpdateStats.End(); #endif } }
void mCore_Tick() { #if DEBUG mStatistics.Begin(); #endif TriggerChange(this); #if DEBUG mStatistics.End(); #endif }
private void StateActivated(State state) { if (mCurrentStats != null) { mCurrentStats.End(); } mCurrentStats = mStatistics[state.Name]; mCurrentStats.Begin(); }
private void FlythroughThread() { mFinished = false; mPlaying = true; #if DEBUG mStats.Begin(); #endif while (mPlaying && mEvents.Length > 0) { IncrementTime(); mPrev = mCurrent; mCurrent = mEvents.CurrentEvent.Value; #if DEBUG mStats.End(); #endif //double wait = (mCore.TickLength * (1.0 / mSpeed)) - DateTime.Now.Subtract(mLastTick).TotalMilliseconds; //double wait = mCore.TickLength - DateTime.Now.Subtract(mLastTick).TotalMilliseconds; //Merge conflict - wait UTC or now? wait <= or < 0? //if (wait < 0) double wait = mCore.TickLength - DateTime.UtcNow.Subtract(mLastTick).TotalMilliseconds; if (wait <= 0) { Logger.Debug("Flythrough Tick overran by " + (wait * -1) + "ms."); } else { System.Threading.Thread.Sleep((int)wait); } #if DEBUG mStats.Begin(); #endif mLastTick = DateTime.UtcNow; mCore.Update(mCurrent.Position, mCurrent.Position - mPrev.Position, mCurrent.Orientation, mCurrent.Orientation - mPrev.Orientation); } lock (mFinishLock) { mFinished = true; Monitor.PulseAll(mFinishLock); } }
static void source_Tick() { #if DEBUG sStatistics.Begin(); #endif if (sController != null && sController.IsConnected) { sGamepad = sController.GetState().Gamepad; } #if DEBUG sStatistics.End(); #endif }
private void mCoordinator_Tick() { #if DEBUG sStatistics.Begin(); #endif if (mSubtitleTimes.Count > 0 && DateTime.UtcNow.Subtract(mStarted).TotalSeconds > mSubtitleTimes.Peek()) { mSubtitlesText.TextString = mSubtitles[mSubtitleTimes.Dequeue()]; mLastSubtitle = DateTime.UtcNow; } else if (DateTime.UtcNow.Subtract(mLastSubtitle).TotalSeconds > mSubtitleTimeoutS && mSubtitlesText.TextString.Length > 0) { mSubtitlesText.TextString = ""; } #if DEBUG sStatistics.End(); #endif }
private void TickMethod() { mAlive = true; while (mAlive) { DateTime tickStart = DateTime.UtcNow; #if DEBUG mTickStats.Begin(); #endif var tick = Tick; #if DEBUG if (tick != null) { Delegate[] tickHandlers = tick.GetInvocationList(); foreach (Delegate currentHandler in tickHandlers) { Action tickAction = (Action)currentHandler; var watch = Stopwatch.StartNew(); tickAction(); watch.Stop(); if (watch.ElapsedMilliseconds > 0) { Logger.InfoFormat("{0}.{2} {1}", currentHandler.Method.DeclaringType.FullName, watch.ElapsedMilliseconds, currentHandler.Method.Name); } } } #else if (tick != null) { tick(); } #endif #if DEBUG mTickStats.End(); #endif int time = (int)(mTickLength - DateTime.UtcNow.Subtract(tickStart).TotalMilliseconds); if (mAlive && time > 0) { Thread.Sleep(time); } } Logger.Info("Tick Thread shut down."); }
void mCoordinator_Tick() { #if DEBUG mStatistics.Begin(); #endif if (Condition) { if (!mCondition) { mCondition = true; if (mWaitMS <= 0.0) { if (mTriggered != null) { mTriggered(this); } } else { mStart = DateTime.UtcNow; } } else if (!mHasTriggered && mWaitMS > 0.0 && DateTime.UtcNow.Subtract(mStart).TotalMilliseconds > mWaitMS) { mHasTriggered = true; mHasTriggered = true; if (mTriggered != null) { mTriggered(this); } mTriggered(this); } } else if (mCondition) { mCondition = false; mHasTriggered = false; } #if DEBUG mStatistics.End(); #endif }
private void mCoordinator_Tick() { #if DEBUG mStatistics.Begin(); #endif if (mDeltas != Vector3.Zero || mOrientation.Pitch != 0.0 || mOrientation.Yaw != 0.0) { mActive = true; TriggerChange(this); } else if (mActive) { mActive = false; TriggerChange(this); } if (MouseDown) { mOrientation = Rotation.Zero; } #if DEBUG mStatistics.End(); #endif }
private void UpdateThread() { Thread.Sleep(500); while (mCont) { #if DEBUG mStatistics.Begin(); #endif DateTime mStart = DateTime.UtcNow; foreach (var controller in mControllers) { controller.UpdateCamera(); } double t = DateTime.UtcNow.Subtract(mStart).TotalMilliseconds - mCore.TickLength; #if DEBUG mStatistics.End(); #endif if (mCont && t > 0.0) { Thread.Sleep((int)t); } } Logger.Info("Proxy Controller thread shut down."); }
void mCore_Tick() { if (!mEnabled) { return; } #if DEBUG mStatistics.Begin(); #endif if (MouseMoved != null) { MouseMoved(Cursor.Position.X, Cursor.Position.Y); } foreach (var manager in mOverlayPlugin.OverlayManagers) { Rectangle bounds = manager.Frame.Monitor.Bounds; if (bounds.Contains(Cursor.Position)) { if (mLastMouse.X != Cursor.Position.X || mLastMouse.Y != Cursor.Position.Y) { Update(manager, bounds, Cursor.Position.X - bounds.Left, Cursor.Position.Y - bounds.Top); mLastMouse = Cursor.Position; mLastCursor = manager.CursorPosition; } #if DEBUG mStatistics.End(); #endif return; } #if DEBUG mStatistics.End(); #endif } }