void OnServerInitialized() { if (TOD_Sky.Instance == null) { componentSearchAttempts++; if (componentSearchAttempts < 10) { timer.Once(1, OnServerInitialized); } else { PrintWarning("Could not find required component after 10 attempts. Plugin disabled"); } return; } timeComponent = TOD_Sky.Instance.Components.Time; if (timeComponent == null) { PrintWarning("Could not fetch time component. Plugin disabled"); return; } if (setPresetDate) { TOD_Sky.Instance.Cycle.Day = presetDay; TOD_Sky.Instance.Cycle.Month = presetMonth; TOD_Sky.Instance.Cycle.Year = presetYear; } SetTimeComponent(); if (freezeTimeOnload) { StartupFreeze(); } }
private void OnServerInitialized() { _sky = TOD_Sky.Instance; _time = _sky.Components.Time; _time.OnMinute += UpdateTime; MagicPanelRegisterPanels(); }
private void Init() { permission.RegisterPermission(permission_use, this); Time = TOD_Sky.Instance?.Components.Time; if (Time == null) { return; } Time.OnSunset += OnNight; Time.OnDay += OnDay; }
private void OnServerInitialized() { waitForSeconds = new WaitForSeconds(SECONDS_BETWEEN); offsetHours = Convert.ToSingle(Config[OFFSET_HOURS]); todTime = TOD_Sky.Instance.Components.Time; todTime.ProgressTime = false; todTime.UseTimeCurve = false; SyncRealTime(); todTime.RefreshTimeCurve(); ServerMgr.Instance.StartCoroutine(AddTimeAndSync()); }
/// <summary> /// Fetches the TOD_Time component of the GameObject. It is initialized with the conig values afterwards and loads the config values. /// </summary> private void GetTimeComponent() { if (TOD_Sky.Instance == null) { ++this.componentSearchAttempts; if (this.componentSearchAttempts < 10) { Puts("Restarting timer for GetTimeComponent(). Attempt " + this.componentSearchAttempts + "/10."); timer.Once(3, GetTimeComponent); } else { RaiseError("Could not find required component after 10 attempts. Plugin will not work without it."); } return; } if (TOD_Sky.Instance != null && this.componentSearchAttempts > 0) { Puts("Found TOD_Time component after attempt " + this.componentSearchAttempts + "."); } this.timeComponent = TOD_Sky.Instance.Components.Time; if (this.timeComponent == null) { RaiseError("Could not fetch time component. Plugin will not work without it."); return; } this.Daylength = 30; this.Nightlength = 30; this.Daylength = Convert.ToUInt32(Config["Settings", "Daylength"]); this.Nightlength = Convert.ToUInt32(Config["Settings", "Nightlength"]); this.timeComponent.ProgressTime = true; this.timeComponent.UseTimeCurve = false; this.timeComponent.OnSunrise += UpdateTimeOnSunrise; this.timeComponent.OnSunset += UpdateTimeOnSunset; if (TOD_Sky.Instance.IsDay == true) { UpdateTimeOnSunrise(); } else { UpdateTimeOnSunset(); } }
public override void Execute() { TOD_Sky instance = TOD_Sky.Instance; TOD_Time time = instance.Components.Time; AppTime appTime = Pool.Get <AppTime>(); appTime.dayLengthMinutes = time.DayLengthInMinutes; appTime.timeScale = (time.ProgressTime ? UnityEngine.Time.timeScale : 0f); appTime.sunrise = instance.SunriseTime; appTime.sunset = instance.SunsetTime; appTime.time = instance.Cycle.Hour; AppResponse appResponse = Pool.Get <AppResponse>(); appResponse.time = appTime; Send(appResponse); }
public static float GetSleepTimeFactor() { TOD_Sky todsky = MainLevel.Instance.m_TODSky; TOD_Time todtime = MainLevel.Instance.m_TODTime; bool flag = todsky.Cycle.Hour > 6f && todsky.Cycle.Hour <= 18f; float num; if (flag) { num = todtime.m_DayLengthInMinutes / 12f * 60f; } else { num = todtime.m_NightLengthInMinutes / 12f * 60f; } return(num * SleepController.Get().m_HoursDelta); }
//public bool speedingUp; //public bool slowingDown; // Use this for initialization void Start() { tod_time = FindObjectOfType <TOD_Time>(); tod_sky = FindObjectOfType <TOD_Sky> (); //InvokeRepeating ("SyncTime", 0, 10); }
protected void OnEnable() { this.DomeTransform = base.transform; if (Camera.main == null) { Debug.LogWarning("Main camera does not exist or is not tagged 'MainCamera'."); } else { this.CameraTransform = Camera.main.transform; } this.Sky = base.GetComponent <TOD_Sky>(); this.Animation = base.GetComponent <TOD_Animation>(); this.Time = base.GetComponent <TOD_Time>(); this.Weather = base.GetComponent <TOD_Weather>(); this.Resources = base.GetComponent <TOD_Resources>(); if (!this.Space) { Debug.LogError("Space reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.SpaceRenderer = this.Space.renderer; this.SpaceShader = this.SpaceRenderer.sharedMaterial; this.SpaceMeshFilter = this.Space.GetComponent <MeshFilter>(); if (!this.Atmosphere) { Debug.LogError("Atmosphere reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.AtmosphereRenderer = this.Atmosphere.renderer; this.AtmosphereShader = this.AtmosphereRenderer.sharedMaterial; this.AtmosphereMeshFilter = this.Atmosphere.GetComponent <MeshFilter>(); if (!this.Clear) { Debug.LogError("Clear reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.ClearRenderer = this.Clear.renderer; this.ClearShader = this.ClearRenderer.sharedMaterial; this.ClearMeshFilter = this.Clear.GetComponent <MeshFilter>(); if (!this.Clouds) { Debug.LogError("Clouds reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.CloudRenderer = this.Clouds.renderer; this.CloudShader = this.CloudRenderer.sharedMaterial; this.CloudMeshFilter = this.Clouds.GetComponent <MeshFilter>(); if (!this.Projector) { Debug.LogError("Projector reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.ShadowProjector = this.Projector.GetComponent <UnityEngine.Projector>(); this.ShadowShader = this.ShadowProjector.material; if (!this.Light) { Debug.LogError("Light reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.LightTransform = this.Light.transform; this.LightSource = this.Light.light; if (!this.Sun) { Debug.LogError("Sun reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.SunTransform = this.Sun.transform; this.SunRenderer = this.Sun.renderer; this.SunShader = this.SunRenderer.sharedMaterial; this.SunMeshFilter = this.Sun.GetComponent <MeshFilter>(); if (!this.Moon) { Debug.LogError("Moon reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.MoonTransform = this.Moon.transform; this.MoonRenderer = this.Moon.renderer; this.MoonShader = this.MoonRenderer.sharedMaterial; this.MoonMeshFilter = this.Moon.GetComponent <MeshFilter>(); }
protected void OnEnable() { this.DomeTransform = base.transform; if (Camera.main == null) { Debug.LogWarning("Main camera does not exist or is not tagged 'MainCamera'."); } else { this.CameraTransform = Camera.main.transform; } this.Sky = base.GetComponent<TOD_Sky>(); this.Animation = base.GetComponent<TOD_Animation>(); this.Time = base.GetComponent<TOD_Time>(); this.Weather = base.GetComponent<TOD_Weather>(); this.Resources = base.GetComponent<TOD_Resources>(); if (!this.Space) { Debug.LogError("Space reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.SpaceRenderer = this.Space.renderer; this.SpaceShader = this.SpaceRenderer.sharedMaterial; this.SpaceMeshFilter = this.Space.GetComponent<MeshFilter>(); if (!this.Atmosphere) { Debug.LogError("Atmosphere reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.AtmosphereRenderer = this.Atmosphere.renderer; this.AtmosphereShader = this.AtmosphereRenderer.sharedMaterial; this.AtmosphereMeshFilter = this.Atmosphere.GetComponent<MeshFilter>(); if (!this.Clear) { Debug.LogError("Clear reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.ClearRenderer = this.Clear.renderer; this.ClearShader = this.ClearRenderer.sharedMaterial; this.ClearMeshFilter = this.Clear.GetComponent<MeshFilter>(); if (!this.Clouds) { Debug.LogError("Clouds reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.CloudRenderer = this.Clouds.renderer; this.CloudShader = this.CloudRenderer.sharedMaterial; this.CloudMeshFilter = this.Clouds.GetComponent<MeshFilter>(); if (!this.Projector) { Debug.LogError("Projector reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.ShadowProjector = this.Projector.GetComponent<UnityEngine.Projector>(); this.ShadowShader = this.ShadowProjector.material; if (!this.Light) { Debug.LogError("Light reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.LightTransform = this.Light.transform; this.LightSource = this.Light.light; if (!this.Sun) { Debug.LogError("Sun reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.SunTransform = this.Sun.transform; this.SunRenderer = this.Sun.renderer; this.SunShader = this.SunRenderer.sharedMaterial; this.SunMeshFilter = this.Sun.GetComponent<MeshFilter>(); if (!this.Moon) { Debug.LogError("Moon reference not set. Disabling TOD_Sky script."); this.Sky.enabled = false; return; } this.MoonTransform = this.Moon.transform; this.MoonRenderer = this.Moon.renderer; this.MoonShader = this.MoonRenderer.sharedMaterial; this.MoonMeshFilter = this.Moon.GetComponent<MeshFilter>(); }
protected void OnEnable() { DomeTransform = transform; CameraTransform = Camera.main != null ? Camera.main.transform : DomeTransform; Sky = GetComponent <TOD_Sky>(); Animation = GetComponent <TOD_Animation>(); Time = GetComponent <TOD_Time>(); Weather = GetComponent <TOD_Weather>(); Resources = GetComponent <TOD_Resources>(); if (Space) { SpaceRenderer = Space.renderer; SpaceShader = SpaceRenderer.sharedMaterial; SpaceMeshFilter = Space.GetComponent <MeshFilter>(); } else { Debug.LogError("Space reference not set. Disabling script."); this.enabled = false; return; } if (Atmosphere) { AtmosphereRenderer = Atmosphere.renderer; AtmosphereShader = AtmosphereRenderer.sharedMaterial; AtmosphereMeshFilter = Atmosphere.GetComponent <MeshFilter>(); } else { Debug.LogError("Atmosphere reference not set. Disabling script."); this.enabled = false; return; } if (Clouds) { CloudRenderer = Clouds.renderer; CloudShader = CloudRenderer.sharedMaterial; CloudMeshFilter = Clouds.GetComponent <MeshFilter>(); } else { Debug.LogError("Clouds reference not set. Disabling script."); this.enabled = false; return; } if (Projector) { ShadowProjector = Projector.GetComponent <Projector>(); ShadowShader = ShadowProjector.material; } else { Debug.LogError("Projector reference not set. Disabling script."); this.enabled = false; return; } if (Light) { LightTransform = Light.transform; LightSource = Light.light; } else { Debug.LogError("Light reference not set. Disabling script."); this.enabled = false; return; } if (Sun) { SunTransform = Sun.transform; SunRenderer = Sun.renderer; SunShader = SunRenderer.sharedMaterial; SunMeshFilter = Sun.GetComponent <MeshFilter>(); } else { Debug.LogError("Sun reference not set. Disabling script."); this.enabled = false; return; } if (Moon) { MoonTransform = Moon.transform; MoonRenderer = Moon.renderer; MoonShader = MoonRenderer.sharedMaterial; MoonMeshFilter = Moon.GetComponent <MeshFilter>(); } else { Debug.LogError("Moon reference not set. Disabling script."); this.enabled = false; return; } }
/// Initializes all component references public void Initialize() { DomeTransform = GetComponent <Transform>(); Sky = GetComponent <TOD_Sky>(); Animation = GetComponent <TOD_Animation>(); Time = GetComponent <TOD_Time>(); Weather = GetComponent <TOD_Weather>(); Resources = GetComponent <TOD_Resources>(); if (Space) { SpaceTransform = Space.GetComponent <Transform>(); SpaceRenderer = Space.GetComponent <Renderer>(); SpaceMaterial = SpaceRenderer.sharedMaterial; SpaceMeshFilter = Space.GetComponent <MeshFilter>(); } else { Debug.LogError("Space reference not set."); } if (Atmosphere) { AtmosphereRenderer = Atmosphere.GetComponent <Renderer>(); AtmosphereMaterial = AtmosphereRenderer.sharedMaterial; AtmosphereMeshFilter = Atmosphere.GetComponent <MeshFilter>(); } else { Debug.LogError("Atmosphere reference not set."); } if (Clear) { ClearRenderer = Clear.GetComponent <Renderer>(); ClearMaterial = ClearRenderer.sharedMaterial; ClearMeshFilter = Clear.GetComponent <MeshFilter>(); } else { Debug.LogError("Clear reference not set."); } if (Clouds) { CloudRenderer = Clouds.GetComponent <Renderer>(); CloudMaterial = CloudRenderer.sharedMaterial; CloudMeshFilter = Clouds.GetComponent <MeshFilter>(); } else { Debug.LogError("Clouds reference not set."); } if (Projector) { ShadowProjector = Projector.GetComponent <Projector>(); ShadowMaterial = ShadowProjector.material; } else { Debug.LogError("Projector reference not set."); } if (Light) { LightTransform = Light.GetComponent <Transform>(); LightSource = Light.GetComponent <Light>(); } else { Debug.LogError("Light reference not set."); } if (Sun) { SunTransform = Sun.GetComponent <Transform>(); SunRenderer = Sun.GetComponent <Renderer>(); SunMaterial = SunRenderer.sharedMaterial; SunMeshFilter = Sun.GetComponent <MeshFilter>(); } else { Debug.LogError("Sun reference not set."); } if (Moon) { MoonTransform = Moon.GetComponent <Transform>(); MoonRenderer = Moon.GetComponent <Renderer>(); MoonMaterial = MoonRenderer.sharedMaterial; MoonMeshFilter = Moon.GetComponent <MeshFilter>(); } else { Debug.LogError("Moon reference not set."); } }
/// Initializes all component references. public void Initialize() { DomeTransform = GetComponent<Transform>(); Sky = GetComponent<TOD_Sky>(); Animation = GetComponent<TOD_Animation>(); Time = GetComponent<TOD_Time>(); Weather = GetComponent<TOD_Weather>(); if (Space) { SpaceTransform = Space.GetComponent<Transform>(); SpaceRenderer = Space.GetComponent<Renderer>(); SpaceMaterial = SpaceRenderer.sharedMaterial; SpaceMeshFilter = Space.GetComponent<MeshFilter>(); } else { Debug.LogError("Space reference not set."); } if (Atmosphere) { AtmosphereRenderer = Atmosphere.GetComponent<Renderer>(); AtmosphereMaterial = AtmosphereRenderer.sharedMaterial; AtmosphereMeshFilter = Atmosphere.GetComponent<MeshFilter>(); } else { Debug.LogError("Atmosphere reference not set."); } if (Clear) { ClearRenderer = Clear.GetComponent<Renderer>(); ClearMaterial = ClearRenderer.sharedMaterial; ClearMeshFilter = Clear.GetComponent<MeshFilter>(); } else { Debug.LogError("Clear reference not set."); } if (Clouds) { CloudRenderer = Clouds.GetComponent<Renderer>(); CloudMaterial = CloudRenderer.sharedMaterial; CloudMeshFilter = Clouds.GetComponent<MeshFilter>(); } else { Debug.LogError("Clouds reference not set."); } if (Projector) { ShadowProjector = Projector.GetComponent<Projector>(); ShadowMaterial = ShadowProjector.material; } else { Debug.LogError("Projector reference not set."); } if (Light) { LightTransform = Light.GetComponent<Transform>(); LightSource = Light.GetComponent<Light>(); } else { Debug.LogError("Light reference not set."); } if (Sun) { SunTransform = Sun.GetComponent<Transform>(); SunRenderer = Sun.GetComponent<Renderer>(); SunMaterial = SunRenderer.sharedMaterial; SunMeshFilter = Sun.GetComponent<MeshFilter>(); } else { Debug.LogError("Sun reference not set."); } if (Moon) { MoonTransform = Moon.GetComponent<Transform>(); MoonRenderer = Moon.GetComponent<Renderer>(); MoonMaterial = MoonRenderer.sharedMaterial; MoonMeshFilter = Moon.GetComponent<MeshFilter>(); } else { Debug.LogError("Moon reference not set."); } if (Billboards) { // Intentionally left empty } else { Debug.LogError("Billboards reference not set."); } }
protected void OnEnable() { DomeTransform = transform; CameraTransform = Camera.main != null ? Camera.main.transform : DomeTransform; Sky = GetComponent<TOD_Sky>(); Animation = GetComponent<TOD_Animation>(); Time = GetComponent<TOD_Time>(); Weather = GetComponent<TOD_Weather>(); Resources = GetComponent<TOD_Resources>(); if (Space) { SpaceRenderer = Space.renderer; SpaceShader = SpaceRenderer.sharedMaterial; SpaceMeshFilter = Space.GetComponent<MeshFilter>(); } else { Debug.LogError("Space reference not set. Disabling script."); this.enabled = false; return; } if (Atmosphere) { AtmosphereRenderer = Atmosphere.renderer; AtmosphereShader = AtmosphereRenderer.sharedMaterial; AtmosphereMeshFilter = Atmosphere.GetComponent<MeshFilter>(); } else { Debug.LogError("Atmosphere reference not set. Disabling script."); this.enabled = false; return; } if (Clouds) { CloudRenderer = Clouds.renderer; CloudShader = CloudRenderer.sharedMaterial; CloudMeshFilter = Clouds.GetComponent<MeshFilter>(); } else { Debug.LogError("Clouds reference not set. Disabling script."); this.enabled = false; return; } if (Projector) { ShadowProjector = Projector.GetComponent<Projector>(); ShadowShader = ShadowProjector.material; } else { Debug.LogError("Projector reference not set. Disabling script."); this.enabled = false; return; } if (Light) { LightTransform = Light.transform; LightSource = Light.light; } else { Debug.LogError("Light reference not set. Disabling script."); this.enabled = false; return; } if (Sun) { SunTransform = Sun.transform; SunRenderer = Sun.renderer; SunShader = SunRenderer.sharedMaterial; SunMeshFilter = Sun.GetComponent<MeshFilter>(); } else { Debug.LogError("Sun reference not set. Disabling script."); this.enabled = false; return; } if (Moon) { MoonTransform = Moon.transform; MoonRenderer = Moon.renderer; MoonShader = MoonRenderer.sharedMaterial; MoonMeshFilter = Moon.GetComponent<MeshFilter>(); } else { Debug.LogError("Moon reference not set. Disabling script."); this.enabled = false; return; } }
private void OnServerInitialized() { time = UnityEngine.Object.FindObjectOfType <TOD_Time>(); time.ProgressTime = false; Server.Command($"env.time {config.time}"); }
protected void OnEnable() { DomeTransform = transform; if (Camera.main != null) { CameraTransform = Camera.main.transform; } else { Debug.LogWarning("Main camera does not exist or is not tagged 'MainCamera'."); } Sky = GetComponent <TOD_Sky>(); Animation = GetComponent <TOD_Animation>(); Time = GetComponent <TOD_Time>(); Weather = GetComponent <TOD_Weather>(); Resources = GetComponent <TOD_Resources>(); if (Space) { SpaceRenderer = Space.GetComponent <Renderer>(); SpaceShader = SpaceRenderer.sharedMaterial; SpaceMeshFilter = Space.GetComponent <MeshFilter>(); } else { Debug.LogError("Space reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Atmosphere) { AtmosphereRenderer = Atmosphere.GetComponent <Renderer>(); AtmosphereShader = AtmosphereRenderer.sharedMaterial; AtmosphereMeshFilter = Atmosphere.GetComponent <MeshFilter>(); } else { Debug.LogError("Atmosphere reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Clear) { ClearRenderer = Clear.GetComponent <Renderer>(); ClearShader = ClearRenderer.sharedMaterial; ClearMeshFilter = Clear.GetComponent <MeshFilter>(); } else { Debug.LogError("Clear reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Clouds) { CloudRenderer = Clouds.GetComponent <Renderer>(); CloudShader = CloudRenderer.sharedMaterial; CloudMeshFilter = Clouds.GetComponent <MeshFilter>(); } else { Debug.LogError("Clouds reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Projector) { ShadowProjector = Projector.GetComponent <Projector>(); ShadowShader = ShadowProjector.material; } else { Debug.LogError("Projector reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Light) { //LightTransform = gameObject.FindOrCreateChild ("LightTransform");//Light.transform; LightSource = Light.GetComponent <Light>(); } else { Debug.LogError("Light reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Sun) { SunTransform = Sun.transform; SunRenderer = Sun.GetComponent <Renderer>(); SunShader = SunRenderer.sharedMaterial; SunMeshFilter = Sun.GetComponent <MeshFilter>(); } else { Debug.LogError("Sun reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Moon) { MoonTransform = Moon.transform; MoonRenderer = Moon.GetComponent <Renderer>(); MoonShader = MoonRenderer.sharedMaterial; MoonMeshFilter = Moon.GetComponent <MeshFilter>(); } else { Debug.LogError("Moon reference not set. Disabling TOD_Sky script."); Sky.enabled = false; return; } if (Application.isPlaying) { DontDestroyOnLoad(transform); DontDestroyOnLoad(LightTransform); DontDestroyOnLoad(LightSource); } }