public void FadeOutAndPause(float forSeconds) { if ((double)forSeconds == 0.0) { if (this.Cue == null || this.Cue.IsDisposed || this.Cue.State == SoundState.Paused) { return; } this.Cue.Pause(); } else { if (this.Dead || this.fadePauseWaiter != null) { return; } float volumeFactor = this.VolumeFactor * this.VolumeLevel * this.VolumeMaster; this.fadePauseWaiter = Waiters.Interpolate((double)forSeconds, (Action <float>)(s => this.VolumeFactor = volumeFactor * (1f - s)), (Action)(() => { if (this.Cue != null && !this.Cue.IsDisposed && this.Cue.State != SoundState.Paused) { this.Cue.Pause(); } this.fadePauseWaiter = (IWaiter)null; })); this.fadePauseWaiter.AutoPause = true; } }
public void SetUp() { _mockReferenceData = CreateMock <IReferenceData>(); _mockReferenceData.Setup(references => references.Load("ReferenceData.xml")); _mockOrderFactory = CreateMock <IOrderFactory>(); //Must be a real dictionary because mocks cannot be used for out parameters. _dishes = new Dictionary <int, IDish>(); _mockReferenceData.Setup(references => references.Dishes).Returns(_dishes); _mockDish1 = CreateMock <IDish>(); _mockDish2 = CreateMock <IDish>(); _mockDish3 = CreateMock <IDish>(); _mockNameAtMealTime1 = CreateMock <IDictionary <string, string> >(); _mockNameAtMealTime2 = CreateMock <IDictionary <string, string> >(); _mockNameAtMealTime3 = CreateMock <IDictionary <string, string> >(); _mockMultipleAtMealTime1 = CreateMock <IDictionary <string, bool> >(); _mockMultipleAtMealTime2 = CreateMock <IDictionary <string, bool> >(); _mockMultipleAtMealTime3 = CreateMock <IDictionary <string, bool> >(); _mockDish1.SetupGet(dish => dish.NameAtMealTime).Returns(_mockNameAtMealTime1.Object); _mockDish1.SetupGet(dish => dish.MultipleAtMealTime).Returns(_mockMultipleAtMealTime1.Object); _dishes[1] = _mockDish1.Object; _dishes[2] = _mockDish2.Object; _dishes[3] = _mockDish3.Object; _waiter = new Waiter(_mockReferenceData.Object, _mockOrderFactory.Object); }
public static PluginLoader <T> Create(string appName, IPluginPaths paths = null, IAppDomain appDomain = null, IPluginLoaderSettings settings = null, ITypeLoader <T> typeLoader = null, IAssemblyCache assemblyDictionary = null, IAssemblyNameReader assemblyNameReader = null, IAssemblyLoader assemblyLoader = null, IWaiter waiter = null, IPluginDependencyResolverObjectCreator pluginDependencyResolverObjectCreator = null, IPluginDependencyResolverCacheFactory pluginDependencyResolverCacheFactory = null, IPluginCacheFactory <T> pluginCacheFactory = null, IPluginLoaderLogger logger = null) { logger = logger ?? PluginLoaderLogger.Factory(new AppSettings()); appDomain = appDomain ?? new AppDomainWrapper(AppDomain.CurrentDomain, logger); paths = paths ?? new AppPluginPaths(appName, null, appDomain, logger); settings = settings ?? PluginLoaderSettings.Default; typeLoader = typeLoader ?? new TypeLoader <T>(settings, logger); assemblyNameReader = assemblyNameReader ?? new AssemblyNameReader(); assemblyDictionary = assemblyDictionary ?? new AssemblyCache(appDomain, assemblyNameReader, logger); assemblyLoader = assemblyLoader ?? new AssemblyLoader(appDomain, settings, assemblyDictionary, assemblyNameReader, logger); waiter = waiter ?? new Waiter(logger); pluginDependencyResolverObjectCreator = pluginDependencyResolverObjectCreator ?? new PluginDependencyResolverObjectCreator(appDomain, settings, assemblyLoader, waiter, new AssemblyResolveCache(), logger); pluginDependencyResolverCacheFactory = pluginDependencyResolverCacheFactory ?? new PluginDependencyResolverCacheFactory(pluginDependencyResolverObjectCreator, logger); pluginCacheFactory = pluginCacheFactory ?? new PluginCacheFactory <T>(typeLoader, pluginDependencyResolverCacheFactory, assemblyLoader, logger); return(new PluginLoader <T>(paths, pluginCacheFactory)); }
public TestProbeParentActor( ITestProbeCreator testProbeCreator, IWaiter exceptionWaiter, TestKitBase testKit, Func <Exception, Directive> decider, IReadOnlyDictionary <Type, Func <object, object> > handlers) { _exceptionWaiter = exceptionWaiter; _decider = decider; _unhandledExceptions = new List <Exception>(); TestProbe = testProbeCreator.Create(testKit); TestProbe.SetAutoPilot(new DelegateAutoPilot((_, message) => { Type messageType = message.GetType(); if (handlers.TryGetValue(messageType, out Func <object, object> handler)) { object reply = handler(message); Context.Sender.Tell(reply); } return(AutoPilot.KeepRunning); })); ReceiveAny(o => TestProbe.Forward(o)); Ref = Self; }
bool IChannel.TrySend(IWaiter w) { var s = (Waiter <T>)w; lock (sync) { if (closed) { return(false); } if (items.Empty) { Waiter <T> wr = receivers.Dequeue(); if (wr != null) { wr.Value = s.Value; Debug.Print("Thread {0}, {1} TrySend({2}), waking up receiver", Thread.CurrentThread.ManagedThreadId, GetType(), wr.Value); wr.Wakeup(); return(true); } } if (!items.Full) { Debug.Print("Thread {0}, {1} TrySend({2}), add item to queue", Thread.CurrentThread.ManagedThreadId, GetType(), s.Value.Value); items.Enqueue(s.Value.Value); return(true); } } return(false); }
private void DoPause(object s, EventArgs ea) { bool checkActive = s == this.Game; if (this.loadWaiter != null) { return; } this.loadWaiter = Waiters.Wait((Func <bool>)(() => { if (this.GameState.Loading) { return(false); } if (checkActive) { return(Intro.Instance == null); } else { return(true); } }), (Action)(() => { this.loadWaiter = (IWaiter)null; if (checkActive && this.Game.IsActive || MainMenu.Instance != null) { return; } this.GameState.Pause(); })); }
// /* // ------------------------------------------------------------------------------------------------------ // -----------------------------OBSERVEUR--CHEF--RANG---------------------------------------------------- // ------------------------------------------------------------------------------------------------------ // */ public void AttachChefRang(IWaiter chefRang) { if (!this.ObserversChefRang.Contains(chefRang)) { this.ObserversChefRang.Add(chefRang); } }
/// <summary>Try to receive without blocking</summary> bool IChannel.TryRecv(IWaiter w) { var r = (Waiter <T>)w; lock (sync) { if (!items.Empty) { r.Value = Maybe <T> .Some(items.Dequeue()); Debug.Print("Thread {0}, {1} TryRecvSelect, removed {2} from itemq", Thread.CurrentThread.ManagedThreadId, GetType(), r.Value); MoveSendQToItemQ(); return(true); } if (!senders.Empty) { Waiter <T> s = senders.Dequeue(); if (s != null) { Debug.Print("Thread {0}, {1} RecvSelect, waking sender", Thread.CurrentThread.ManagedThreadId, GetType()); r.Value = s.Value; s.Wakeup(); return(true); } } if (closed) { // closed channels return no value and dont block return(true); } Debug.Print("Thread {0}, {1} TryRecvSelect, itemq and sendq are empty", Thread.CurrentThread.ManagedThreadId, GetType()); return(false); } }
public void DettachSocket(IWaiter Socket) { if (this.ObserversSocket.Contains(Socket)) { this.ObserversSocket.Add(Socket); } }
public void DettachServeur(IWaiter serveur) { if (this.ObserversServeur.Contains(serveur)) { this.ObserversServeur.Add(serveur); } }
public void DettachMaitreHotel(IWaiter hostMaster) { if (this.ObserversChefRang.Contains(hostMaster)) { this.ObserversChefRang.Add(hostMaster); } }
// /* // ------------------------------------------------------------------------------------------------------ // -----------------------------OBSERVEUR--MAITRE--HOTEL-------------------------------------------------- // ------------------------------------------------------------------------------------------------------ //*/ public void AttachMaitreHotel(IWaiter hostMaster) { if (!this.ObserversMaitreHotel.Contains(hostMaster)) { this.ObserversMaitreHotel.Add(hostMaster); } }
private void ScheduleHit() { this.wutex2 = (IWaiter)null; this.wutex1 = Waiters.Wait(0.25, (Action)(() => { Waiters.Wait(0.25, (Action)(() => this.wutex1 = (IWaiter)null)); this.PlayerManager.Action = ActionType.HitBell; this.PlayerManager.Animation.Timing.Restart(); this.SinceHit = TimeSpan.Zero; SoundEffectExtensions.EmitAt(this.sBellHit[(int)(this.CameraManager.Viewpoint - 1)], this.BellAo.Position); this.SoundManager.FadeVolume(0.25f, 1f, 2f); this.AngularVelocity += new Vector2(-FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitZ), FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitX)) * 0.075f; if (this.Solved) { return; } if (this.LastHit != Viewpoint.None && this.LastHit != this.CameraManager.Viewpoint) { this.Hits[this.CameraManager.Viewpoint] = 0; } this.LastHit = this.CameraManager.Viewpoint; Dictionary <Viewpoint, int> local_1; Viewpoint local_2; (local_1 = this.Hits)[local_2 = this.CameraManager.Viewpoint] = local_1[local_2] + 1; if (!Enumerable.All <KeyValuePair <Viewpoint, int> >((IEnumerable <KeyValuePair <Viewpoint, int> >) this.Hits, (Func <KeyValuePair <Viewpoint, int>, bool>)(kvp => kvp.Value == this.ExpectedHits[kvp.Key]))) { return; } this.Solved = true; this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.BellAo.Id); this.LevelService.ResolvePuzzle(); ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, this.BellAo, this.OriginalPosition)); })); this.wutex1.AutoPause = true; }
public TestBase() : base(AkkaConfig.Config) { // Create mocks WaiterMock = new Mock <IWaiter>(); RecipientMock = new Mock <IActorRef>(); // Create objects used by mocks CallOrder = new List <string>(); // Create objects passed into sut methods Waiter = WaiterMock.Object; ExpectedEventCount = TestHelper.GenerateNumber(); Message = TestHelper.Generate <object>(); Recipient = RecipientMock.Object; Sender = CreateTestProbe(); // Mocking sender breaks Akka so a TestProbe is used // Set up mocks WaiterMock .Setup(waiter => waiter.Start(this, ExpectedEventCount)) .Callback(() => CallOrder.Add(nameof(IWaiter.Start))); WaiterMock .Setup(waiter => waiter.Wait()) .Callback(() => CallOrder.Add(nameof(IWaiter.Wait))); WaiterMock .Setup(waiter => waiter.ResolveEvent()) .Callback(() => CallOrder.Add(nameof(IWaiter.ResolveEvent))); RecipientMock .Setup(waiter => waiter.Tell(Message, TestActor)) .Callback(() => CallOrder.Add(nameof(IActorRef.Tell))); RecipientMock .Setup(waiter => waiter.Tell(Message, Sender)) .Callback(() => CallOrder.Add(nameof(IActorRef.Tell) + "Sender")); }
public void DettachChefRang(IWaiter rankLeader) { if (this.ObserversChefRang.Contains(rankLeader)) { this.ObserversChefRang.Add(rankLeader); } }
public ConsoleApplication(TextWriter errorWriter, TextWriter logWriter, int bufferWidth, IWaiter waitAtEnd) { _errorWriter = errorWriter; _logWriter = logWriter; _bufferWidth = bufferWidth; _waitAtEnd = waitAtEnd; }
internal RetryAfterAwareBackOffHandler( RetryOptions retryOptions, IClock clock = null, IWaiter waiter = null) : base(CreateInitializer(retryOptions)) { this.clock = clock ?? SystemClock.Default; this.waiter = waiter; }
bool IChannel.Send(IWaiter w) { var s = (Waiter <T>)w; Debug.Assert(s.Value.IsSome); lock (sync) { if (closed) { throw new ClosedChannelException("You cannot send on a closed Channel"); } if (items.Empty) { Waiter <T> wr = receivers.Dequeue(); if (wr != null) { wr.Value = s.Value; Debug.Print("Thread {0}, {1} Send({2}), SetItem suceeded", Thread.CurrentThread.ManagedThreadId, GetType(), wr.Value); wr.Wakeup(); return(true); } } if (!items.Full) { Debug.Print("Thread {0}, {1} Send({2}), spare capacity, adding to itemq", Thread.CurrentThread.ManagedThreadId, GetType(), s.Value.Value); items.Enqueue(s.Value.Value); return(true); } // at capacity, queue our waiter until some capacity is freed up by a recv senders.Enqueue(s); return(false); } }
internal RetryHttpClientInitializer( RetryOptions retryOptions, IClock clock = null, IWaiter waiter = null) { this.retryOptions = retryOptions.ThrowIfNull(nameof(retryOptions)); this.backOffHandler = new RetryAfterAwareBackOffHandler( this.retryOptions, clock, waiter); }
public AsynchronousWorker( IAsynchronousWorkerHandler <T> handler, IWaiter waiter, int workerThreadCount, int maxItemCount, TimeSpan?blockingQueueTimeout) { if (blockingQueueTimeout.HasValue) { _queue = new ConcurrentBoundedBlockingQueue <T>( new ManualResetEventWrapper(), blockingQueueTimeout.Value, maxItemCount); } else { _queue = new ConcurrentBoundedQueue <T>(maxItemCount); } _handler = handler; _waiter = waiter; for (int i = 0; i < workerThreadCount; ++i) { _workers.Add(Task.Factory.StartNew(() => Dequeue(), TaskCreationOptions.LongRunning)); } }
public void FireWaiter(IWaiter waiter) { if (this.waiters != null && this.waiters.Count > 0) { this.waiters.Remove(waiter); } }
void IChannel.RemoveReceiver(IWaiter w) { var r = (Waiter <T>)w; lock (sync) { receivers.Remove(r); } }
public void Setup() { connectionFactory = Substitute.For<IConnectionFactory>(); timer = Substitute.For<ITimer>(); waiter = Substitute.For<IWaiter>(); sut = new ReliableConnection(connectionFactory, timer, waiter, new Aggregator()); }
public void Setup() { connectionFactory = Substitute.For <IConnectionFactory>(); timer = Substitute.For <ITimer>(); waiter = Substitute.For <IWaiter>(); sut = new ReliableConnection(connectionFactory, timer, waiter, new Aggregator()); }
internal void Release() { if (chan != null && Waiter != null) { chan.ReleaseWaiter(Waiter); Waiter = null; } chan = null; }
public ReliableConnection(IConnectionFactory connectionFactory, ITimer timer, IWaiter waiter, IAggregator aggregator) { this.connectionFactory = connectionFactory; this.timer = timer; this.waiter = waiter; this.aggregator = aggregator; token = tokenSource.Token; timer.Callback += BlockingConnect; }
public void HireWaiter(IWaiter waiter) { if (waiter.Age < 18 || waiter.Age > 65) { throw new ArgumentOutOfRangeException("Ne mojem da naemame hora pod 18 godini i hora nad 65 godini."); } this.waiters.Add(waiter); }
public TestActorRef <TActor> Create <TActor>(IWaiter childWaiter, TestKitBase testKit, Props props, int expectedChildrenCount, IActorRef supervisor) where TActor : ActorBase { childWaiter.Start(testKit, expectedChildrenCount); TestActorRef <TActor> sut = supervisor != null ? testKit.ActorOfAsTestActorRef <TActor>(props, supervisor) : testKit.ActorOfAsTestActorRef <TActor>(props); childWaiter.Wait(); return(sut); }
private static ConfigurableHttpClient CreateHttpClient( MockMessageHandler handler, RetryOptions options, IWaiter waiter, IClock clock = null) { var args = new CreateHttpClientArgs(); args.Initializers.Add(new RetryHttpClientInitializer(options, clock, waiter)); var factory = new MockHttpClientFactory(handler); return(factory.CreateHttpClient(args)); }
public void MoveToHeight() { if (this.MovingToHeight) { return; } this.MovingToHeight = true; float y = this.ArtObject.ActorSettings.ShouldMoveToHeight.Value; this.ArtObject.ActorSettings.ShouldMoveToHeight = new float?(); Vector3 vector3 = this.ArtObject.Position + this.CenterOffset; Vector3 movement = (new Vector3(0.0f, y, 0.0f) - vector3) * Vector3.UnitY + Vector3.UnitY / 2f; Vector3 origin = vector3; Vector3 destination = vector3 + movement; float lastHeight = origin.Y; if (this.PlayerManager.Action == ActionType.PivotTombstone || this.PlayerManager.Grounded && this.AttachedGroup.Triles.Contains(this.PlayerManager.Ground.First)) { this.MovingToHeight = false; } else if ((double)Math.Abs(movement.Y) < 1.0) { this.MovingToHeight = false; } else { IWaiter waiter = Waiters.Interpolate((double)Math.Abs(movement.Y / 2f), (Action <float>)(step => { float local_0 = Easing.EaseInOut((double)step, EasingType.Sine); this.ArtObject.Position = Vector3.Lerp(origin, destination, local_0); this.ArtObject.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, local_0 * 1.570796f * (float)(int)Math.Round((double)movement.Y / 2.0)); foreach (TrileInstance item_0 in this.AttachedGroup.Triles) { item_0.Position += Vector3.UnitY * (this.ArtObject.Position.Y - lastHeight); item_0.PhysicsState.Velocity = Vector3.UnitY * (this.ArtObject.Position.Y - lastHeight); this.LevelManager.UpdateInstance(item_0); } lastHeight = this.ArtObject.Position.Y; }), (Action)(() => { this.ArtObject.Position = destination; this.ArtObject.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)(int)Math.Round((double)movement.Y / 2.0)); foreach (TrileInstance item_1 in this.AttachedGroup.Triles) { item_1.PhysicsState.Velocity = Vector3.Zero; } this.MovingToHeight = false; })); waiter.AutoPause = true; waiter.UpdateOrder = -2; } }
public void TellMessage <TMessage>(IWaiter waiter, TestKitBase testKit, IActorRef recipient, TMessage message, int waitForCount, IActorRef sender = null) { waiter.Start(testKit, waitForCount); if (sender == null) { recipient.Tell(message); } else { recipient.Tell(message, sender); } waiter.Wait(); }
private void DoPause(object s, EventArgs ea) { bool checkActive = s == this.Game; if (this.loadWaiter != null) return; this.loadWaiter = Waiters.Wait((Func<bool>) (() => { if (this.GameState.Loading) return false; if (checkActive) return Intro.Instance == null; else return true; }), (Action) (() => { this.loadWaiter = (IWaiter) null; if (checkActive && this.Game.IsActive || MainMenu.Instance != null) return; this.GameState.Pause(); })); }
public void SetUp() { _mockReferenceData = CreateMock<IReferenceData>(); _mockReferenceData.Setup(references => references.Load("ReferenceData.xml")); _mockOrderFactory = CreateMock<IOrderFactory>(); //Must be a real dictionary because mocks cannot be used for out parameters. _dishes = new Dictionary<int, IDish>(); _mockReferenceData.Setup(references => references.Dishes).Returns(_dishes); _mockDish1 = CreateMock<IDish>(); _mockDish2 = CreateMock<IDish>(); _mockDish3 = CreateMock<IDish>(); _mockNameAtMealTime1 = CreateMock<IDictionary<string, string>>(); _mockNameAtMealTime2 = CreateMock<IDictionary<string, string>>(); _mockNameAtMealTime3 = CreateMock<IDictionary<string, string>>(); _mockMultipleAtMealTime1 = CreateMock<IDictionary<string, bool>>(); _mockMultipleAtMealTime2 = CreateMock<IDictionary<string, bool>>(); _mockMultipleAtMealTime3 = CreateMock<IDictionary<string, bool>>(); _mockDish1.SetupGet(dish => dish.NameAtMealTime).Returns(_mockNameAtMealTime1.Object); _mockDish1.SetupGet(dish => dish.MultipleAtMealTime).Returns(_mockMultipleAtMealTime1.Object); _dishes[1] = _mockDish1.Object; _dishes[2] = _mockDish2.Object; _dishes[3] = _mockDish3.Object; _waiter = new Waiter(_mockReferenceData.Object, _mockOrderFactory.Object); }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.InMap || (this.PointsList.Length == 0 || this.Dot.PreventPoI) || (this.GameState.Paused || this.GameState.InMenuCube || this.Dot.Owner != null && this.Dot.Owner != this) || (this.GameState.FarawaySettings.InTransition || ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action))) return; Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint); BoundingBox boundingBox1 = new BoundingBox(this.PlayerManager.Center - new Vector3(6f), this.PlayerManager.Center + new Vector3(6f)); Volume volume1 = (Volume) null; foreach (Volume volume2 in this.PointsList) { if (volume2.Enabled) { BoundingBox boundingBox2 = volume2.BoundingBox; boundingBox2.Min -= vector3 * 1000f; boundingBox2.Max += vector3 * 1000f; if (boundingBox1.Contains(boundingBox2) != ContainmentType.Disjoint) { this.Dot.ComeOut(); this.Dot.Behaviour = DotHost.BehaviourType.RoamInVolume; this.Dot.RoamingVolume = volume1 = volume2; } if (this.SpeechBubble.Hidden) { if (this.talkWaiter != null && this.talkWaiter.Alive) this.talkWaiter.Cancel(); if (this.eDotTalk != null && !this.eDotTalk.Dead) this.eDotTalk.FadeOutAndPause(0.1f); } if (!this.SpeechBubble.Hidden && this.PlayerManager.CurrentVolumes.Contains(volume2) && volume2.ActorSettings.DotDialogue.Count > 0 && (this.PlayerManager.Action == ActionType.Suffering || this.PlayerManager.Action == ActionType.SuckedIn || (this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp))) { this.SpeechBubble.Hide(); this.Dot.Behaviour = DotHost.BehaviourType.ReadyToTalk; this.InGroup = false; } if (!this.GameState.InFpsMode && this.PlayerManager.CurrentVolumes.Contains(volume2) && volume2.ActorSettings.DotDialogue.Count > 0) { if (this.SpeechBubble.Hidden && (this.InputManager.CancelTalk == FezButtonState.Pressed || this.InGroup)) { switch (this.PlayerManager.Action) { case ActionType.Sliding: case ActionType.Landing: case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Idle: case ActionType.Walking: case ActionType.Running: volume2.ActorSettings.NextLine = (volume2.ActorSettings.NextLine + 1) % volume2.ActorSettings.DotDialogue.Count; int index1 = (volume2.ActorSettings.NextLine + 1) % volume2.ActorSettings.DotDialogue.Count; this.InGroup = volume2.ActorSettings.DotDialogue[volume2.ActorSettings.NextLine].Grouped && volume2.ActorSettings.DotDialogue[index1].Grouped && index1 != 0; volume2.ActorSettings.PreventHey = true; string index2 = volume2.ActorSettings.DotDialogue[volume2.ActorSettings.NextLine].ResourceText; bool flag; if (this.GameState.SaveData.OneTimeTutorials.TryGetValue(index2, out flag) && !flag) { this.GameState.SaveData.OneTimeTutorials[index2] = true; this.SyncTutorials(); } if (this.talkWaiter != null && this.talkWaiter.Alive) this.talkWaiter.Cancel(); string @string = GameText.GetString(index2); this.SpeechBubble.ChangeText(@string); this.PlayerManager.Action = ActionType.ReadingSign; if (this.eDotTalk == null || this.eDotTalk.Dead) { this.eDotTalk = SoundEffectExtensions.EmitAt(this.sDotTalk, this.Dot.Position, true); } else { this.eDotTalk.Position = this.Dot.Position; Waiters.Wait(0.100000001490116, (Action) (() => { this.eDotTalk.Cue.Resume(); this.eDotTalk.VolumeFactor = 1f; })).AutoPause = true; } this.talkWaiter = Waiters.Wait(0.100000001490116 + 0.0750000029802322 * (double) Util.StripPunctuation(@string).Length * (Culture.IsCJK ? 2.0 : 1.0), (Action) (() => { if (this.eDotTalk == null) return; this.eDotTalk.FadeOutAndPause(0.1f); })); this.talkWaiter.AutoPause = true; break; } } if (this.SpeechBubble.Hidden && !volume2.ActorSettings.PreventHey) { if (this.PlayerManager.Grounded) { switch (this.PlayerManager.Action) { case ActionType.Sliding: case ActionType.Landing: case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Idle: case ActionType.Walking: case ActionType.Running: this.Dot.Behaviour = DotHost.BehaviourType.ThoughtBubble; this.Dot.FaceButton = DotFaceButton.B; if (this.Dot.Owner != this) this.Dot.Hey(); this.Dot.Owner = (object) this; break; default: this.Dot.Behaviour = DotHost.BehaviourType.ReadyToTalk; break; } } } else this.Dot.Behaviour = DotHost.BehaviourType.ReadyToTalk; if (!this.SpeechBubble.Hidden) this.SpeechBubble.Origin = this.Dot.Position; if (this.Dot.Behaviour == DotHost.BehaviourType.ReadyToTalk || this.Dot.Behaviour == DotHost.BehaviourType.ThoughtBubble) break; } } } if (this.Dot.Behaviour != DotHost.BehaviourType.ThoughtBubble && this.Dot.Owner == this && this.SpeechBubble.Hidden) this.Dot.Owner = (object) null; if (volume1 != null || this.Dot.RoamingVolume == null) return; this.Dot.Burrow(); }
public void OnMuteStateChanged(float fadeDuration) { if (this.ActiveForDayPhase && !this.ForceMuted && (double) this.volume != 1.0) { float originalVolume = this.volume; IWaiter thisWaiter = (IWaiter) null; this.volume += 1.0 / 1000.0; this.transitionWaiter = thisWaiter = Waiters.Interpolate((double) fadeDuration * (1.0 - (double) this.volume), (Action<float>) (s => { if (this.transitionWaiter != thisWaiter) return; this.volume = originalVolume + s * (1f - originalVolume); if (this.cue == null || this.cue.IsDisposed) return; this.cue.Volume = this.volume; }), (Action) (() => { if (this.transitionWaiter != thisWaiter) return; this.volume = 1f; if (this.cue == null || this.cue.IsDisposed) return; this.cue.Volume = this.volume; })); } else { if (this.ActiveForDayPhase && !this.ForceMuted || (double) this.volume == 0.0) return; float originalVolume = this.volume; IWaiter thisWaiter = (IWaiter) null; this.volume -= 1.0 / 1000.0; this.transitionWaiter = thisWaiter = Waiters.Interpolate((double) fadeDuration * (double) this.volume, (Action<float>) (s => { if (this.transitionWaiter != thisWaiter) return; this.volume = originalVolume * (1f - s); if (this.cue == null || this.cue.IsDisposed) return; this.cue.Volume = this.volume; }), (Action) (() => { if (this.transitionWaiter != thisWaiter) return; this.volume = 0.0f; if (this.cue == null || this.cue.IsDisposed) return; this.cue.Volume = this.volume; })); } }
private void ResizeStars() { if (this.LevelManager.Sky == null || this.stars.TextureMap == null || !this.LevelManager.Rainy && !(this.LevelManager.Sky.Name == "ABOVE") && (!(this.LevelManager.Sky.Name == "PYRAMID_SKY") && !(this.LevelManager.Sky.Name == "OBS_SKY")) && (double) this.TimeManager.NightContribution == 0.0) return; if ((double) this.stars.Material.Opacity > 0.0) this.stars.Position = this.CameraManager.Position - this.CameraManager.ViewOffset; if (this.EngineState.FarawaySettings.InTransition) { float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice); if (!this.stars.Effect.ForcedProjectionMatrix.HasValue) { this.sideToSwap = (int) FezMath.GetOpposite(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)); if (this.sideToSwap > 1) --this.sideToSwap; if (this.sideToSwap == 4) --this.sideToSwap; } float num1 = (float) this.GraphicsDevice.Viewport.Width / (this.CameraManager.PixelsPerTrixel * 16f); float num2; if ((double) this.EngineState.FarawaySettings.OriginFadeOutStep == 1.0) { float amount = Easing.EaseInOut(((double) this.EngineState.FarawaySettings.TransitionStep - (double) this.startStep) / (1.0 - (double) this.startStep), EasingType.Sine); num2 = num1 = MathHelper.Lerp(num1, this.EngineState.FarawaySettings.DestinationRadius, amount); } else num2 = num1; this.stars.Effect.ForcedProjectionMatrix = new Matrix?(Matrix.CreateOrthographic(num1 / viewScale, num1 / this.CameraManager.AspectRatio / viewScale, this.CameraManager.NearPlane, this.CameraManager.FarPlane)); int index = (int) FezMath.GetOpposite(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)); if (index > 1) --index; if (index == 4) --index; if (index != this.sideToSwap) { float num3 = SkyHost.starSideOffsets[index]; SkyHost.starSideOffsets[index] = SkyHost.starSideOffsets[this.sideToSwap]; SkyHost.starSideOffsets[this.sideToSwap] = num3; this.sideToSwap = index; } this.stars.Scale = new Vector3(1f, 5f, 1f) * num2 * 2f; } else { if (this.waiter == null && this.stars.Effect.ForcedProjectionMatrix.HasValue) this.waiter = Waiters.Wait(1.0, (Action) (() => { this.stars.Effect.ForcedProjectionMatrix = new Matrix?(); this.waiter = (IWaiter) null; })); this.stars.Scale = new Vector3(1f, 5f, 1f) * (float) ((double) this.CameraManager.Radius * 2.0 + (double) Easing.EaseOut(this.CameraManager.ProjectionTransition ? (FezMath.IsOrthographic(this.CameraManager.Viewpoint) ? (double) (1f - this.CameraManager.ViewTransitionStep) : (double) this.CameraManager.ViewTransitionStep) : 1.0, EasingType.Quintic) * 40.0); } int num4 = 0; foreach (Group group in this.stars.Groups) { float m11 = this.stars.Scale.X / ((float) this.stars.TextureMap.Width / 16f); float m22 = this.stars.Scale.Y / ((float) this.stars.TextureMap.Height / 16f); float num1 = SkyHost.starSideOffsets[num4++]; group.TextureMatrix.Set(new Matrix?(new Matrix(m11, 0.0f, 0.0f, 0.0f, 0.0f, m22, 0.0f, 0.0f, num1 - m11 / 2f, num1 - m22 / 2f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f))); } }
public void FadeVolume(float fromVolume, float toVolume, float overSeconds) { IWaiter thisWaiter = (IWaiter) null; this.volTransitionWaiter = thisWaiter = Waiters.Interpolate((double) overSeconds, (Action<float>) (step => { if (this.volTransitionWaiter != thisWaiter || this.EngineState.DotLoading) return; this.MusicVolumeFactor = MathHelper.Lerp(fromVolume, toVolume, step); }), (Action) (() => { if (this.volTransitionWaiter != thisWaiter) return; if (!this.EngineState.DotLoading) this.MusicVolumeFactor = toVolume; this.volTransitionWaiter = (IWaiter) null; })); }
public void FadeFrequencies(bool toLowPass, float fadeDuration) { if (!this.IsLowPass && toLowPass) { float originalStep = this.FrequencyStep; IWaiter thisWaiter = (IWaiter) null; this.freqTransitionWaiter = thisWaiter = Waiters.Interpolate((double) fadeDuration * (1.0 - (double) originalStep), (Action<float>) (s => { if (this.freqTransitionWaiter != thisWaiter) return; this.FrequencyStep = originalStep + s * (1f - originalStep); if (!OggStreamer.HasInstance) return; OggStreamer.Instance.LowPassHFGain = MathHelper.Lerp(1f, 0.025f, Easing.EaseOut((double) this.FrequencyStep, EasingType.Cubic)); }), (Action) (() => { if (this.freqTransitionWaiter != thisWaiter) return; this.FrequencyStep = 1f; if (!OggStreamer.HasInstance) return; OggStreamer.Instance.LowPassHFGain = 0.025f; })); } else if (this.IsLowPass && !toLowPass) { float originalStep = this.FrequencyStep; IWaiter thisWaiter = (IWaiter) null; this.freqTransitionWaiter = thisWaiter = Waiters.Interpolate((double) fadeDuration * (double) originalStep, (Action<float>) (s => { if (this.freqTransitionWaiter != thisWaiter) return; this.FrequencyStep = originalStep * (1f - s); if (!OggStreamer.HasInstance) return; OggStreamer.Instance.LowPassHFGain = MathHelper.Lerp(1f, 0.025f, Easing.EaseIn((double) this.FrequencyStep, EasingType.Cubic)); }), (Action) (() => { if (this.freqTransitionWaiter != thisWaiter) return; this.FrequencyStep = 0.0f; if (!OggStreamer.HasInstance) return; OggStreamer.Instance.LowPassHFGain = 1f; })); } this.IsLowPass = toLowPass; }
private void ScheduleTurnTo() { this.wutex2 = Waiters.Wait(0.4, (Func<float, bool>) (_ => this.PlayerManager.Action != ActionType.TurnToBell), new Action(this.ScheduleHit)); this.wutex2.AutoPause = true; }
static Program() { _waiter = new Waiter(new ReferenceData(new DishFactory()), new OrderFactory()); }
private void ScheduleHit() { this.wutex2 = (IWaiter) null; this.wutex1 = Waiters.Wait(0.25, (Action) (() => { Waiters.Wait(0.25, (Action) (() => this.wutex1 = (IWaiter) null)); this.PlayerManager.Action = ActionType.HitBell; this.PlayerManager.Animation.Timing.Restart(); this.SinceHit = TimeSpan.Zero; SoundEffectExtensions.EmitAt(this.sBellHit[(int) (this.CameraManager.Viewpoint - 1)], this.BellAo.Position); this.SoundManager.FadeVolume(0.25f, 1f, 2f); this.AngularVelocity += new Vector2(-FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitZ), FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitX)) * 0.075f; if (this.Solved) return; if (this.LastHit != Viewpoint.None && this.LastHit != this.CameraManager.Viewpoint) this.Hits[this.CameraManager.Viewpoint] = 0; this.LastHit = this.CameraManager.Viewpoint; Dictionary<Viewpoint, int> local_1; Viewpoint local_2; (local_1 = this.Hits)[local_2 = this.CameraManager.Viewpoint] = local_1[local_2] + 1; if (!Enumerable.All<KeyValuePair<Viewpoint, int>>((IEnumerable<KeyValuePair<Viewpoint, int>>) this.Hits, (Func<KeyValuePair<Viewpoint, int>, bool>) (kvp => kvp.Value == this.ExpectedHits[kvp.Key]))) return; this.Solved = true; this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.BellAo.Id); this.LevelService.ResolvePuzzle(); ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, this.BellAo, this.OriginalPosition)); })); this.wutex1.AutoPause = true; }
public void FadeOutAndPause(float forSeconds) { if ((double) forSeconds == 0.0) { if (this.Cue == null || this.Cue.IsDisposed || this.Cue.State == SoundState.Paused) return; this.Cue.Pause(); } else { if (this.Dead || this.fadePauseWaiter != null) return; float volumeFactor = this.VolumeFactor * this.VolumeLevel * this.VolumeMaster; this.fadePauseWaiter = Waiters.Interpolate((double) forSeconds, (Action<float>) (s => this.VolumeFactor = volumeFactor * (1f - s)), (Action) (() => { if (this.Cue != null && !this.Cue.IsDisposed && this.Cue.State != SoundState.Paused) this.Cue.Pause(); this.fadePauseWaiter = (IWaiter) null; })); this.fadePauseWaiter.AutoPause = true; } }