8000 Updating words about systems to reflect changes in the main game repo by UnrushedGibberish · Pull Request #1 · RE-SS3D/.gitbook · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updating words about systems to reflect changes in the main game repo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dev Guide/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
* [Applying attributes on all network related methods.](guidelines/the-c-style-guide/declarations/common-patterns-and-structure/applying-attributes-on-all-network-related-methods..md)
* [Code Design Definitions](guidelines/code-design/README.md)
* [Actor](guidelines/code-design/actor.md)
* [System](guidelines/code-design/system.md)
* [SubSystem](guidelines/code-design/subsystem.md)
* [View](guidelines/code-design/view.md)
* [Events](guidelines/code-design/events/README.md)
* [Event Bus](guidelines/code-design/events/event-bus.md)
* [Action](guidelines/code-design/events/action.md)
* [System Locator](guidelines/code-design/system-locator.md)
* [SubSystems Locator](guidelines/code-design/subsystem-locator.md)
* [Tweening](guidelines/code-design/tweening.md)
* [Asset Criteria](guidelines/asset-criteria/README.md)
* [External Criteria](guidelines/asset-criteria/external-criteria/README.md)
Expand Down
57 changes: 57 additions & 0 deletions Dev Guide/guidelines/code-design/subsystem-locator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
description: >-
Class used to get game subsystems, using generics and then making cache of said
subsystems.
---

# SubSystems

The <mark style="color:purple;">**SubSystems**</mark> class is used to easily find any subsystem that has been registered on it.&#x20;

It helps us avoid falling into the [Singleton pattern](https://gameprogrammingpatterns.com/singleton.html), and does something similar to the [Service Locator pattern](https://gameprogrammingpatterns.com/service-locator.html). Also good for performance reasons, It can handle over a million calls every frame with no issues.

## Using the SubSystems class

To register a new subsystem you can call the <mark style="color:purple;">**SubSystems**</mark>**.**<mark style="color:green;">**Register**</mark>**(**<mark style="color:blue;">**this**</mark>**)** method, passing in a class that extends from <mark style="color:purple;">**SubSystem**</mark> or <mark style="color:purple;">**NetworkSubSystem**</mark>, it'll add that subsystem into a dictionary of subsystems, preventing two of the same subsystem from existing.&#x20;

Then you can get this subsystem from somewhere else using <mark style="color:purple;">**SubSystems**</mark>**.**<mark style="color:green;">**Get**</mark>**<**<mark style="color:purple;">**T**</mark>**>()**

## <mark style="color:yellow;">**⚠️**</mark>** **<mark style="color:red;">**IMPORTANT!**</mark>&#x20;

Note that is done automatically by classes inheriting <mark style="color:purple;">**SubSystem**</mark> and <mark style="color:purple;">**NetworkedSubSystem**</mark>. They both register on <mark style="color:green;">**Awake**</mark> and unregister on <mark style="color:green;">**Destroy**</mark>:

<pre><code><strong>public class SubSystem : Actor
</strong> {
protected override void OnAwake()
{
base.OnAwake();
SubSystemLocator.Register(this);
}

protected override void OnDestroyed()
{
base.OnDestroyed();
SubSystemLocator.Unregister(this);
}
}
</code></pre>

## Examples

<details>

<summary>Getting the spawned players list</summary>

<mark style="color:purple;">EntitySpawnSubSystem</mark> entitySpawnSubSystem = <mark style="color:purple;">SubSystems</mark>.<mark style="color:green;">Get</mark><<mark style="color:purple;">EntitySpawnSubSystem</mark>>();&#x20;

<mark style="color:purple;">List</mark><<mark style="color:purple;">PlayerControllable</mark>> playersToAssign = entitySpawnSubSystem.<mark style="color:blue;">SpawnedPlayers</mark>;

</details>

<details>

<summary>Ending the round after detonating a nuke</summary>

_<mark style="color:blue;">// Ends the round, regardless of how many objectives were completed</mark>_ <mark style="color:purple;">SubSystems</mark>.<mark style="color:green;">Get</mark><<mark style="color:purple;">GamemodeSubSystem</mark>>().<mark style="color:green;">EndRound</mark>();

</details>
27 changes: 27 additions & 0 deletions Dev Guide/guidelines/code-design/subsystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SubSystem

{% hint style="info" %}
This refers to a technical concept, not as a generic "container subsystem" or a "interactions subsystem"
{% endhint %}

A subsystem is a <mark style="color:blue;">**class**</mark> that manages something, it should work on its own, the only exception is when it needs information about other subsystems, but it is preferable that you do that by using <mark style="color:purple;">**events**</mark>, <mark style="color:purple;">**event buses**</mark>, or [<mark style="color:purple;">**network messages**</mark>](../../networking/fishnet-networking/network-message.md).

A subsystem can be networked or not, for that you can inherit your class from <mark style="color:purple;">**SubSystem**</mark> or <mark style="color:purple;">**NetworkSubSystem**</mark>.

Here's a snipped of how you can declare a subsystem that creates an explosion somewhere.

```
public sealed class ExplosionSubSystem : NetworkSubSystem
{
public void CreateExplosionAt(Vector3 position, float size)
{
// boom.
}
}
```

It is also important that you know how all the subsystems work with the [<mark style="color:purple;">**SubSystems**</mark>](subsystem-locator.md) <mark style="color:blue;">**class**</mark>

{% hint style="warning" %}
Always add the postfix "**SubSystem**" in the name of the <mark style="color:blue;">**class**</mark> for your <mark style="color:purple;">**subsystems**</mark>.
{% endhint %}
51 changes: 0 additions & 51 deletions Dev Guide/guidelines/code-design/system-locator.md

This file was deleted.

27 changes: 0 additions & 27 deletions Dev Guide/guidelines/code-design/system.md

This file was deleted.

0