Hello world. Been a few weeks. I've been exhausted. I got a new promotion at work along with a move to a new apartment. I have begun worrying about work life balance, and the last thing I want to do when I get home is work on my game.
But fear not, I have been dabbling and I've solved the issue I was working on. Specifically, how to handle current orders. The orders don't execute until the next day, and there's just so many things to handle. What if I want to cancel the order? How do I keep all the text in line with each other? How do I dynamically spawn a little red cancel button to cancel the order? How do I keep the button in line with the text? How do I remove the button and text from the screen when I execute the order on a different screen? What if I try to execute a market order when there are no contracts on the market?
Alot of this I solved by learning the Invoke() method. If I tie all the cancelling to the button, I can actually execute those listeners in my code in other places with just the invoke method. It basically pushes the button. So after I've resolved the market order, just invoke the cancel button and it cleans up the current orders list and removes the button from the UI screen. Pretty cool stuff. I also figured out how to add event listeners to the button and also can dynamically remove them for garbage collection. So, it's alot to take in, but it's super important for later stuff.
What gave me this idea was a youtuber named CodeMonkey. He has some awesome videos, and they're perfect for me since he makes management sims as well. He also has some utilities I want to use, like how error messages pop up next to the cursor as floating text, and his utilities can do it in one line of code. Definitely going to be combing through his videos.
So what's next? I just linked the market orders to the market and tested them. So now I have immediate contracts coming through for companies the player owns, but none of that is displayed. It's time to rework the company info screen to show employees hired, contracts we own, how long the contracts are for and what price the goods are for, our current inventory levels and cash on hand, and other stats we want to know as a company. This screen will lead to the company hierarchy screen, which we need to go over and polish again. I'll probably rip out all the code for the dual objects that I had before, and just have one object representing the employees. Before, I would have a "holder" that would snap a "employee card" to it and would detect if it was removed and adjust the tree if it did. Instead, we're just going to have sticky notes and let the player drag "string" to each sticky note and rearrange the tree however they want. When you mouse over a sticky note for a second or so, it'll display a manilla folder with a bunch of info on the employee. I think this system will be much better than what I have.
As for generics, before I had different market screens for jobs and goods. Now we have service contracts we have to worry about as well. But I want to build my code so that it can handle whatever I throw at it. I want market orders to be jobs, goods, or services. So how to do this? I think Generics is the way to go. I haven't researched generics as much, but it is something I need to learn to do, and I think this will be a great way to handle it. Besides, who knows what else I want to do in the future. I can't really think of anything I want to show off in markets, but maybe something else will come up?
So that's the road forward, as much time as I can allow. Without unpacking anymore, I'll have more time to work on the game. Get the company info screen back up and running to display company stats, polish up the ol' hierarchy tree, and get market screens working with generics. That sounds like a month or two of work. Looking forward to it!