A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://medium.com/codex/rts-interlude-2-refactoring-the-event-system-unity-c-b52a2e3feae below:

RTS Interlude #2: Refactoring the event system (Unity/C#) | by Mina Pêcheux | CodeX

RTS Interlude #2: Refactoring the event system (Unity/C#)

On with our RTS project — in this interlude, we’re going to improve our event system! 3 min read

·

May 14, 2021

⬅️ Tutorial #10: Moving the camera| TOC | Tutorial #11: Adding a day-and-night cycle ➡️

📕 Get the ebook and bonus material on Gumroad!
🚀 Find the code of this tutorial series on my Github!

Several weeks ago, we implemented a simple event mechanism that allows us to better separate the systems in our game and avoid too-strict relationships. The first draft was meant to be very explicit and, because our class hierarchy was not as clearly defined as it is now, it was easier to use an intermediate struct, CustomEventData, to represent the type of data that could be sent in an event.

However, this implementation is far from ideal. In particular, if we start adding more and more data types to our events, we’ll have to remember to add fields to this CustomEventData struct and update all constructors. And differentiating between "typed" and "not-typed" events was important at first to understand the event system well, but it's a bit user-unfriendly in the long run.

Now that we’re more fluent with C# and type casting (especially thanks to our multiple glances at polymorphism and…


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4