SencilSwitch¶
A switch that, when activated, causes a frozen area range to appear or to disappear when deactivated.
Data Arrays¶
data[1]: If this isn't negative, it is a map entity id whose entity is set as this stencil switch's parent. No parent changes occurs otherwisedata[2]: If this is 1,hitis set to true on SetUp regardless of theactivationflagdata[3]: If this is 1, all colliders including the entity.modelones are disabled shortly after setup if the model is present, nothing happens otherwisevectordata[0].x: The the rate at which the radius grows and shrinks whenhitis toggled (1.0 being the game's frametime)vectordata[0].y: The radius of the rangevectordata[1]: The local position of the stencil switch ifdata[1]isn't negative
Additional data¶
activationflag: If 0 or above, a flag slot that determines the startinghitvalue and also the slot whose value will be set to this switchhitvalue when toggled.regaionalflag: If not negative, the regionalflag slot turned to true when the stencil switch is actuated for the first time
Setup¶
- entity.
rigidgets effectively fixed by placing it in kinematic mode without gravity and all constraints frozen - entity.
alwaysactiveis set to true nointeractis set to true- if the
activationflagflags slot is true,hitis also set to true. - From there some adjustements happens based on the
originalid's AnimID(nothing happens if it doesn't match any of them):SwitchCrystalandBigCrystalSwitch: A GlowTrigger is added to the entity'smodel's first child with itsparentset to this object and theglowpartsset to a single element corresponding to the MeshRender already attached to the firstmodelchild.WoodenSwitchandSteelSwitch:internaldatais initialised to a single element being -60 if it's aWoodenSwitchor -100 if it's aSteelSwitch, Then, themoveobjis set to the entity'smodelfirst child and ifhitwas set to true earlier, its angles are set to (0.0,internaldata[0], 0.0)
- If the player is present, all collision between the
boxcoland the player's wall detector are ignored. - If the
originalidis not amongBigCrystalSwitch,WoodenSwitchorSteelSwitch, AddPushder is called.
If the entity is allowed to exist according to its limit, requires and regionalflag, then some further setup happens, nothing happens otherwise.
Enabled StencilSwitch SetUp¶
- entity.
alwaysactiveis set to true - entity.
activeonpauseis set to true internaltransformis initialised to a single element being a new GameObject namedice radius fromfollowed by this entity name with a tag ofIceRadius. It gets a child added as a new instance of thePrefabs/Particles/IceRadiusprefab. After that, a trigger SphereCollider is added to it with a radius of 0.8.hitis set to true ifdata[1]is 1.- All collisions between the
boxcoland the SphereCollider addeed on theinternaltransform[0]are ignored. - If
data[1]isn't negative, the map entity whose id is this value is resolved and the following occurs:- This stencil switch gets childed to the resolved entity.
modelif it's present or the entity itself if it's not - This stencil switch position is set to the resolved entity position +
vectordata[1] - This stencil switch entity.
startposis set to its position
- This stencil switch gets childed to the resolved entity.
- If
data[3]is 1 and the entity has amodel, the collider on thatmodelif it exist gets disabled and DisableAllColliders is invoked in 0.1 seconds which disables the entity.ccol, thescol, theboxcoland thepusherif any were present internaltransform[0]gets childed to the map and its position is set to this stencil switch position
Update¶
The scale of internaltransform[0] (the ice radius) is set to a lerp from the existing one to a value that depends on the hit value of this stencil switch. If it's false, it's Vector3.zero and if it's true, it's Vector3.one * vectordata[0].y * 2.0 instead. The factor is the game's frametime * vectordata[0].x. This grows and shrinks the the radius depending on the hit value smmoothly.
The position of internaltransform[0] (the ice radius) is set to be offscreen at (0.0, -999.0, 0.0) unless hit is true which will make the position be set to this object's position instead.
If data[1] isn't negative (another map entity is the parent of this stencil switch), the local position of this object is set to vectordata[1].
MapControl.CheckStencilSwitch¶
This method specifically targets any NPCControl of this object type. It is called for any MapControl LateUpdate after the first one.
If any exists in the map where their entity isn't iskill and their hit value is true, it will select the first one. With it, 2 shaders global properties are set:
GlobalIceRadius: Half of the magnitude of theinternfaltransform[0](the ice radius object) scaleCentralIcePoint: the sencil switch position
It also sets the map's stencilid to the map entity id of the selected stencil switch which has the effect of freezing any IcePlatform in range of the stencil switch which is defined as being less than vectordata[0].y * 1.85 away from the stencil switch.
If no actuated stencil switches are found, the stencilid remains at -1 and the GlobalIceRadius shader property is set to lerp from the existing one to 0.0 with a factor of 1/20 of the game's frametime.
OnTriggerEnter¶
Nothing happens if any of the following is true:
- We are in a
pauseorminipause - message is grabbed
collisionammountis higher than 1 (this is a debounce protection)- The other gameObject tag isn't
BeetleHorn,BeetleDash,IcefallandIceclewhile it's not the playerbeemerang
The following occurs if we the above is fufilled:
collisionammountis incremented- A HitPart particle is played at this position + (0.0, 0.5, 0.0)
- All collisions between the entity.
ccoland the SphereCollider ofinternaltransform[0](the ice radius) are ignored - The
Freezesound is played at this position ifhitis false, theIceMeltone is played if it is true hitgets toggledactioncooldownis set to 30.0 (doesn't do anything)- If
hitis true, the corresponding regionalflag slot ofregionalflagwhen it isn't negative is set to true the corresponding flag slot ofactivationflagwhen it isn't negative is set to true - DeactivateOtherStencil is called which deactivates all other
StencilSwitchin the current map whose entity aren'tiskillby having theirhitset to false - If the other gameObject was the player
beemerang, itshitis set to true and theWoodHitsound is played on the entity - If the entity
originalidisn't -1 (None), SwitchSound is called indicating a press
EntityControl.OnTriggerStay¶
Due to the IceRadius tag of the ice radius object, any entities that collides with it has their inice set to true which update thier sprites and animation accordingly.