From 318ea595cf621cabeb43882504251edbf6b888f4 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Thu, 19 Oct 2023 12:41:31 -0700 Subject: [PATCH] Update conventions.md for Entity --- .../general-development/codebase-info/conventions.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/en/general-development/codebase-info/conventions.md b/src/en/general-development/codebase-info/conventions.md index fd2e14906..8dc514cc6 100644 --- a/src/en/general-development/codebase-info/conventions.md +++ b/src/en/general-development/codebase-info/conventions.md @@ -316,10 +316,10 @@ Transform(uid).Coordinates; ### Public API Method Signature All public Entity System API Methods that deal with entities and game logic should *always* follow a very specific structure. -All relevant `EntityUid` should come first. +All relevant `Entity` and `EntityUid` should come first. +The `T?` in `Entity` stands for the component type you need from the entity. +The question mark `?` must be present at the end to mark the component type as nullable. Next, any arguments you want should come afterwards. -And finally, all the components you need from the entity or entities should come last. -The component arguments shall be nullable, and default to `null`. The first thing you should do in your method's body should then be calling `Resolve` for the entity UID and components. @@ -327,11 +327,11 @@ The first thing you should do in your method's body should then be calling `Reso Example (click to expand) ```csharp= -public void SetCount(EntityUid uid, int count, StackComponent? stack = null) +public void SetCount(Entity stack, int count) { - // This call below will set "stack" to the correct instance if it's null. + // This call below will set "Comp" to the correct instance if it's null. // If all components were resolved to an instance or were non-null, it returns true. - if(!Resolve(uid, ref stack)) + if(!Resolve(stack, ref stack.Comp)) return; // If the component wasn't found, this will log an error by default. // Logic here!