using System;
using System.Numerics;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Graphics;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Robust.Client.Graphics
{
///
/// A viewport is an API for rendering a section of the game map centered around an eye,
/// complete with lighting, FOV and grid rendering.
///
[NotContentImplementable]
public interface IClydeViewport : IDisposable
{
///
/// A unique ID for this viewport. No other viewport with this ID can ever exist in the app lifetime.
///
long Id { get; }
///
/// The render target that is rendered to when rendering this viewport.
///
IRenderTexture RenderTarget { get; }
IRenderTexture LightRenderTarget { get; }
IEye? Eye { get; set; }
Vector2i Size { get; }
///
/// Raised when the viewport indicates that any cached rendering resources (e.g. render targets)
/// should be purged.
///
///
/// This event is raised if the viewport is disposed (manually or via finalization).
/// However, code should expect this event to be raised at any time, even if the viewport is not disposed fully.
///
event Action ClearCachedResources;
///
/// Color to clear the render target to before rendering. If null, no clearing will happen.
///
Color? ClearColor { get; set; }
///
/// On frames where Eye is null or in nullspace, whether the viewport may clear.
///
bool ClearWhenMissingEye { get; set; }
///
/// This is, effectively, a multiplier to the eye's zoom.
///
Vector2 RenderScale { get; set; }
///
/// If true, will be automatically called at the start of the frame.
///
bool AutomaticRender { get; set; }
///
/// Render the state of the world in this viewport, updating the texture inside the render target.
///
void Render();
///
/// Converts a point in the viewport's screen to world coordinates.
///
MapCoordinates LocalToWorld(Vector2 point);
///
/// Matrix equivalent of .
///
Matrix3x2 GetWorldToLocalMatrix();
///
/// Converts a point in world-space to the viewport's screen coordinates.
///
Vector2 WorldToLocal(Vector2 point);
///
/// Draw below screen-space overlays for this viewport in UI space.
///
/// The drawing handle to draw with.
/// The control rendering.
///
/// Absolute screen-space bounds to draw the control at.
/// Not relative to the current transform of .
///
public void RenderScreenOverlaysBelow(
IRenderHandle handle,
IViewportControl control,
in UIBox2i viewportBounds);
///
/// Draw above screen-space overlays for this viewport in UI space.
///
/// The drawing handle to draw with.
/// The control rendering.
///
/// Absolute screen-space bounds to draw the control at.
/// Not relative to the current transform of .
///
public void RenderScreenOverlaysAbove(
IRenderHandle handle,
IViewportControl control,
in UIBox2i viewportBounds);
}
public struct ClearCachedViewportResourcesEvent
{
///
/// The of the viewport.
///
public readonly long ViewportId;
///
/// The viewport itself. This is not available if the viewport was disposed.
///
public readonly IClydeViewport? Viewport;
internal ClearCachedViewportResourcesEvent(long viewportId, IClydeViewport? viewport)
{
ViewportId = viewportId;
Viewport = viewport;
}
}
}