Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A view is a controller for an user interface, it sets the parameters, controls buttons, etc. A view's existence is never known by systems.
If we need to network a view, we can either use a direct call on a system or use network messages. Do not use the event bus's events for that.
Always add the postfix "View" in the name of the class for your views.
Programming Definitions & Important notes
Always ask the lead programmer if you're in doubt.
Remember, we gotta network stuff.
Use _variableName for private variables.
Use VariableName for public, const and static variables.
Never use underscores.
Never use abbreviated variables, except (if any missing or you'd like to suggest one please contact the lead programmer): i, j, rb, ui, gui, id, x, y, z, args, config.
Avoid singletons at all costs.
Avoid numbers in variables.
Always unsubscribe from events.
Document everything you can, the idea is: anyone with beginner understanding of code should read and understand the code, knowledge is everything and we got to provide that to newcomers and instruct them. This is the way.
Don't leave Debug.Logs, and always remove unused commented code.
Do not touch other people's code, if you're not directly working with it.
An Action is an event that depends on an object to exist.
The Action event should be used when we don't need something to be accessed globally, like a button being pressed, or when we need to listen from something from a specific object.
Let's imagine you have a granade in your character's hand. Pretty common sight in a Low RP server. In the code, usually we would have something like:
The OnPinRemoved event will be used to to tell listeners that subscribed to that granade's event that the granade's pin was removed. The relevance of that OnPinRemoved event is usually for UI related purposes, or running a local animation of a granade pin flying through your screen.
Something like:
You might even think it would be easier to call it directly, and depending on your logic it might be, but we are assuming that in this case its better to keep the classes decoupled.
This refers to a technical concept, not as a generic "container system" or a "interactions system"
A system is a class that manages something, it should work on its own, the only exception is when it needs information about other system, but it is preferable that you do that by using events or event buses or network messages.
A system can be networked or not, for that you can inherit your class from System or NetworkSystem.
Here's a snipped of now you can declare a system that creates explosion somewhere.
It is also important that you know all the systems work with the SystemLocator class
Always add the postfix "System" in the name of the class for your systems.
Class used to get game systems, using generics and then making cache of said systems.
The SystemLocator is a class used to easily find any system that has been registered on it.
It helps us avoid falling into the Singleton pattern, and does something similar to the Service Locator pattern. Also good for performance reasons, It can handle over a million calls every frame with no issues.
To register a new system you can call the SystemLocator.Register(this) method, it'll add that system into a dictionary of systems, preventing two of the same system from existing.
Then you can get this system from somewhere else using SystemLocator.Get<T>()
Note that is done automatically by classes inheriting System and NetworkedSystem. They register on Awake:
The event bus is a design pattern, it serves the purpose of a "global event system" as it can be invoked from anyone, anywhere and can be listened by anyone, anywhere.
The implementation we use was created by the CS Framework and we use it to create new event buses. To understand further on the design pattern itself, you can read this article.
We use these events when we want something that will be used in more than one place, without having to care about object relation.
We usually want events to be fired by systems when we want to inform other objects something has happened, like a round timer being updated, a player that spawned, an object that was picked up.
Pretty straight-forward isn't it? Well, now for the usage.