public void DisableShadowOnDeadState(NodeRemoveEvent evt, DeadTankNode state, [Combine, JoinByTank] TankPartRendererNode renderer) { Renderer renderer2 = renderer.baseRenderer.Renderer; renderer2.enabled = false; TankMaterialsUtil.SetAlpha(renderer2, 0f); }
public void UpdateTransparencyTransition(TimeUpdateEvent evt, TransitionRendererNode renderer) { TransparencyTransitionComponent transparencyTransition = renderer.transparencyTransition; transparencyTransition.CurrentTransitionTime += evt.DeltaTime; if (renderer.baseRenderer.Renderer) { float targetAlpha; if (transparencyTransition.CurrentTransitionTime < transparencyTransition.TransparencyTransitionTime) { targetAlpha = transparencyTransition.OriginAlpha + (transparencyTransition.AlphaSpeed * transparencyTransition.CurrentTransitionTime); } else { targetAlpha = transparencyTransition.TargetAlpha; if (transparencyTransition.TargetAlpha >= ClientGraphicsConstants.OPAQUE_ALPHA) { base.ScheduleEvent <TransparencyFinalizeEvent>(renderer.Entity); } else if (transparencyTransition.TargetAlpha <= ClientGraphicsConstants.TRANSPARENT_ALPHA) { renderer.baseRenderer.Renderer.enabled = false; } } renderer.transparencyTransition.CurrentAlpha = targetAlpha; TankMaterialsUtil.SetAlpha(renderer.baseRenderer.Renderer, targetAlpha); } }
private void StartReducing(AimingWorkActivationNode weapon, TankNode tank, ICollection <RendererNode> renderers, bool switchShader) { base.ScheduleEvent(new AddTankShaderEffectEvent(ClientGraphicsConstants.SHAFT_AIMING_EFFECT, false), tank); if (switchShader) { Shader transparentShader = tank.tankShader.TransparentShader; this.SetTransparentMode(renderers, tank, transparentShader, -1f); } if (weapon.Entity.HasComponent <ShaftAimingRendererRecoveringAlphaComponent>()) { weapon.Entity.RemoveComponent <ShaftAimingRendererRecoveringAlphaComponent>(); } float alpha = TankMaterialsUtil.GetAlpha(tank.trackRenderer.Renderer); weapon.Entity.AddComponent(new ShaftAimingRendererReducingAlphaComponent(alpha)); ShaftAimingRendererQueueMapComponent component = new ShaftAimingRendererQueueMapComponent(); foreach (RendererNode node in renderers) { foreach (Material material in node.baseRenderer.Renderer.materials) { component.QueueMap.Add(material, material.renderQueue); material.renderQueue = weapon.shaftAimingRendererEffect.TransparentRenderQueue; } } weapon.Entity.AddComponent(component); }
public void HideAndPrepareRenderer(NodeAddedEvent evt, TankPartRendererNode renderer) { Renderer renderer2 = renderer.baseRenderer.Renderer; renderer2.enabled = false; TankMaterialsUtil.SetAlpha(renderer2, ClientGraphicsConstants.OPAQUE_ALPHA); renderer.startMaterials.Materials = renderer2.materials; renderer.Entity.AddComponent <RendererInitializedComponent>(); }
public void OnInit(ChassisInitEvent e, ChassisAnimationInitNode node) { Transform root = node.tankVisualRoot.transform; ChassisAnimationComponent chassisAnimation = node.chassisAnimation; ChassisTrackControllerComponent component = new ChassisTrackControllerComponent { LeftTrack = this.ConstructController(chassisAnimation.leftTrackData, root), RightTrack = this.ConstructController(chassisAnimation.rightTrackData, root) }; chassisAnimation.TracksMaterial = TankMaterialsUtil.GetTrackMaterial(node.trackRenderer.Renderer); node.Entity.AddComponent(component); }
private bool FadeAlpha() { float clampedAlpha = 1f - Mathf.Clamp01((Time.timeSinceLevelLoad - ((this.effectStartTime + this.effectLifeTime) - this.fadeTime)) / this.fadeTime); if (clampedAlpha != this.lastAlpha) { this.lastAlpha = clampedAlpha; foreach (Material material in this.materials) { TankMaterialsUtil.SetAlpha(material, clampedAlpha); } } return(Time.timeSinceLevelLoad < (this.effectStartTime + this.effectLifeTime)); }
public void SetColoringTextureToRenderer(NodeAddedEvent evt, AssembledTankNode tank, [JoinByTank, Context] TankRendererInitializedNode tankRendererNode, [JoinByTank, Context] WeaponRendererInitializedNode weaponRendererNode) { TankMaterialsUtil.ApplyColoring(tankRendererNode.baseRenderer.Renderer, weaponRendererNode.baseRenderer.Renderer, tankRendererNode.coloring, weaponRendererNode.coloring); tankRendererNode.Entity.AddComponent <RendererPaintedComponent>(); weaponRendererNode.Entity.AddComponent <RendererPaintedComponent>(); tankRendererNode.coloring.transform.localPosition = Vector3.zero; weaponRendererNode.coloring.transform.localPosition = Vector3.zero; if (tankRendererNode.coloring.overrideEmission) { tankRendererNode.doubleArmorEffect.usualEmissionColor = tankRendererNode.coloring.emissionColor; } if (weaponRendererNode.coloring.overrideEmission) { weaponRendererNode.doubleDamageEffect.usualEmissionColor = weaponRendererNode.coloring.emissionColor; } }
public void RecoverAlpha(TimeUpdateEvent evt, AimingRecoveringNode weapon, [JoinByTank] TankNode tank, [JoinByTank] ICollection <RendererNode> renderers) { float num4; float num3 = TankMaterialsUtil.GetAlpha(tank.trackRenderer.Renderer) + (weapon.shaftAimingRendererEffect.AlphaRecoveringSpeed * evt.DeltaTime); if (num3 < ClientGraphicsConstants.OPAQUE_ALPHA) { num4 = num3; this.SetTransparentMode(renderers, tank, null, num4); } else { num4 = ClientGraphicsConstants.OPAQUE_ALPHA; this.SetTransparentMode(renderers, tank, null, num4); base.ScheduleEvent(new StopTankShaderEffectEvent(ClientGraphicsConstants.SHAFT_AIMING_EFFECT, false), tank); weapon.Entity.RemoveComponent <ShaftAimingRendererRecoveringAlphaComponent>(); } }
private void SetTransparentMode(ICollection <RendererNode> renderers, TankNode tank, Shader targetShader = null, float alpha = -1f) { foreach (RendererNode node in renderers) { if (targetShader != null) { ClientGraphicsUtil.ApplyShaderToRenderer(node.baseRenderer.Renderer, targetShader); } if ((alpha == 0f) || tank.Entity.HasComponent <TankPartIntersectedWithCameraStateComponent>()) { node.baseRenderer.Renderer.enabled = false; } else if (alpha > 0f) { TankMaterialsUtil.SetAlpha(node.baseRenderer.Renderer, alpha); node.baseRenderer.Renderer.enabled = true; } } }
public void InitSemiActiveTransition(NodeAddedEvent e, SemiActiveTankNode tank, [Combine, Context, JoinByTank] RendererNode renderer) { base.ScheduleEvent(new AddTankShaderEffectEvent(ClientGraphicsConstants.TRANSPARENCY_TRANSITION_EFFECT, false), tank); base.ScheduleEvent <TransparencyInitEvent>(renderer); TankMaterialsUtil.SetAlpha(renderer.baseRenderer.Renderer, ClientGraphicsConstants.SEMI_TRANSPARENT_ALPHA); }
private void ApplyPaint(GameObject tankInstance, GameObject weaponInstance, GameObject tankPaintInstance, GameObject weaponPaintInstance) { TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(tankInstance), TankBuilderUtil.GetWeaponRenderer(weaponInstance), tankPaintInstance.GetComponent <ColoringComponent>(), weaponPaintInstance.GetComponent <ColoringComponent>()); }
private void SetColoring(ColoringComponent coloring) { this.coloring = coloring; TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(this.hullInstance), coloring); TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetWeaponRenderer(this.weaponInstance), coloring); }
public void FinalizeTransparency(TransparencyFinalizeEvent evt, TransitionRendererNode renderer, [JoinByTank] TankShaderNode tankShader) { renderer.Entity.RemoveComponent <TransparencyTransitionComponent>(); TankMaterialsUtil.SetAlpha(renderer.baseRenderer.Renderer, ClientGraphicsConstants.OPAQUE_ALPHA); base.ScheduleEvent(new StopTankShaderEffectEvent(ClientGraphicsConstants.TRANSPARENCY_TRANSITION_EFFECT, false), tankShader); }