Jump to content

Mods.GTFO.EZ.Shared

From MindAttic Docs

GTFO.EZ.Shared

The source the GTFO.EZ family compiles in: GTFO.EZ, GTFO.EZ.AbsurdWeapons, GTFO.EZ.AbsurdMoves and GTFO.EZ.AbsurdItems. It isn't a separate DLL or package. Each mod pulls this repo in as a git submodule and compiles the files it needs straight into its own assembly, so players install nothing extra. (GTFO.CrashTestDummies used to compile in SharedOwner.cs/InfiniteToggles.cs/ MessageHelper.cs for its own Insert/Delete toggle; it dropped the feature, and this submodule with it, in its v17 - out of scope for a mod whose job is spawning test targets.)

Scope

The complete product, every feature built or still to come, is written down in SPEC.md, with each story tied to its ticket. The current finish line, and what it takes to reach it, is RELEASE.md. This library's current milestone is its last: once it is reached, the product is finished.

Files

File What it is Compiled by
SharedOwner.cs With several of the mods installed, picks the one that answers shared keys (the copy with the highest SharedOwner.ProtocolVersion, read off each loaded copy; ties go to the first installed of GTFO.EZ, GTFO.EZ.AbsurdWeapons, GTFO.EZ.AbsurdMoves, GTFO.EZ.AbsurdItems). Bump ProtocolVersion on any change to the shared code's behaviour or messages and holds state every copy must agree on once for the whole game process. A mod whose master switch ([0. Mod] Enabled) is off counts as not installed. SharedOwner.IsActive(guid) and SharedOwner.TryGetSetting<T>(...) let one mod check another. GTFO.EZ, its Absurd companions
InfiniteToggles.cs Insert / Delete: infinite health and ammo (both guns, the tool, placed sentries, grenades and other consumables; magazines topped off when it comes on) for the whole team, whoever presses it - synced through the host over GTFO-API, announced in everyone's event log and always in the console too. A client's press says "requested from the host..." until the host's broadcast confirms it "for the whole team"; no answer within 2 s means the host has no team sync and only the presser has it. Announcements name teammates whose mod is missing or on another ProtocolVersion ("except Bob"). Needs GTFO-API, RemoteEvents.cs and PlayerNames.cs. GTFO.EZ, its Absurd companions
MessageHelper.cs On-screen messages for the local player: MessageHelper.Show(text, MessageType.Warden | EventLog | Center | Subtitle, seconds). GTFO.EZ, its Absurd companions
RemoteEvents.cs RemoteEvents.Register<T>(name, handler): a GTFO-API network event whose handler can't throw (an exception escaping one would hand GTFO-API's packet to the game's own receive). Needs GTFO-API. GTFO.EZ, its Absurd companions
GameSounds.cs GameSounds.Play(event, position, logName, local): a Wwise event by name (a "2D" event only for the local player; a failing event warned once). LoopSoundSet: loops that stop shortly after they stop being touched; the mod ticks it from a MonoBehaviour of its own (Il2Cpp injects types by full name, so a shared MonoBehaviour would collide). GTFO.EZ.AbsurdMoves
HostValues.cs new HostValues(config, logName, ownSections...): Set puts the host's values (keyed "Section/Key") into the mod's shared numeric and bool settings in memory, never saved; Clear puts the player's own back. The mod's public HostLevelSettings, which GTFO.EZ finds by reflection, hands its calls here. GTFO.EZ.AbsurdMoves
ConfigDefaults.cs ConfigDefaults.Migrate(config, table, logName): after every Bind, a setting still on its old default moves to the new one once (tracked by [Internal] Config Migration Version); a value the player set is never touched. Each mod keeps only its table. GTFO.EZ.AbsurdMoves
Blast.cs The family's one grenade blast. Blast.Damage(center, innerRadius, radius, damage, edgeDamageFraction, staggerMulti, source, gearCategoryId, logName, spared): damage and stagger to every living enemy the center can see, once each through its nearest limb, with falloff, then the door locks in reach; returns the enemies hit. Its line of sight starts 0.2 m up so a low wall edge doesn't block it, but never up into a ceiling just above. Blast.Locks(center, radius, damage, source, logName): the locks alone. Blast.Show(position, logName): the bang and the trip mine's explosion effect; the mod spawns its own flash (a MonoBehaviour, so per mod). Bullet damage path, so it syncs: call Damage/Locks only on the attacker's game. Needs SharedOwner.cs and BlastFalloff.cs. none yet (GTFO.EZ.AbsurdWeapons and GTFO.EZ.AbsurdItems carry copies: GAI-T71)
BlastFalloff.cs BlastFalloff.At(distance, inner, outer, edgeFraction): full damage out to inner, then linear to edgeFraction at outer (inner 0 falls off from the center). No game types, so a mod's tests can link it. none yet
DataBlockCopy.cs DataBlockCopy.Clone(block): a new datablock with every writable instance property copied from a vanilla one, so fields the mod doesn't set start from it; DataBlockCopy.CopyObject(obj): the same for a plain data object inside a block (shared with vanilla, never edited in place). none yet (GTFO.EZ.AbsurdWeapons and GTFO.EZ.AbsurdItems carry copies: GAI-T72)
OwnPlayer.cs OwnPlayer.IsMine(Dam_PlayerDamageLocal): whether the component is your own player's, not one of the host's bots (whose components run the same Setup and Update). none yet (GTFO.EZ and GTFO.EZ.AbsurdItems carry copies)
NonNegative.cs NonNegative.Instance, a BepInEx acceptable range of 0 or more for a float setting (a typo'd minus sign or NaN lands on 0); NonNegative.Bind(config, section, key, default, description) binds with it. none yet (GTFO.EZ and GTFO.EZ.AbsurdItems carry copies)
ModdedName.cs ModdedName.Mark(name): a family mod's own item or weapon name as players see it, marked " (!)"; block names stay unmarked. No game types, so a mod's tests can link it. none yet (GTFO.EZ, GTFO.EZ.AbsurdWeapons and GTFO.EZ.AbsurdItems carry copies)
PlayerNames.cs PlayerNames.Of(SNet_Player? player, fallback) and PlayerNames.Of(ulong lookup, fallback): a player's nickname for a message, or the caller's own fallback ("a teammate", "Someone"...) when there is no player, the nickname is blank, the lookup is 0 or the game throws. InfiniteToggles.cs (GTFO.EZ, GTFO.EZ.AbsurdWeapons, GTFO.EZ.AbsurdItems and GTFO.EZ.AbsurdMoves carry their own copies: G.EZ-T184, G.AWPN-T282)

Every file is internal in namespace MindAttic.GTFO.Shared, so each mod's copy stays private to its own assembly. Copies in different mods coordinate at runtime through SharedOwner.

Using it in a mod

Each mod has this repo at external/GTFO.EZ.Shared:

git submodule add https://github.com/mindattic/GTFO.EZ.Shared.git external/GTFO.EZ.Shared

and links the files it uses into its plugin project (src/<Mod>/<Mod>.csproj):

<ItemGroup>
  <Compile Include="..\..\external\GTFO.EZ.Shared\SharedOwner.cs" Link="Shared\SharedOwner.cs" />
  <Compile Include="..\..\external\GTFO.EZ.Shared\InfiniteToggles.cs" Link="Shared\InfiniteToggles.cs" />
  <Compile Include="..\..\external\GTFO.EZ.Shared\MessageHelper.cs" Link="Shared\MessageHelper.cs" />
  <Compile Include="..\..\external\GTFO.EZ.Shared\RemoteEvents.cs" Link="Shared\RemoteEvents.cs" />
  <Compile Include="..\..\external\GTFO.EZ.Shared\PlayerNames.cs" Link="Shared\PlayerNames.cs" />
</ItemGroup>
<!-- InfiniteToggles.cs syncs over GTFO-API (installed with BepInExPack_GTFO). -->
<ItemGroup>
  <Reference Include="$(BepInEx)\plugins\GTFO-API.dll" Private="false" />
</ItemGroup>

Clone a mod with git clone --recurse-submodules, or run git submodule update --init in an existing clone.

Changing shared code

Change it here, commit and push. Then in each mod, move the submodule to the new commit (git -C external/GTFO.EZ.Shared pull origin main), rebuild, and commit the updated submodule pointer. A mod keeps building against the commit it points at until then.

Versioning

On the same vN scheme as the GTFO.EZ family (major-only bumps, no minor/patch - there's no Thunderstore package here to need the strict x.y.z form). CHANGELOG.md headers use the short vN form, same as every other GTFO.* repo. Current: v17.

Pages in this repository

From Mods.GTFO.EZ.Shared/docs/overview.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.