Hazards¶
This component can be attached to a GameObject via Unity or added programmatically, but it requires a BoxCollider component that this component will force to be trigger.
A Hazards is considered a dangerous zone in a map and any contact with it will be handled depending on the hazard type and the specifics of what is trigger colliding with it. The vast majority of them are defined in Unity in maps, but a GlowTrigger can add its own if their electime isn't 0.0. All collision handling is done on OnTriggerEnter with some logic on LateUpdate, Update and Start.
Configuration fields¶
There are various configurations available for hazards, here are all the public fields:
type: An enum value that represents the type of the Hazards which greatly influences the logic. See the section below about the possible values and how they change in logiccenterpoint: For aSandFunnelhazard, this is the point at which HazardAction will move the player towards when they collide with the Hazard. For aWaterhazard, only the y component is used and it represents the base y coordinate used to move thewaterfloatswhen theirflagfloatsrequirements are metriverammount: The direction and magnitude per frame at which icicle platforms (created byMoth's Icicle ability) moves which includes theparentof any GroundDetectorspeed: The amount of frames it takes for aTempFirehazard to toggle its fire state (between on or off)holdspace: A y coordonate to use for temporarilly placing an entity before returning it or respawning it. It only applies for returning nonPFollowertagged entities childed to the MainManager.mapthat aren't items created from CreateItem and it also applies for player collision with aWater,HoneyorHolehazardsminwaterfloat: The minimum y coordinate that anywaterfloatscan be on when theirflagfloatsrequirements are metfreezetime: The amount of frames an active icicle platform (created fromMoth's Icicle ability) that can ellapse before the platform disappears and becomes inactive. If this is 0.0 or below, the value defaults to 1000.0, but if theFreezeTimemedal is equipped, this defaults to 2000.0. NOTE: Whether or not the medal is equipped does nothing if the value is positivenoice: If this is true, it disables the ability forMoth's Icicle ability to create icicle platforms and any attempt to create one will cause the icicle to shatterkeeplayer: If this is true, the layer of the GameObject won't be set to 0 (Default) on Start so the value set initially is keptalwaysactive: If this is true, it allows for aTempFirehazard'sspeedtimer logic to continue on Update and for aWatertype hazard to move any icicle platform logic on Update even if the game is pausediceparentedtomap: If this is true, all icicle platforms used for this hazard are childed to the MainManager.mapinstead of the attached GameObjectplayeronly: If this is true, any entity other than the player andPFollowertagged entities won't cause a reaction when colliding with the hazard. If this is false, this only happens when in aminipausefor any entity other than the playerplatformlimit: The maximum amount of icicle platforms allowed on this hazard. If the value is higher than 3, it is set to 3 on Startwaterfloats: For aWaterhazard, an array of all the GameObject whose matchingflagfloatsrequirements are met will be allowed to float over the water by having their y position continuously lerp towardscenterpoint.y clamped fromminwaterfloat. On Start, all the GameObjects in this array have their isStatic set to falseflagfloats: An array where each element corresponds to a flags slot where if it is true, it will allow the matchingwaterfloatsto have their y continously lerped towardscenterpoint.y calmped fromminwaterfloatrespawnentities: An array of entity ids whose entities's positions will be set to theirstartposwhen HazardAction happens (when the player collides with a hazard leading them to be respawned)
Hazard types¶
Here are the different hazard types and their specific logic:
Spikes: Spikey floor that can't be walked on even if the player is shielded:- The HazardAction animation when the player collides with the hazard is the
Damage0sound followed by them spinning for 0.75 seconds - Any entity other than the player colliding with the hazard will be returned, but any NPCControl will have their
freezecooldownset to 0.0 which will unfreeze them
- The HazardAction animation when the player collides with the hazard is the
SandFunnel: A funnel that sucks in from the ground- The HazardAction animation when the player collides with the hazard is the
SandFallsound followed by them spinning and moving towardscenterpointuntil the MainManager.GetDistance between the 2 is 0.5 or lower - If the entity that collides with the hazard follows someone, they will not be returned
- The HazardAction animation when the player collides with the hazard is the
Water: A body of water- On Start, MainManager.
map.lastwateris set to the attached GameObject which can control how Geizer's sprout renders - Icicle platforms are allowed to exist on this hazard when an
IceFalltagged collider collides with the hazard (only once per frame) - Any
waterfloatsGameObject whoseflagfloatsrequirement is satisfied will have their y position moved via lerps tocenterpoint.y clamped fromminwaterfloat - Any entity colliding with the hazard will instantiate a
Prefabs/Objects/WaterSplashprefab at the collider's GameObject and be destroyed in 0.75 seconds. Also, any collider taggedDelAftBtlwill have the same happen if the game isn't paused, but it will also cause the collider's GameObject to be moved offscreen at (2222.0, -99999.0, 88282.0) - The HazardAction animation when the player collides with the hazard is player y position being set to
holdspace - Any entity other than the player colliding with the hazard will be returned, but any NPCControl will have their
freezecooldownset to 0.0 which will unfreeze them
- On Start, MainManager.
Hole: A bottomless pit- On Start, MainManager.
map.ylimitis set to -150.0 meaning if the player's y position ever gets lower than this, they will be respawned. This can override the map configuration - Any entity other than the player colliding with the hazard will be returned, but any NPCControl will have their
freezecooldownset to 0.0 which will unfreeze them - The HazardAction animation when the player collides with the hazard is player y position being set to
holdspacefollowed by theFallingsound (SandFallinstead if the map isDesertSandPitArea)
- On Start, MainManager.
WalkableSpike: Spikey floor that can be walked on even if the player is shielded:- On Update, if MainManager.
player.shieldis true, the BoxCollider's center is set to offscreen at (2222.0, -99999.0, 88282.0) and if it's false, it's set to its original value from Start - The HazardAction animation when the player collides with the hazard (when they weren't shielded) is the
Damage0sound followed by them spinning for 0.75 seconds - If returning an item entity, this is the only hazard type that won't lead to the destruction of the entity's GameObject
- On Update, if MainManager.
Honey: A body of honey- On Start, MainManager.
map.lastwateris set to the attached GameObject which can control how Geizer's sprout renders - Icicle platforms are pooled, but this hazard doesn't allow them to exist
- Any entity colliding with the hazard will instantiate a
Prefabs/Objects/HoneySplashprefab at the collider's GameObject and be destroyed in 0.75 seconds - The HazardAction animation when the player collides with the hazard is player y position being set to
holdspace
- On Start, MainManager.
TempFire: A large flame where it is assumed an Animator is attached in a child GameObject- This hazard starts inactive and it will every
speedamount of frames toggle its activity between on or off (managed in Update whenalwaysactiveis true or the game is unpaused). If the hazard becomes active, the child Animator will have theStartclip played and theStopclip when inactive. The activity also changes the BoxCollider's center: it is set to its initial value from Start when active and set to offscreen at (2222.0, -99999.0, 88282.0) when inactive - The HazardAction animation when the player collides with the hazard is the
Damage0sound followed by them spinning for 0.75 seconds - If the entity that collides with the hazard follows someone, they will not be returned
- This hazard starts inactive and it will every
Other notes¶
Here are some other important details about the logic of the component:
- If the attached GameObject has the
WaterFloattag, MainManager.map.waterfloatis set to the attached GameObject which allows entities to move over it if they are allowed - On HazardAction when the player collides with the hazard, there is a failsafe where if a player respawn happens 4 times in succession each within less than 60.0 frames apart, their position will be set to MainManager.
player.lastloadzone+ MainManager.MainCameraforward vector * 0.1 * theplayerdataindex (z fighting countermeasure). Normally, the base position used is MainManager.player.lastpos - On HazardAction when the player collides with the hazard, StopForceMove is called without targetstate or smooth on the player's entity
- HazardAction contains some additional details when the player collides with the hazard:
- The hazard animation includes a MainManager.PlayTransition(0, 0, 0.2, Color.black) call at the start and a MainManager.PlayTransition(1, 0, 0.2, Color.black) call at the end, but these and most of the yield times will be skipped when in a
pause,minipause,ineventor when the message lock is held - All active NPCControl Enemy that is within 4.0 units of the player gets their
freezecooldownset to 0.0 which unfreezes them if they were - All Hornable of type
IceCubewithin 4.0 units of the player has ShatterDroppletIce called on theirparentNPCControl - All ScrewPlatform's
camchangeare reset to false and if ScrewPlatform.camischanging, MainManager.ResetCamera is called before resetting the value back to false
- The hazard animation includes a MainManager.PlayTransition(0, 0, 0.2, Color.black) call at the start and a MainManager.PlayTransition(1, 0, 0.2, Color.black) call at the end, but these and most of the yield times will be skipped when in a
- The way icicle platforms work is if one is created when there's already
platformlimitactive one, the oldest one (tracked in an internal 2 elements array) will be destroyed to leave room for the new one. They always appear at the GameObject's position who collided with the hazard. The original GameObject gets destroyed when this happens - The MainManager.
player.beemerangwon't cause a reaction when colliding with the Hazard - Some specific entities won't react to colliding with the hazard. Here are the list that will simply stay on the hazard:
- Any entity with
fixedentitytrue - Any entity with
ignorewatertrue - Any NPCControl Enemy whose entity.
heightand entity.minheightare above 0.05 except if their entity.killonfallis true where it will react on top of their entity.iskilland entity.deadbeing set to true. NOTE: All NPCControl enemies will have their entity.emoticoncooldownwill still be reset to 0.0 when colliding, but no further reaction will happen if it doesn't fall within the entity.killonfallcase - NPCControl object of type BeetleGrass
- NPCControl object of type Item
- NPCControl object of type Beemerang (wouldn't cause a reaction anyway as mentioned above)
- NPCControl object of type JumpSpring
- NPCControl object of type Switch
- NPCControl object of type PathPlatform
- NPCControl object of type Geizer
- NPCControl object of type RollingRock
- Any entity with