From 567c422f8cd42eba2437f9a8c2522716a1649be7 Mon Sep 17 00:00:00 2001 From: hazel Date: Mon, 26 Jan 2026 22:04:39 +0100 Subject: celesteia archive, last updated april 9th 2024 Signed-off-by: hazel --- source/resources/types/BlockType.cs | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 source/resources/types/BlockType.cs (limited to 'source/resources/types/BlockType.cs') diff --git a/source/resources/types/BlockType.cs b/source/resources/types/BlockType.cs new file mode 100644 index 0000000..d55e998 --- /dev/null +++ b/source/resources/types/BlockType.cs @@ -0,0 +1,71 @@ +using Celesteia.Graphics.Lighting; +using Celesteia.Resources.Sprites; +using MonoGame.Extended; +using MonoGame.Extended.TextureAtlases; + +namespace Celesteia.Resources.Types { + public class BlockType : IResourceType { + private byte id; + public readonly string Name; + public void SetID(byte value) => id = value; + public byte GetID() => id; + + public BlockType(string name) { + Name = name; + } + + public BlockFrames Frames = null; + public NamespacedKey? DropKey = null; + public RectangleF? BoundingBox = new RectangleF(0f, 0f, 1f, 1f); + public int Strength = 1; + public bool Translucent = false; + public BlockLightProperties Light = new BlockLightProperties(); + + + public BlockType MakeFrames(TextureAtlas atlas, int frameStart, int frameCount) { + Frames = new BlockFrames(atlas, frameStart, frameCount); + return this; + } + + public BlockType AddDrop(NamespacedKey dropKey) { + DropKey = dropKey; + return this; + } + + public BlockType SetBoundingBox(RectangleF boundingBox) { + BoundingBox = boundingBox; + return this; + } + + public BlockType SetStrength(int strength) { + Strength = strength; + return this; + } + + public BlockType SetLightProperties(BlockLightProperties properties) { + Light = properties; + if (Light == null) Light = new BlockLightProperties(); + return this; + } + + public BlockType SetTranslucent(bool translucent) { + Translucent = translucent; + return this; + } + } + + public class BlockLightProperties { + public readonly bool Emits = false; + public readonly bool Occludes = true; + public readonly int Propagation = 0; + public readonly LightColor Color = LightColor.black; + + public BlockLightProperties() {} + public BlockLightProperties(LightColor color, int propagation = 0, bool occludes = true) { + Emits = !color.Equals(LightColor.black); + Propagation = propagation; + Occludes = occludes; + Color = color; + } + } +} \ No newline at end of file -- cgit v1.2.3