protected IEnumerator SetStateOverTime(WIState oldState, WIState newState, double transitionStartTime, double transitionDuration) { if (!Application.isPlaying) { yield break; } double transitionEndTime = transitionStartTime + transitionDuration; float normalizedTransition = 0f; //get the world light if we're using one if (!newState.UseLight) { if (worlditem.Light != null) { //whoops, better get rid of this one LightManager.DeactivateWorldLight(worlditem.Light); } } else { //if we are using one Transform lightParent = worlditem.tr; if (worlditem.Is(WIMode.Equipped | WIMode.Stacked)) { lightParent = Player.Local.Tool.ToolDoppleganger.transform; } WorldLightType wlType = WorldLightType.Exterior; if (worlditem.Is(WIMode.Equipped)) { wlType = WorldLightType.Equipped; } else { while (worlditem.Group == null) { yield return(null); } if (worlditem.Group.Props.Interior || worlditem.Group.Props.TerrainType == LocationTerrainType.BelowGround) { wlType = WorldLightType.InteriorOrUnderground; } } worlditem.Light = LightManager.GetWorldLight(worlditem.Light, newState.LightTemplateName, lightParent, newState.LightOffset, newState.LightRotation, true, wlType); } while (WorldClock.AdjustedRealTime < transitionEndTime) { normalizedTransition = (float)((WorldClock.AdjustedRealTime - transitionStartTime) / (transitionEndTime - transitionStartTime)); BlendState(oldState, newState, mCurrentState, normalizedTransition); yield return(null); } //finish transition BlendState(oldState, newState, mCurrentState, 1.0f); OnTransitionFinish(oldState, newState, mCurrentState); yield break; }
public void OnLosePower() { BehaviorState = OrbBehaviorState.Unpowered; //become stunned indefinitely creature.TryToStun(Mathf.Infinity); //SearchLight.LightEnabled = false; LuminteTrail.enabled = false; if (HasPowerBeam) { mPowerBeam.StopFiring(); } OrbSpeak(OrbSpeakUnit.TargetIsLost, worlditem.tr); LightManager.DeactivateWorldLight(SearchLight); OrbSpotlightForward.enabled = false; OrbSpotlightBottom.enabled = false; OrbPointLight.enabled = false; LuminiteParticles.enableEmission = false; PowerSource.CanRemoveSource = true; }
public void Deactivate() { LightManager.DeactivateWorldLight(this); }