Files
GS13NG/datum/component/virtual_reality.html
2025-02-05 06:19:18 +00:00

31 lines
11 KiB
HTML

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/component/virtual_reality - /tg/ Station 13</title></head><body><header><a href="index.html">/tg/ Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a><a href="datum/component/virtual_reality.html#proc">Proc Details</a></header><main><h1>virtual_reality <aside>/<a href="datum.html">datum</a>/<a href="datum/component.html">component</a>/<a href="datum/component/virtual_reality.html">virtual_reality</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L9"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 9"></a></h1><p>The virtual reality turned component.
Originally created to overcome issues of mob polymorphing locking the player inside virtual reality
and allow for a more &quot;immersive&quot; virtual reality in a virtual reality experience.
It relies on comically complex order of logic, expect things to break if procs such as mind/transfer_to() are revamped.
In short, a barebone not so hardcoded VR framework.
If you plan to add more devices that make use of this component, remember to isolate their code outta here where possible.</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/PostTransfer">PostTransfer</a></th><td>Required for the component to be transferable from mob to mob.</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/action_trigger">action_trigger</a></th><td>The following procs simply acts as hooks for quit(), since components do not use callbacks anymore</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/connect">connect</a></th><td>Called when attempting to connect a mob to a virtual reality mob.
This will return FALSE if the mob is without player or dead. TRUE otherwise</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/on_player_transfer">on_player_transfer</a></th><td>Takes care of moving the component from a mob to another when their mind or ckey is transferred.
The very reason this component even exists (else one would be stuck playing as a monky if monkyified)</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/player_hijacked">player_hijacked</a></th><td>Called when someone or something else is somewhat about to replace the mastermind's mob key somehow.
And potentially lock the player in a broken virtual reality plot. Not really something to be proud of.</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/pre_player_transfer">pre_player_transfer</a></th><td>Called to stop the player mind from being transferred should the new mob happen to be one of our masterminds'.
Since the target's mind.current is going to be null'd in the mind transfer process,
This has to be done in a different signal proc than on_player_transfer(), by then the mastermind.current will be null.</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/quit">quit</a></th><td>Takes care of deleting itself, moving the player back to the mastermind's current and queueing the parent for deletion.
It supports nested virtual realities by recursively calling vr_in_a_vr(), which in turns calls quit(),
up to the deepest level, where the ckey will be transferred back to our mastermind's mob instead.
The above operation is skipped when session_paused is TRUE (ergo no player in control of the current mob).
vars:</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/switch_player">switch_player</a></th><td>Called when the mastermind mind is transferred to another mob.
This is pretty much just going to simply quit the session until machineries support polymorphed occupants etcetera.</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/vr_in_a_vr">vr_in_a_vr</a></th><td>Used for recursive virtual realities shenanigeans and should be called by the above proc.</td></tr><tr><th><a href="datum/component/virtual_reality.html#proc/you_only_live_once">you_only_live_once</a></th><td>emag_act() hook. Makes the game deadlier, killing the mastermind mob too should the parent die.</td></tr></table><h2 id="proc">Proc Details</h2><h3 id="proc/PostTransfer"><aside class="parent"><a title="/datum/component" href="datum/component.html#proc/PostTransfer"></a></aside>PostTransfer<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L172"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 172"></a></aside></h3><p>Required for the component to be transferable from mob to mob.</p><h3 id="proc/action_trigger"><aside class="declaration">proc </aside>action_trigger<aside>(/<a href="datum.html">datum</a>/<a href="datum/action.html">action</a>/source, /<a href="obj.html">obj</a>/target) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L179"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 179"></a></aside></h3><p>The following procs simply acts as hooks for quit(), since components do not use callbacks anymore</p><h3 id="proc/connect"><aside class="declaration">proc </aside>connect<aside>(/<a href="mob.html">mob</a>/M) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L79"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 79"></a></aside></h3><p>Called when attempting to connect a mob to a virtual reality mob.
This will return FALSE if the mob is without player or dead. TRUE otherwise</p><h3 id="proc/on_player_transfer"><aside class="declaration">proc </aside>on_player_transfer<aside>(/<a href="datum.html">datum</a>/source, /<a href="mob.html">mob</a>/new_mob, /<a href="mob.html">mob</a>/old_mob) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L166"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 166"></a></aside></h3><p>Takes care of moving the component from a mob to another when their mind or ckey is transferred.
The very reason this component even exists (else one would be stuck playing as a monky if monkyified)</p><h3 id="proc/player_hijacked"><aside class="declaration">proc </aside>player_hijacked<aside>(/<a href="datum.html">datum</a>/source, /<a href="mob.html">mob</a>/our_character, /<a href="mob.html">mob</a>/their_character) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L146"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 146"></a></aside></h3><p>Called when someone or something else is somewhat about to replace the mastermind's mob key somehow.
And potentially lock the player in a broken virtual reality plot. Not really something to be proud of.</p><h3 id="proc/pre_player_transfer"><aside class="declaration">proc </aside>pre_player_transfer<aside>(/<a href="datum.html">datum</a>/source, /<a href="mob.html">mob</a>/new_mob, /<a href="mob.html">mob</a>/old_mob) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L127"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 127"></a></aside></h3><p>Called to stop the player mind from being transferred should the new mob happen to be one of our masterminds'.
Since the target's mind.current is going to be null'd in the mind transfer process,
This has to be done in a different signal proc than on_player_transfer(), by then the mastermind.current will be null.</p><h3 id="proc/quit"><aside class="declaration">proc </aside>quit<aside>(deathcheck, cleanup, /<a href="mob.html">mob</a>/override) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L208"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 208"></a></aside></h3><p>Takes care of deleting itself, moving the player back to the mastermind's current and queueing the parent for deletion.
It supports nested virtual realities by recursively calling vr_in_a_vr(), which in turns calls quit(),
up to the deepest level, where the ckey will be transferred back to our mastermind's mob instead.
The above operation is skipped when session_paused is TRUE (ergo no player in control of the current mob).
vars:</p>
<ul>
<li>deathcheck is used to kill the master, you want this FALSE unless for stuff that doesn't involve emagging.</li>
<li>cleanup is used to queue the parent for the next vr_clean_master's run, where they'll be deleted should they be dead.</li>
<li>mob/override is used for the recursive virtual reality explained above and shouldn't be used outside of vr_in_a_vr().</li>
</ul><h3 id="proc/switch_player"><aside class="declaration">proc </aside>switch_player<aside>(/<a href="datum.html">datum</a>/source, /<a href="mob.html">mob</a>/new_mob, /<a href="mob.html">mob</a>/old_mob) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L110"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 110"></a></aside></h3><p>Called when the mastermind mind is transferred to another mob.
This is pretty much just going to simply quit the session until machineries support polymorphed occupants etcetera.</p><h3 id="proc/vr_in_a_vr"><aside class="declaration">proc </aside>vr_in_a_vr<aside>(/<a href="mob.html">mob</a>/player, deathcheck, lethal_cleanup) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L242"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 242"></a></aside></h3><p>Used for recursive virtual realities shenanigeans and should be called by the above proc.</p><h3 id="proc/you_only_live_once"><aside class="declaration">proc </aside>you_only_live_once<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/datums/components/virtual_reality.dm#L100"><img src="git.png" width="16" height="16" title="code/datums/components/virtual_reality.dm 100"></a></aside></h3><p>emag_act() hook. Makes the game deadlier, killing the mastermind mob too should the parent die.</p></main><footer>tgstation.dme <a href="https://github.com/evilew/GS13-Citadel/tree/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e">e8e0068</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.9.0</a></footer></body></html>