aboutsummaryrefslogtreecommitdiff
path: root/source/resources/types/BlockType.cs
diff options
context:
space:
mode:
authorhazel <hazel@hazelthats.me>2026-01-26 22:04:39 +0100
committerhazel <hazel@hazelthats.me>2026-01-26 22:04:39 +0100
commit567c422f8cd42eba2437f9a8c2522716a1649be7 (patch)
tree93c5b296f3b7c14b626d0aadf5cad37764c41c74 /source/resources/types/BlockType.cs
downloadcelesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.gz
celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.bz2
celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.zip
celesteia archive, last updated april 9th 2024
Signed-off-by: hazel <hazel@hazelthats.me>
Diffstat (limited to 'source/resources/types/BlockType.cs')
-rw-r--r--source/resources/types/BlockType.cs71
1 files changed, 71 insertions, 0 deletions
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