Rendering components¶
These components deals with rendering, visual effects and rendering animations.
LightSorter¶
A component meant to be attached on any GameObject via Unity.
It will call MainManager.SortLights on every 2 LateUpdate using all child MeshRenderer of the GameObject.
PulsingLight¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has a Light component (it will be collected on the component's Start).
It will on every LateUpdate set the Light's range value to be basevalue + Sin(Time.time * speed) * ammount. The basevalue, speed and ammount values are configurable via the inspector.
MaterialColor¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has a Renderer component (it will be collected on the component's Start).
It will set on its Start the Renderer's component's materials[materialid].color to color. Both materialid and color fields are configurable via the inspector. If the settag value is set to true in the inspector, Start will also cause the GameObject tag to be set to NoMapColor which will not cause changes to the material's color when entering an inside.
InsideSorter¶
A component meant to be attached on any GameObject via Unity.
It will cause on LateUpdate whenever instance.insideid changes to another value to change the enablement of the child value which is a GameObject. If the new instance.insideid becomes this component's insideid, the child gets enabled and if not, it gets disabled. This enablement logic can be reversed if the invert field is true (so enabled when NOT the inside, disabled if it is). The child, insideid and invert fields are all configurable via the inspector.
Intuitively, it allows to control the enablement of any other GameObject according to being in a specific inside or NOT being in that inside.
RenderQueue¶
A component meant to be attached on any GameObject via Unity, but it requires a Renderer component on the GameObject to function.
It will cause all the materials of the Renderer component (or all the ones whose index is in materials if it's not empty) to have their renderQueue set to queue 0.1 seconds after Start, then it the component will disable itself. The materials and queue fields are configurable via the inspector.
ShadowLite¶
A component meant to be programmatically added to an existing GameObject and have the SetUp method called immediately upon attaching it:
public void SetUp(float opacity, float size)
The shadowsize field gets set to the size parameter and the shadowammount gets set to the opacity parameter.
This component manages the SpriteRenderer of a newly created GameObject called shadow childed to the GameObject of the component using the MainManager.shadowsprite sprite with a pure white color (using shadowammount as the opacity).
it essentially acts as a minimal version of the EntityControl's shadow functionality. As long as the SpriteRender is visible, its position, scale and angles changes every LateUpdate accoriding to a Raycast test from the GameObject position + 1.0 in y heading down. The shadow will look at the normal, be position at the point of the raycast hit and be scaled according to the y of the point (the scale is multiplied by shadowsize).
CheckOutline¶
A component meant to be attached anywhere since it operates on all MeshRenderer components in the scene.
On its Start, all materials of all MeshRenderer on the scene using the MainManager.outlinemain.shader as their shader will have the following happen to them:
- material color set to pure black
_Outlinefloat property set tobaseoutline* 2.0 unless they are childed to themainmeshwhere it's set to the material's GameObject's scale magnitude / 2.0 *baseoutline
Additionally, if this is running in the Unity editor, pressing the 0 key will manually call the Start method.
Both the mainmesh field GameObject and the baseoutline float are configurable via the inspector.
FaceCamera¶
A component meant to be attached on any GameObject via Unity or attached programmatically to any GameObject.
On FixedUpdate, the angles of the GameObject will change using the following logic on every FixedUpdate to make it face the game camera:
- If
angleis false, the change depends on the value ofbillboard:- If it's true, the GameObject will LookAt the MainManager.MainCamera
- If it's false, the GameObject's y angles is set to the MainCam's y angles +
offset
- If
angleis true, it leverages a GameObject that was created on Start childed to the attached GameObject reffered to as therotater:rotaterwill LookAt the MainManager.MainCamera (this will implicitly change the GameObject's angles)- The GameObject's local xz scales of the GameObject gets inverted compared to the values it had on Start (causes the GameObject to face the opposite direction so away from the camera)
- The GameObject's y angles is set to the MainCam's y angles +
offset
The offset, angle and billboard fields are all public and configurable via the inspector.
MeshMerger¶
A component meant to be attached on any GameObject via Unity.
On Start, it will merge all the meshes MeshRenderer such that meshes[0] will be recreated with its materials being the same, but have all the other meshes elements combined into it. After, the angles of the GameObject will be set to rotatefix Vector3 and if hasCollider is true, a MeshCollider will be added where the hasCollider will be the merged mesh. This is an optimisation where less separate meshes will be rendered as all meshes will get destroyed before the merge and the recreation of meshes[0].
The meshes, rotatefix and hasCollider fields are all configurable via the inspector.
Hidder¶
A component meant to be attached on any GameObject via Unity.
On Start, all of the Renderer components in all the childs of the objs GameObject arrays are collected.
On every 2 LateUpdate where MainManager.player exists (not loading a map), the enablement of all the collected renders changes depending on if MainManager.player xz positions fufills a condition expressed by the hidepos float field and the left field (it's a Directions enum, but only the values Right, Left, Up and Down are valid). The objs, hidepos and left fields are configurable via the inspector. This enablement change only happens if the xz position check actually changes (goes from true to false or vice versa).
It's essentially an optimisation where Renderers may be hidden when the player gets too far away to see them, but they will reappear when the player gets close enough again. Here are the exact conditions evaluated depending on the left values which can be intuitively thought as tripwire position checks (the condition being true means that the renderers gets enabled, disabled otherwise):
Left:hideposis less than the MainManager.playerx position (it's located leftward)Right:hideposis more than the MainManager.playerx position (it's located rightward)Up:hideposis more than the MainManager.playerz position (it's located towards the back of the map)Down:hideposis less than the MainManager.playerz position (it's located towards the front of the map)
NOTE: This component doesn't ensure that each Renderer isn't null while it's possible one becomes null or gets destroyed after the component's Start so it won't be reflected and it can lead to a NullReferenceException.
GlowingAura¶
A component meant to be attached on any GameObject via Unity. If the component doesn't have a FaceCamera component, one will be added on Start.
This components operates on all the halos SpriteRenderer (if it's empty, it's set to all the child SpriteRenderers) where the first, second and third gets different changes to them on every FixedUpdate. Here's the details:
- The first gets its z angle increased by
speed - The second gets its z angle decreased by
speed - The third gets Rotate called with (
speed,speed/ 1.5,speed/ 2.0)
On top of the above, if alphavariation is above 0.0, every halos gets their color set to color with an alpha set to a lerp from the existing one to alphavariation with a factor of the absolute value of Mathf.Sin(speed * Time.time) * frequency.
The halos, speed, alphavariation, color and frequency fields are all configurable via the inspector.
RandomPosTime¶
A component meant to be attached on any GameObject via Unity.
Every frametime amount of frames including the first frame on Update (or a random amount of frames between half of frametime and frametime if randomizedtime is true), the GameObject position changes to be its position it had on Start + a random vector where each component is between - (size / 2.0) and size / 2.0. If checkground is true, the position is instead set to the hit point of a Raycast starting from that position heading down for 50.0 units. Optionally, if the Animator animatorpart isn't null, the animname AnimationClip name is played on it on top of that.
The frametime, randomizedtime, size, checkground, animatorpart, and animname fields are all configurable via the inspector.
ElecThing¶
A component specifically used to perform some visual effects on the LineRenderer of 2 GameObjects in the GiantLairFridgeOutside map to simulate electricity looking lines.
Informations about the LineRenderer is collected on Start and the visual effect is performed on each LateUpdate.
CamChange¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has a BoxCollider component (it is enforced by a RequireComponent attribute).
It will change the instance.camoffset, instance.camangleoffset and instance.camspeed to this component's offset, angle and speed fields respectively when OnTriggerEnter happens with the MainManager.player. The camera fields are restored to their original value when OnTriggerExit happens with the MainManager.player. For more information on the camera fields, check the camera system documentation.
The offset, angle and speed fields are all configurable via the inspector. It is essentially a simpler and external version of the CameraChange Object that doesn't require a map entity to operate.
LightFlicker¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has a Light component (it is collected on its Start).
This component will periodically change the Light's intensity on Update, but there is a cooldown period and complex logic involving several configuration fields set via the inspector to simulate a light periodically flickering at random intervals. Here's a breakdown of how this works:
- There's a cooldown expressed in amount of frames that on Start and when it expires (decreased on every Update), its value will be set to
frequency+ a random value between -randomandrandom - The cooldown above changes the logic depending if it's expired or not:
- If it's not expired, every
framecountframes, the Light's intensity is set to a lerp from the existing one to the value it had on Start with a factor ofspeed* MainManager.framestep - If it is expired and it's one of the first
durationframes of it expiring, the Light's intensity is set to a lerp from the existing one totargetintensitywith a factor ofspeed* MainManager.framestep - If it is expired and it's been more than
durationframes of it expiring, the new value of the cooldown is set using the formula mentioned above. However, there is afastflickerpercentchance that the value gets divided byfastdividerbefore setting the final cooldown value which will make it lower. This fast flicker can't happen on 2 cycles in a row
- If it's not expired, every
VenusBattle¶
A component meant to be programmatically added to an existing GameObject and have the SetUp method called immediately upon attaching it:
public void SetUp(EntityControl parent, EntityControl targetentity)
It's a component that implements specific battle related logic where 2 entities needs to have their animation synchronised. All the logic happens in LateUpdate as long as parent and targetentity aren't null and targetentity.overrideanim is false.
It only has logic for the following targetentity.animid which won't be detailed for the sake of brevity:
- Venus
- SandWyrmTail
- SandWyrm
DialogueAnim¶
A component meant to be programmatically added to an existing GameObject and have the SetUp method called immediately upon attaching it:
public void SetUp(Vector3 tpos, float spd)
public void SetUp(Vector3 tsize, Vector3 tpos, float spd)
public void SetUp(Vector3 startsize, Vector3 tsize, Vector3 tpos, float spd)
The method sets the following fields (any not sent fields aren't set, but the tsize value defaults to Vector3.zero):
speedis set to thespdvaluetargetscaleis set to thetsizevaluetargetposis set to thetposvalue- The
startsizesets the GameObject's scale
It's a general purpose component that allows any GameObject to gain smooth scaling animations combined with optional local movement animation. It does the following on FixedUpdate of various kinds. All of its fields are public and on top of the ones mentioned above, it's possible to configure this component further by setting other fields.
Here's what the component does on FixedUpdate:
- The local scale is changed according to the configuration using a lerp from the existing one with a facctor of
shrinkspeed, but the destination depends on the configuration:- If
flipxis true, the value is (0.0, existing y scale *multiplier, 1.0) - Otherwise, if
flipyis true, the value is (existing x scale *multiplier, 0.0, 1.0) - Otherwise, if
shrinkis true, the value is Vector3.zero - Otherwise, the value is
targetscale*multiplier
- If
- If
targetposisn't Vector3.zero, the GameObject's local position is set to a lerp from the existing one totargetposwith a factor ofspeed
SpriteParticleCaller¶
A component meant to be attached on any GameObject via Unity.
All the logic are contained in LateUpdate where as soon as a specific map entity's sprite (or a specific Renderer) becomes a specific sprite, some particle effects will be played (instantiated if they don't exist) close to the GameObject. This is all configurable via fields in the inspector:
position: The position (or local position ifrelativepositionis true) of the particles that will play when the watched Renderer's sprite becomestargetspriterenderer: The specific Renderer to watch for its sprite becomingtargetsprite. If it's null, it will use MainManager.map.entities[mapentityid].spriteinsteadmapentityid: If Renderer is null, this is the map entity id whosespritewill be watched for becomingtargetspritetargetsprite: The sprite to watch the Renderer to become. When the Renderer's sprite becomes this one, the particles will playparticleprefab: The prefab of the particles to play, it needs to contain a ParticleSystem at its root for particles to playtimer: If above -1.0 or above, the particles gets destroyed intimeramount of seconds each time they are created (it may be recreated later when it gets to null)onlyone: If this is false, it will prevent particles to be replayed after they have been instantiated so it forces them to be recreated. If it's true, it will allow the particles to replay from the start if they have been created alreadyrelativeposition: If this is true,positionrefers to the local position of the particles that will be set when they are played. If this is false, it refers to the position insteadparented: If this is true, the particles GameObject will be childed to the attached GameObject when created
The instantiated particles will always have a local scale of 1.0x. Also, when the watched sprite becomes targetsprite, the particles plays, but won't play again until the sprite changes to another before becoming targetsprite again.
Caravan¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has an Animator in a child who also have a SpriteRenderer components (they are collected on the component's Start).
This component is specific to the animation logic of the Caravan shop's snail where it implements some visual effects. Most of the logic involves if the Sleep or Idle AnimationClip should be played on the snail's animator. Additionally, it features enablement updates of the snail's sprites if the current inside changes. Both of these happens on LateUpdate.
Since the logic is complex, it won't be documented here, but the inspector configuration fields will be:
isslep: This should always be false because this component manages it itself (it has no good reason to be public)facingright: Whether the sprite's logical facing direction is to the right, it's assumed to be the left if it's falseinsideid: The map's inside id where the snail's sprite will remain enabled and disabled elsewhere. A value of -1 means being in any inside will disable it while not being in any will enable it
On MoveInside, the first Caravan's Refresh method will be called which will update the AnimationClip to play according to the isslep value. It is assumed that there will only be one Caravan component in the scene at the time.
ParticleRange¶
A component meant to be attached on any GameObject via Unity or attached programmatically, but it needs a ParticleSystem in any children of the GameObject to function.
This component continuously plays some particles (the first child ParticleSystem) as long as the MainManager.player gets close enough and stops playing when they are further away. It also features the ability to fade all child MeshRenderer from Color.Clear to a color smoothly as the MainManager.player gets in and out of range. Since the logic is complex, only the public fields will be detailed. It has a Start and LateUpdate (where most of the logic is).
Here's the details of the public fields:
radius: The max Vector3.Distance away the MainManager.playerneeds to be to remain the particles playing. Falling further away than this distance will stop the particles from playing. It also controls the fading distance in the same wayfadeframeammount: The maximum amount of frames the fading takes of therendertowardsmatcolorgetmaterialcolor: If true,matcoloris overriden to the firstrender.material.color on Startgetmeshes: If true,renderis overriden to all child MeshRenderer on Startfademesh: This field is UNUSED and does nothinginvertfademesh: If true, the fading of therenderelements is reversed and it will go towards Color.Clear away frommatcolorinstead when the MainManager.playergets in rangematcolor: The color to fade towards therenderelements's materials when the MainManager.playergets in range (the opposite happens when out of range, but both directions can be swapped ifinvertfademeshis true)render: The MeshRenderers to have their material.color fade towardsmatcoloras the MainManager.playergets in range and out of range
The range check and the playback of particles only happens every 3 LateUpdate.
RandomColor¶
A component meant to be attached on any GameObject via Unity anywhere as it doesn't manage its own GameObject, but it manages other MeshRenderer.
This component periodically changes other MeshRenderer's material.color to specific ones with multiple configuration available and optional randomness in timings or colors. All the logic is contained in LateUpdate, but since it's complex, only the public fields will be detailed:
type: An enum value that tells how to decide the colors to use for therenders:RandomFromList: Randomly selects a color from thecolorsarray whenever the color needs to be changedRainbow: Always use MainManager.RainbowColor(variant) when changing the colorInOrder: The same asRandomFromList, but without randomness so it goes from first to last repeatedly
colors: The list of colors to cycle therenderswhentypeisn'tRainbowoffcolor: When theflagcondition isn't fufilled, this is the color allrenderswill be set to (up to once ifsetoffonceis true)renders: The MeshRenderer whose material.color will get cycled by this component periodicallyflag: If this is -1, the color cycling logic always happen on LateUpdate. If it's 0 or above, it only happens when flags slotflagis true as otherwise, the color cycling is disabled and allrenders's material.color gets set tooffcolorinstead. NOTE: Any value of -2 or below are invalid and will cause an exception to be thrownspeed: This field is UNUSED and does nothingframetime: The minimum amount of frames between color cyclingvariant: This serves both as the maximum amount of frames to add toframetimeeach cycle to calculate the cooldown in frames to wait before the next color cycling. It also serves as the parameter to MainManager.RainbowColor whentypeisRainbowsetoffonce: If this is true, whenever theflagcheck fails, therenderswill have their material.color set tooffcoloronly once for the lifetime of this componentindex: The starting index - 1 value to use for whentypeisInOrder. Any starting value of -2 or below are invalid and will cause an exception to be thrown (-1 works and it means 0)
PrefabParticle¶
A component meant to be attached on any GameObject via Unity.
This component instantiates a bunch of instances of a particles prefab and manages them all together with various configuration. This component honors the particle levels settings set from the config file. The component has a Start where the instances are created and a LateUpdate where most of their management happens. The logic is complex so only the public fields will be detailed:
prefabpart: The prefab particle to instantiate up tomaxammountamount of timesmaxammount: The amount of instances of particles to created, but if the particle settings in the config file is set to LOW, this amount is halved (floored) on Startspeed: The magnitude to move the particles on each LateUpdate from their heading directionliveframes: This specifies the time in amount of LateUpdates that the particle will grow towardsmaxsize. It is random betweenliveframes/ 2.0 andliveframeseach time a cycle happenscooldown: The additional amount of frames to wait after theliveframesperiod is over when the particles will start to shrink towards Vector3.zeroshrinkspeed: The MainManager.TieFramerate parameter to use as the lerp factor when growing or shrinking the particles. The growth however is done with MainManager.TieFramerate(shrinkspeed/ 2.0) insteadlimits: The position of each particles when cycling them is random between -limitsandlimitsmaxsize: The maximum size each particles will have during theliveframesperiodchildspin: The rotation vector to use to rotate each particles on each LateUpdate. If this is Vector3.zero, no rotation happens
If the particle level in the config file is set to OFF, this component gets disabled on Start.
SpinAround¶
A component meant to be added programmatically or via Unity to a GameObject. If done programmatically, the StartUp method needs to be called:
public void StartUp(Transform spintarget, float spinfrequency, float spinspeed, float yfrequency, float yspeed, float yoffset)
It sets the following fields (explained below):
target:spintarget:sf:spinfrequencyss:spinspeedyf:yfrequencyys:yspeedoffset:yoffset
This component has all of its fields public so more can be configured on top of the method above.
It's a general purpose component to have any kinds of GameObject rotate in various ways around an axis or move around another GameObject continuously in a circle around it. It has a Start and an Update (which contains most of the logic). Since the logic is complex, only the fields will be detailed:
target: If not null, this is the GameObject the attached one will move around of. Ifgettargetis true, it is overriden to the parent of the attached GameObject on Startitself: If this isn't Vector3.zero, it will be the axis of rotation used to rotate the attached GameObject around and thetargetgets ignored unlessitselfandtargetis true where both the rotation and movement around happensgettarget: If true, thetargetfield gets overriden to the attached GameObject's parent on Startlocal: If true, the GameObject will rotate by increased its local angles byitself* MainManager.framestepinstead of calling Rotate(itself* MainManager.framestep)requiresflag: If it's not -1, flags slotrequiresflagneeds to be true for the component to do anything on Update. Any value of -2 and below are invalid and will cause an exception to be thrownsf: See below for the rotation formula, only applicable when moving aroundtargetss: See below for the rotation formula, only applicable when moving aroundtargetyf: See below for the rotation formula, only applicable when moving aroundtargetys: See below for the rotation formula, only applicable when moving aroundtargetoffset: See below for the rotation formula, only applicable when moving aroundtargetrandoms: If this isn't 0.0, the value ofsfandssare overriden to be random between -randomsandrandomson Startrandomy: If this isn't 0.0, the value ofyfandysare overriden to be random between -randomsandrandomson Start
When moving around target, this is the formula used to set the new position:
target position + a Vector3 with the following components:
- x: Sin(Time.time *
sf) *ss - y: Sin(Time.time *
yf) *ys+offset - z: (0.0 - Cos(Time.time *
sf)) *ss
PromptAnim¶
A component meant to be programmatically added to a new GameObject using the SetUp static method:
public void SetUp(int selectid, bool underlines)
The selectid is the option refered to by the text and underlines is whether or not to render a red _ under the option if selected.
This component is specific to the choicewave SetText command, check its documentation to learn more. The component has a Start that setups everything and most of the animation is done on FixedUpdate. It is what implements the visuals of the prompt choice highlight.
SpriteBounce¶
A component meant to be added programmatically or via Unity to a GameObject. If done programmatically, the SetUp method needs to be called:
public void SetUp(float freq, float spd)
freq is used to set the frequency value and spd is used to set the speed value of the component (details below).
This component is a general purpose bouncing scaling animation that simulates some form of bouncing visuals. It has a Start and a FixedUpdate where most of the logic resides. It also features many configurations available, here's all the public fields that configures it:
maxx: See the formula below when the scaling of the GameObject changeds on FixedUpdatemaxy: See the formula below when the scaling of the GameObject changeds on FixedUpdatefrequency: See the formula below when the scaling of the GameObject changeds on FixedUpdatespeed: See the formula below when the scaling of the GameObject changeds on FixedUpdateydifference: See the formula below when the scaling of the GameObject changeds on FixedUpdatebasescale: See the formula below when the scaling of the GameObject changeds on FixedUpdate. Ifstartscaleis true, the value is overriden to the GameObject's local scale on Startspritecolor: If the GameObject has a SpriteRenderer, its sprite's color will be set to this value on Startfacecamera: If true, a FaceCamera component is added to the GameObject on Startstartscale: If true, the value ofbasescaleis overriden to the GameObject's local scale on Startrequiresflag: If it's not negative, a flag slot that must be true for the GameObject's local scale to change in FixedUpdaterequiresentity: If it's not negative, a map entity id whose matchingentity.npcdata.hitneeds to be true for the GameObject's local scale to change in FixedUpdate
Each FixedUpdate that the requiresflag and requiresentity checks passes, the GameObject's local scale is set to a value using the following formula:
basescale + a Vector3 with the following components:
- x: Sin(Time.time *
speed) *frequency*maxx - y: Cos(Time.time *
speed+ydifference) *frequency*maxy - z: 0.0
There's also a public method that can be called after the fact: MessageBounce:
public void MessageBounce()
public void MessageBounce(float multiplier)
The default multiplier value of the first overload is 1.0.
It will set frequency to 0.1 * multiplier and speed to 7.0 * multiplier.
ConveyorSprite¶
A component meant to be attached on any GameObject via Unity.
This component implements a visual effect with multiple sprites are initially positioned along a path made of nodes and they each moves towards the next node until reaching it. They are created using MainManager.NewSpriteObject at each nodes childed to this GameObject using their respective sprites. This process repeats indefintely so it simulates the sprites moving along a conveyer path using lerps.
It has a Start and a LateUpdate where most of the logic happens. Here are all the public fields:
type: An enum value that dictates how thespriteswill be used when placing the nodes on Start:AlternateEach: They are ordered as they appear in thespritesarrayRandomEach: Each node is a random sprite from thespritesarray
nodes: The positions of all the nodes in Vector3 specified inspritesordersprites: The matching sprites used for each nodes, it must have the same amount of elements asnodesframespeed: The amount of frames each nodes takes to move to their next nodeparticle: When reaching the next node, all of these particles names will be played using MainManager.PlayParticle at the matchingnodesbillboard: If true, each sprite object will get a FaceCamera component on Start with abillboardfield set to true
FaderRange¶
A component meant to be attached on any GameObject via Unity, but it requires to have Renderers children to function (collected on Start).
This component will fade / unfade all of the child Renderer depending on if the MainManager.player position or the MainManager.MainCamera.WorldToViewportPoint's z falls within a range or not of the GameObject position . It also manages the renderQueue and shader of the Renderer throughout this process.
Here's all the public fields:
maxdistance: The maximum Vector3.Distance away the MainManager.playerz position or the upper bound the MainManager.MainCamera.WorldToViewportPoint's z can be from the GameObject position +pivotbefore the Renderers starts to unfademindistance: The minimum Vector3.Distance away the MainManager.playerz position or the upper bound the MainManager.MainCamera.WorldToViewportPoint's z can be from the GameObject position +pivotbefore the Renderers starts to fadefadedelay: The parameter of MainManager.TieFramerate to use as the lerp factor when fading or unfading the Renderersfadepercent: The alpha value ofcolorto use as the destination of the lerp when fading the Rendererscolor: The color to use as the destination of the lerp when unfading the Renderers and also the RGB parts of the color when fading thempivot: The offset to apply to the GameObject position before using it for the range checkinvert: If this is true, any fade becomes unfades and vice-versaplayer: If this is true, the range check is done with the MainManager.playerposition instead of MainManager.MainCamera.WorldToViewportPoint(pivot+ GameObject's position)ignorematerial: If this is true, it does 2 things:- When unfading, it always happen even if the Renderer's material.shader is MainManager.
Fade3D.shader - The shader of the Renderers won't change after the distance check in LateUpdate and the color won't be set to pure white if the alpha gets higher than 0.9
- When unfading, it always happen even if the Renderer's material.shader is MainManager.
framestep: The amount of frames between distance checks in LateUpdate
Some other details to note:
- On Start: all Renderers gets the
NoMapColorwhich will not cause changes to the material's color when entering an inside - On Start, all Renderers using the MainManager.
outlinemain.shader will have their renderQueue set to 3000 - No distance checks happens on LateUpdate if any of the following is true:
- MainManager.
playeris null (loading a map) - The Renderer's shader is MainManager.
fakelight. In which case, what happens instead is their renderQueue are set to 3000 + 100.0 * the z position of MainManager.player(or the MainManager.MainCamera.WorldToViewportPoint ifplayeris false) - The Renderer's shader isn't MainManager.
Fade3D.shader or MainManager.Main3D.shader
- MainManager.
Wind¶
A component meant to be attached on any GameObject via Unity as long as the GameObject has a TrailRenderer component (it will be collected on the component's Start).
This component implements the visual effects of having wind trails of various sizes move horizontally accross the screen. It is done by placing the GameObject on Start, it moves to the right or left until a certain point where it will stop moving. Once its trail is barely visible after stopping, Start is called again to repeat this cycle. The movement is done on FixedUpdate. On LateUpdate, the TrailRenderer's material.renderQueue is set to 5000.
Here's the public fields:
origins: The base position used for the GameObject on Start. If this is null, the GameObject position is the base insteadinsideid: The inside id the GameObject needs to be in for its TrailRenderer to remain enabled. It is disabled otherwise. This is checked on FixedUpdaterandomizer: This influences the maximum amount of FixedUpdate cycle before the GameObject will move when stopped as soon as the TrailRenderer's endWith gets to 0.5 or lower. More speicically, each time the wind is stopped, the amount is random between 60.0 * TrailRenderer's time and this valuelimit: The x position limit the GameObject can be before it stops and teleports somewhere else. If this is negative, the GameObject moves in -x, +x otherwise. There is always an implied 5.0 units of grace period where the GameObject can go 5.0 over this value in the respective directionbobammount: See the y position moving formula belowbobfrequency: See the y position moving formula belowhorizontalOffset: This specifies the range that the z position of the GameObject will be on Start on each movement cycle. The z position will beoirigins.z + (random between -horizontalOffsetandhorizontalOffset)VerticalOffset: This specifies the range that the initial y position of the GameObject will be on Start on each movement cycle. The y position will beoirigins.y + (random between -VerticalOffsetandVerticalOffset)speed: The amount of units the GameObject moves in x on each FixedUpdate that it movesowncenter: This value does nothing. It influences ifcenteris set, but that field also does nothingcenter: This value does nothing, but it may be assigned from Start to MainManager.map.centralpointif the currentmapexists (not loading one) andowncenteris false
Each FixedUpdate that the GameObject moves, the new y position is calculated using the following formula:
Starting y position since the last Start + Sin((Time.time + R) * bobammount) * bobfrequency where R is a random number between 0 and 9 that is regenerated on each Start.
StaticModelAnim¶
A component meant to be attached on any GameObject programmatically or via Unity, but the GameObject has to have a Renderer component.
This component is a general purpose bobbing and texture shifting animation. It is used for a wide variety of reasons such as animating water by texture shifting or bobbing some object periodically by moving it slightly. Most features of the component are optional.
Here's all the public fields:
speed: The direction of_MainTexshifting where the magnitude is expressed is scaled by MainManager.framestepand represents the rate of the shiftingcurrent: This act as the current shifting offset to_MainTex(it increases byspeed* MainManager.framestepevery Update). This can be set externally, but it's typically going to be Vector3.zero initiallylimitmin: The value thecurrentvalue will loop back to when it reacheslimitmax. This is calculated per component so the x and y will cycle independentlylimitmax: The maximum value thecurrentvalue can have before looping back tolimitmin. This is calculated per component so the x and y will cycle independentlybobspeed: A Vector3 that expresses the speed of the bobbing, calculated per components. If this value andbobfreqare Vector3.zero, no bobbing happensbobfreq: A Vector3 that expresses the period of the bobbing, calculated per components. If this value andbobspeedare Vector3.zero, no bobbing happensbobangle: If this isn't Vector3.zero, it changes the bobbing to bob the angles instead of the position of the GameObjectconveyor: This field isn't used by the component, but if it is set via the inspector, the game can access it. This is only used for PlayerControl to move if they are on theirconveyorand the value controls the direction of the movementnomove: If this is true, bobbing is disabled and can't happenpausetied: If this is true, it will do 2 things:- Nothing will happen on the first FixedUpdate if the game is paused
- On Update,
internaltwon't increase by MainManager.framestepif the game is paused
internaltimer: If this is true, the way angle bobbing happens (which is only applicable ifbobangleisn't Vector3.zero) changes where instead of using Time.time in the oscilation,internalt* Time.deltatime is used insteadonlyonce: If this becomes true, the GameObject gets disabled on the next LateUpdatefirstcycle: This becomes true after the first LateUpdate is done, but it is exposed to the gamestopbob: If this is true, movment bobbing is disabled and can't happen, but angle bobbing can still happen ifbobangleisn't Vector3.zerorequiresflag: This is a flag slot that needs to be true forinternaltto increase if all other conditions are satisfied. If this value is -1, no flags is requiredinternalt: Ifinternaltimeris true, this value * ime.deltatime is used instead as the base for angle oscillation rather than Time.time. On Update, if all conditions are fufilled, the value increases by MainManager.framestep
If bobfreq or bobspeed aren't Vector3.zero, the GameObject's isStatic is set to false on Start.
AnimationFunctions¶
A component meant to be attached on any GameObject via Unity.
This is a component made to hold many animation related methods meaning it doesn't really have logic on its own, but rather provides logic meant to be called by Unity's Animator using an animation event. It's meant to be attached to the GameObject where animations happens so that the methods can be called by the Animator.
The component does have a Start though that will collect the EntityControl component if getentity and model are true which is assumed to be at the grand grant parent of the GameObject. This enables some methods that requires to operate on the entity for a model entity. The getentity and model fields are configurable via the inspector.
Fader¶
A component meant to be added programmatically or via Unity to a GameObject.
This is a general purpose component meant to fade the GameObject attached when it is obstructing the camera view. The logic is too complex to detail, but the map can configure them and this is documented in the fader control section of the graphics documentation.