/// <inheritdoc/> public override void OnAdded(IScreenObject host) { if (_screen != null) { throw new Exception("Component has already been added to a host."); } if (!(host is IScreenSurface surface)) { throw new ArgumentException($"Must add this component to a type that implements {nameof(IScreenSurface)}"); } if (RenderStep != null) { surface.RenderSteps.Remove(RenderStep); RenderStep.Dispose(); } RenderStep = GameHost.Instance.GetRendererStep(Renderers.Constants.RenderStepNames.EntityRenderer); RenderStep.SetData(this); surface.RenderSteps.Add(RenderStep); _screen = surface; _isAttached = true; UpdateCachedVisibilityArea(); }
/// <inheritdoc/> public override void OnRemoved(IScreenObject host) { ((IScreenSurface)host).RenderSteps.Remove(RenderStep); RenderStep?.Dispose(); RenderStep = null; _screen = null; _screenCachedFont = null; _screenCachedFontSize = Point.None; _screenCachedView = Rectangle.Empty; _isAttached = false; }