Log 3? Maybe? I've lost the order of these.
This is the first one in order, but I think it came... later??? Idk
ALright. Wow.
I def went in circles a lot today. Truley, there was a moment where it fully felt like I had gone in a complete circle. P-gross.
So, I was working on how to get the tiles to have varying responses to stimulus. Specifically, I have 3 different tiles, GRASS, SAND, and STONE. Each of them can hold only so much moisture before they have to do something with it (their 'limit'). Once they reach the limit, the GRASS and STONE will spill over, while the SAND will do nothing. And this is just one small example of how many different, similar objects are going to have many different ways of handling different things. So I was trying to figure out how to organize that, basically.
Script inheritance seems like it's not fully there? Like, idk, it didn't seem to work the same way that I remember C# Script Inheritance working. Which I think I like, but it still made it so that I didn't know what to do.
I started out by trying to do the Dict thing that I learned from the UnityPokemon tutorial. Didn't work. Could get the initializer to set callables that would look at the classes interenal vars. I suppose I could have fixed this by having the the params I need getting passed to the callable ( which is what I ended up doing, in a different way), but I didn't want to do that at the time? I'm not sure.
I looked up a whole shit ton about inheritance. Gross. It wouldn't let me override my callable vars, so I thought that you couldn't inherit and override at all. I struggled with this for a while.
Looking this up, I saw a conversation about Inheritance vs. Composition in Godot, which I remember being a huge selling point at the beginning, for me. I figured "Fuck it. I'm super stuck, I might as well just try something, even though I think it's going to get messy, and see where I get stuck (I wasn't so coherent at the time)
So I tried Node composition. I made a GardenTile, then inherited a GrassTile, a MoistureHandler node, then made a LimitHandler node under that, then made a SpreadWater tile that inherited from LimitHandler.
I, pretty much immediately, switched LimitHandler to a Resource instead of a node. Go figure. It just didn't make sense as a node? I guess I realized that I didn't need it to exist in the scene tree once I got the function out of it, and then I could store the function where I wanted it.
Then I needed to extract the callable from the SpreadWater. So I looked into overriding AGAIN, and found out you COULD override, it just had to be a func. womp womp. So I made a func in LimitHandler, overrode it in SpreadWater, and in SpreadWater, it simply returns the callable that actually spreads water. That callable will get passed up as far as it needs to go, to its final resting place.
I need to remmeber that @exports don't get set until after _init(). That caused me some confusion for a minute. Had to owait until _ready() to access this callable, that was getting yoinked from the LimitHandler resource.
So full circle. Thought about inheritance, tried composition, ran into so many problems, and each solution pushed me round in a circle until I was back at inheritance. But I guess now that I think about it, it's a bit of a hybrid of inheritance and composition? I guess that's kind of cool.
Time to sleep. For real.
Day 06 Garden Grower
First step towards a tile game
Status | Released |
Author | Conor V O'Donnell |
Leave a comment
Log in with itch.io to leave a comment.