internal void Remove(Event e) { if (!events.Contains(e)) { return; } events.Remove(e); switch (e.Type) { case EventTypes.Sprite: case EventTypes.Animation: case EventTypes.Background: if (e.Layer == StoryLayer.Background) { spriteManagerBG.Remove(e.Sprite); spriteManagerBGWide.Remove(e.Sprite); } else { spriteManagerFG.Remove(e.Sprite); } storyLayerSprites[(int)e.Layer].Remove(e); break; case EventTypes.Break: eventBreaks.Remove((EventBreak)e); break; case EventTypes.Video: videoSprites.Remove((pVideo)e.Sprite); break; case EventTypes.Sample: EventSample _e = (EventSample)e; AudioEngine.SampleEvents.Remove(_e.SampleCache); eventSamples.Remove(_e); break; } }
internal void Update() { float targetAlpha = backgroundIsReady && showStoryboard ? 1 : 0; float maskingTargetAlpha = WidescreenStoryboard ? 0 : targetAlpha; if (GameBase.Mode == OsuModes.Edit) { spriteManagerFG.Alpha = spriteManagerBG.Alpha = targetAlpha; spriteManagerMasking.Alpha = maskingTargetAlpha; } else { if (spriteManagerFG.Alpha != targetAlpha) { spriteManagerBG.Alpha = spriteManagerFG.Alpha = OsuMathHelper.Clamp(spriteManagerFG.Alpha + ((targetAlpha < spriteManagerFG.Alpha ? -0.07f : 0.07f) * (float)GameBase.FrameRatio), 0, 1); } if (spriteManagerMasking.Alpha != maskingTargetAlpha) { spriteManagerMasking.Alpha = OsuMathHelper.Clamp(spriteManagerMasking.Alpha + ((maskingTargetAlpha < spriteManagerMasking.Alpha ? -0.07f : 0.07f) * (float)GameBase.FrameRatio), 0, 1); } } bool breakMode = false; if (hitObjectManager.hitObjectsCount > 0) { if (beforeGameplay && AudioEngine.Time > hitObjectManager.EarliestHitObject.HittableStartTime - hitObjectManager.PreEmpt) { beforeGameplay = false; } else if (!afterGameplay && AudioEngine.Time > hitObjectManager.LatestHitObject.HittableEndTime + hitObjectManager.HitWindow50) { afterGameplay = true; } } else { beforeGameplay = true; afterGameplay = false; } if (GameBase.Mode == OsuModes.Play && (beforeGameplay || afterGameplay)) { breakMode = true; } for (int i = 0; i < eventBreaks.Count; i++) { EventBreak e = eventBreaks[i]; if (AudioEngine.Time < e.StartTime || AudioEngine.Time > e.EndTime) { continue; } breakMode = true; BreakCurrent = e; break; } if (GameBase.Mode == OsuModes.Play && Player.Passing != passingCurrent) { passingCurrent = Player.Passing; if (passingCurrent) { InvokeOnPassing(); } else { InvokeOnFailing(); } //Sprites for (int i = 0; i < storyLayerSprites[(int)StoryLayer.Fail].Count; i++) { Event e = storyLayerSprites[(int)StoryLayer.Fail][i]; e.Sprite.Bypass = passingCurrent; } //Samples for (int i = 0; i < storyLayerSamples[(int)StoryLayer.Fail].Count; i++) { EventSample e = (EventSample)storyLayerSamples[(int)StoryLayer.Fail][i]; if (passingCurrent) { AudioEngine.SampleEvents.Remove(e.SampleCache); } else { AudioEngine.SampleEvents.Add(e.SampleCache); } } if (!firstRun) { //Sprites for (int i = 0; i < storyLayerSprites[(int)StoryLayer.Pass].Count; i++) { Event e = storyLayerSprites[(int)StoryLayer.Pass][i]; e.Sprite.Bypass = !passingCurrent; } //Samples for (int i = 0; i < storyLayerSamples[(int)StoryLayer.Pass].Count; i++) { EventSample e = (EventSample)storyLayerSamples[(int)StoryLayer.Pass][i]; if (passingCurrent) { AudioEngine.SampleEvents.Add(e.SampleCache); } else { AudioEngine.SampleEvents.Remove(e.SampleCache); } } } firstRun = false; } if (GameBase.Mode == OsuModes.Play && Player.Loaded && breakMode != BreakMode && !InputManager.ReplayMode) { //toggles go here. are only run on switching mode. if (!breakMode) { NotificationManager.ClearMessageMassive(); //Clear any displaying messages when gameplay starts. } } BreakMode = breakMode; if (!breakMode) { BreakCurrent = null; } UpdateVideo(); UpdateDimming(); if (GameBase.SixtyFramesPerSecondFrame && showStoryboard) { LoadDynamic(false, true); } }
internal void Add(Event e) { if (e.EndTime > lastEventTime) { lastEventTime = e.EndTime; } if (e.StartTime < firstEventTime) { firstEventTime = e.StartTime; } events.Add(e); if (e.Sprite != null && storyLayerEnabled[(int)e.Layer]) { HasStoryboard = true; if (e.Layer == StoryLayer.Background) { if (backgroundEvent != null && e.Filename == backgroundEvent.Filename) { //The background has been used in the storyboard. //Remove the static background to optimise performance. backgroundUsedInStoryboard = true; } //We don't add these here because they don't have transformations yet. //If they don't have transformations, the time comparer fails. //We add them AFTER transformations have been populated. if (!spriteManagerBG.ForwardPlayOptimisations) { spriteManagerBG.Add(e.Sprite); } } else if (!spriteManagerFG.ForwardPlayOptimisations) { spriteManagerFG.Add(e.Sprite); } } if (e.Layer == StoryLayer.Fail || e.Layer == StoryLayer.Pass) { HasPassFailLayers = true; } switch (e.Type) { case EventTypes.Break: eventBreaks.Add((EventBreak)e); eventBreaks.Sort(); break; case EventTypes.Video: videoSprites.Add((pVideo)e.Sprite); break; case EventTypes.Sample: storyLayerSamples[(int)e.Layer].Add(e); EventSample es = (EventSample)e; AudioEngine.SampleEvents.Add(es.SampleCache); eventSamples.Add(es); eventSamples.Sort(); break; case EventTypes.Sprite: case EventTypes.Animation: storyLayerSprites[(int)e.Layer].Add(e); break; } }