Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
WrappedDrawable.cs
1using System.Drawing;
5
6namespace Gondwana.Drawing;
7
8// A render instance, never a clone of the tile, sprite, drawing, or widget.
9internal sealed class WrappedDrawable(IDrawable owner, SceneLayer layer, PointF offset) : IDrawable
10{
11 internal IDrawable Owner { get; } = owner;
12 internal SceneLayer Layer { get; } = layer;
13 internal PointF Offset { get; } = offset;
17 public Guid Id => Owner.Id;
21 public string? Nickname => Owner.Nickname;
25 public bool Visible => Owner.Visible;
29 public int ZOrder => Owner.ZOrder;
35 public RectangleF GetDrawLocationScreen(View view)
36 {
37 using var scope = Enter(view);
38 return Owner.GetDrawLocationScreen(view);
39 }
45 public void Draw(BackbufferBase backbuffer, RectangleF destRectScreen) => Owner.Draw(backbuffer, destRectScreen);
46
47 [ThreadStatic] private static WrappedDrawable? _current;
48 [ThreadStatic] private static View? _view;
49 internal static PointF ScreenOffset(View view, SceneLayer layer)
50 {
51 if (_current is null || !ReferenceEquals(_view, view) || !ReferenceEquals(_current.Layer, layer))
52 return PointF.Empty;
53 float zoom = Gondwana.Rendering.RenderContext.Current?.ViewportZoom ?? view.Viewport.Zoom;
54 return new(_current.Offset.X * zoom, _current.Offset.Y * zoom);
55 }
56 internal IDisposable Enter(View view) => new Scope(this, view);
57 private sealed class Scope : IDisposable
58 {
59 private readonly WrappedDrawable? _prior = _current;
60 private readonly View? _priorView = _view;
61 internal Scope(WrappedDrawable instance, View view) { _current = instance; _view = view; }
65 public void Dispose() { _current = _prior; _view = _priorView; }
66 }
67}
Viewport Viewport
Gets the viewport that defines the screen-space rectangle, zoom level, and other rendering parameters...
Definition View.cs:44
float Zoom
Zoom factor applied to the world when rendering this view. Values greater than 1 zoom in,...
Definition Viewport.cs:67
Represents an object that can be drawn on a visual surface, with properties for visibility and stacki...
Definition IDrawable.cs:14
@ SceneLayer
Performs direct drawing within a scene layer using world-space coordinates.
@ View
Displays camera position, viewport zoom, and viewport dimensions.