Example #1
0
        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;
        }
Example #2
0
 public void OnAddedToGroup()
 {
     if (worlditem.HasLightSource)
     {
         WorldLightType wlType = ((worlditem.Group.Props.Interior || worlditem.Group.Props.TerrainType == LocationTerrainType.BelowGround) ? WorldLightType.InteriorOrUnderground : WorldLightType.Exterior);
         if (worlditem.Is(WIMode.Equipped))
         {
             wlType = WorldLightType.Equipped;
         }
         else if (worlditem.Group != null)
         {
             if (worlditem.Group.Props.Interior || worlditem.Group.Props.TerrainType == LocationTerrainType.BelowGround)
             {
                 wlType = WorldLightType.InteriorOrUnderground;
             }
         }
         worlditem.Light.Type = wlType;
     }
 }
Example #3
0
        public static WorldLight GetWorldLight(WorldLight existingLight, string templateName, Transform lightParent, Vector3 lightOffset, Vector3 lightRotation, bool enabled, WorldLightType wlType)
        {
                        #if UNITY_EDITOR
            if (Get == null)
            {
                Mods.WakeUp <LightManager> ("Frontiers_ObjectManagers");
            }
            if (Colors.Get == null)
            {
                Mods.WakeUp <Colors> ("Frontiers_ArtResourceManagers");
            }
                        #endif
            WorldLightTemplate wlt = null;
            //if the existing light isn't null, just apply the new template
            if (existingLight != null)
            {
                existingLight.gameObject.SetActive(true);
                existingLight.tr.parent = null;
                //set the scale first so the collider range isn't affected
                existingLight.tr.localScale    = Vector3.one;
                existingLight.tr.parent        = lightParent;
                existingLight.tr.localPosition = lightOffset;
                if (lightRotation != Vector3.zero)
                {
                    existingLight.tr.localRotation = Quaternion.Euler(lightRotation);
                }
                else
                {
                    existingLight.tr.localRotation = Quaternion.identity;
                }
                if (!mTemplateLookup.TryGetValue(templateName, out wlt))
                {
                    wlt = Get.DefaultTemplate;
                }
                existingLight.SetTemplate(wlt);
                return(existingLight);
            }

            WorldLight newWorldLight = null;
            if (Get.InactiveWorldLights.Count > 0)
            {
                newWorldLight = Get.InactiveWorldLights.Dequeue();
                Get.ActiveWorldLights.Add(newWorldLight);
            }
            else
            {
                newWorldLight = CreateWorldLight();
            }
            newWorldLight.Reset();
            newWorldLight.Type = wlType;
            newWorldLight.Enable(true);
            newWorldLight.tr.parent = null;
            //set the scale first so the collider range isn't affected
            newWorldLight.tr.localScale    = Vector3.one;
            newWorldLight.tr.parent        = lightParent;
            newWorldLight.tr.localPosition = lightOffset;
            if (lightRotation != Vector3.zero)
            {
                newWorldLight.tr.localRotation = Quaternion.Euler(lightRotation);
            }
            else
            {
                newWorldLight.tr.localRotation = Quaternion.identity;
            }
            if (!mTemplateLookup.TryGetValue(templateName, out wlt))
            {
                wlt = Get.DefaultTemplate;
            }
            newWorldLight.SetTemplate(wlt);
            newWorldLight.UpdateBrightness();

            return(newWorldLight);
        }
Example #4
0
 public static WorldLight GetWorldLight(string lightType, Transform parent, Vector3 offset, bool enabled, WorldLightType wlType)
 {
     return(GetWorldLight(null, lightType, parent, offset, Vector3.zero, enabled, wlType));
 }