7:00am - Finally slept during the night for a change. I guess that happens when you get up early two days in a row.
Anyways I'm feeling like working on the Godot Roguelike Toolkit again so I'm going to get to that.
7:23am - Well darn. I'd been looking at this method used in the RogueSharp library and I thought I was modifying it properly, but I was wrong. It looked like a method that was part of the HashSet class in C# but I kept thinking there was something off about it, and I went a while back to look it up in the code, but couldn't find it in the library, so I just shrugged and carried on thinking it was a C# hashset method.
Turns out it IS in the class I've been working on all this time. It's down at the bottom and I don't know why my search didn't find it previously. Very frustrating.
Anyways I'll have to modify all the shape functions I've written so far.
It'll be interesting to do, anyways, since there's a mix-up of pass by reference and pass by value in the languages.
In GDScript there's no operator to pass by reference. Arrays and Dictionaries are passed by reference automatically, while other types are passed by value.
The AddToHashSet method that I'm translating takes some variables as normal, but expects the Cell to be passed by reference, so that it can add the same reference to the cell to the hashset, rather than making a new hashset with new cells.
The method is also overloaded with three different versions, and GDScript doesn't do function overloading.
Here's the thing though. Because I'm not working with Hashsets but instead GDScript Arrays, I have to check the array to see if a particular cell is in there already, and I think that means the edge cases that the overloaded options cover are already covered in the method I use for testing.
Hmm... On double checking the functions I realzed that they're not adding the Cell to the Hashset, they're adding the position in a flat array to the hashset. I'm a bit confused about this.
8:00am - Yeah after analyzing it over and over I think I've figured it out. The functions that the method is used in use it to determine if the cell they're considering is already selected. So the way I've been doing it should work after all, except for certain ones where I was confused.
I'll have to fix them.
8:31am - Everything's fixed and I'm moving on to the next function. I wish I could test these as I make them but it'll have to wait until I've finished translating the class.
9:16am - Well the first copy of the Map class is done. I had to trim out some utility functions that are too different to translate or just don't make sense in GDScript, but the functionality should still be there.
Now to test it and see what happens.
9:39am - There's some sort of problem importing the class in another class. It says there's either a script error or a cyclic dependancy, and I don't see either in the Map class. So I'm not sure what's going wrong. I've tried restarting the Godot IDE but that hasn't changed anything. I'll have to go looking for help, I think, but first I need a break.
10:21am - Alright that was a break but I'm still feeling like working, so I'll see what I can do.
10:35am - Apparently it was a cyclic dependancy, since the class had a deep copy function that tried to make another Map class inside it, and GDScript doesn't allow that. Well I don't think the deep copy function is terribly neccesary in the GDScript implementation here.
Now back to testing.
11:31am - So far the tests are going well, but the get_cells_in_diamond() function isn't working properly. That is to say, it's not selecting the right cells. I'll have to check the logic on it compared to the original function. But for now I need a break again. This one will take longer so I'll end my work post here for now.
Anyways I'm feeling like working on the Godot Roguelike Toolkit again so I'm going to get to that.
7:23am - Well darn. I'd been looking at this method used in the RogueSharp library and I thought I was modifying it properly, but I was wrong. It looked like a method that was part of the HashSet class in C# but I kept thinking there was something off about it, and I went a while back to look it up in the code, but couldn't find it in the library, so I just shrugged and carried on thinking it was a C# hashset method.
Turns out it IS in the class I've been working on all this time. It's down at the bottom and I don't know why my search didn't find it previously. Very frustrating.
Anyways I'll have to modify all the shape functions I've written so far.
It'll be interesting to do, anyways, since there's a mix-up of pass by reference and pass by value in the languages.
In GDScript there's no operator to pass by reference. Arrays and Dictionaries are passed by reference automatically, while other types are passed by value.
The AddToHashSet method that I'm translating takes some variables as normal, but expects the Cell to be passed by reference, so that it can add the same reference to the cell to the hashset, rather than making a new hashset with new cells.
The method is also overloaded with three different versions, and GDScript doesn't do function overloading.
Here's the thing though. Because I'm not working with Hashsets but instead GDScript Arrays, I have to check the array to see if a particular cell is in there already, and I think that means the edge cases that the overloaded options cover are already covered in the method I use for testing.
Hmm... On double checking the functions I realzed that they're not adding the Cell to the Hashset, they're adding the position in a flat array to the hashset. I'm a bit confused about this.
8:00am - Yeah after analyzing it over and over I think I've figured it out. The functions that the method is used in use it to determine if the cell they're considering is already selected. So the way I've been doing it should work after all, except for certain ones where I was confused.
I'll have to fix them.
8:31am - Everything's fixed and I'm moving on to the next function. I wish I could test these as I make them but it'll have to wait until I've finished translating the class.
9:16am - Well the first copy of the Map class is done. I had to trim out some utility functions that are too different to translate or just don't make sense in GDScript, but the functionality should still be there.
Now to test it and see what happens.
9:39am - There's some sort of problem importing the class in another class. It says there's either a script error or a cyclic dependancy, and I don't see either in the Map class. So I'm not sure what's going wrong. I've tried restarting the Godot IDE but that hasn't changed anything. I'll have to go looking for help, I think, but first I need a break.
10:21am - Alright that was a break but I'm still feeling like working, so I'll see what I can do.
10:35am - Apparently it was a cyclic dependancy, since the class had a deep copy function that tried to make another Map class inside it, and GDScript doesn't allow that. Well I don't think the deep copy function is terribly neccesary in the GDScript implementation here.
Now back to testing.
11:31am - So far the tests are going well, but the get_cells_in_diamond() function isn't working properly. That is to say, it's not selecting the right cells. I'll have to check the logic on it compared to the original function. But for now I need a break again. This one will take longer so I'll end my work post here for now.