From 496ea34a9b3d60c6dceae2c1dc096e6ea19d63db Mon Sep 17 00:00:00 2001
From: thepaperpilot <thepaperpilot@gmail.com>
Date: Sun, 13 Mar 2022 18:55:47 -0500
Subject: [PATCH] Enabled using the BaseLayer features while creating the layer

---
 src/game/layers.tsx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/game/layers.tsx b/src/game/layers.tsx
index 0698c0a..2a7bc45 100644
--- a/src/game/layers.tsx
+++ b/src/game/layers.tsx
@@ -89,15 +89,19 @@ export type GenericLayer = Replace<
     }
 >;
 
-export function createLayer<T extends LayerOptions>(optionsFunc: () => T): Layer<T> {
+export function createLayer<T extends LayerOptions>(
+    optionsFunc: (() => T) & ThisType<BaseLayer>
+): Layer<T> {
     return createLazyProxy(() => {
-        const layer = optionsFunc() as T & Partial<BaseLayer>;
+        const layer = {} as T & Partial<BaseLayer>;
         const emitter = (layer.emitter = createNanoEvents<LayerEvents>());
         layer.on = emitter.on.bind(emitter);
         layer.emit = emitter.emit.bind(emitter);
 
         layer.minimized = persistent(false);
 
+        Object.assign(layer, optionsFunc.call(layer));
+
         processComputable(layer as T, "color");
         processComputable(layer as T, "display");
         processComputable(layer as T, "name");