void IUpdatable.UpdateObject() { if (this.waitForDespawn) { if (!this.ent.gameObject.activeInHierarchy) { base.enabled = false; this.waitForDespawn = false; this.DoRespawn(); } return; } this.timer -= Time.deltaTime; if (this.backCam != null && this.fadeTimer > 0f) { this.fadeTimer -= Time.deltaTime; float num = Mathf.Max(0f, this.fadeTimer * this.fadeTimeScale); this.backCam.backgroundColor = Color.Lerp(this.startFadeColor, this._bgFadeColor, num); } if (this.timer <= 0f) { if (this.backCam != null) { this.backCam.backgroundColor = this.startFadeColor; } base.enabled = false; if (this.ShouldChangeLevels()) { this.ChangeLevelRespawn(); } else if (this._fadeOut != null && !this.noFadeOut) { Vector3 value = CoordinateTransformer.ToViewport("Main Camera", this.ent.WorldPosition); OverlayFader.StartFade(this._fadeOut, true, new OverlayFader.OnDoneFunc(this.StartSpawnWait), new Vector3?(value)); } else { this.DoRespawn(); } } }
public void ForceRespawn() { if (this.inForceRespawn) { return; } this.inForceRespawn = true; if (this.WillChangeLevels()) { this.localPauseTag = ObjectUpdater.Instance.RequestPause(null); Killable entityComponent = this.ent.GetEntityComponent <Killable>(); if (entityComponent != null) { entityComponent.CurrentHp = entityComponent.MaxHp; } this.ChangeLevelRespawn(); return; } ObjectUpdater.PauseTag pauseTag = ObjectUpdater.Instance.RequestPause(null); OverlayFader.OnDoneFunc onDoneFunc = delegate() { this.inForceRespawn = false; pauseTag.Release(); Killable entityComponent2 = this.ent.GetEntityComponent <Killable>(); if (entityComponent2 != null) { Killable.DeathData deathData = new Killable.DeathData(true); entityComponent2.ForceDeath(0f, deathData, true); } }; if (this._fadeOut != null) { Vector3 value = CoordinateTransformer.ToViewport("Main Camera", this.ent.WorldPosition); OverlayFader.StartFade(this._fadeOut, true, onDoneFunc, new Vector3?(value)); } else { onDoneFunc(); } }
static Vector3 WorldToScreen(Vector3 pos) { return(CoordinateTransformer.ToViewport("Main Camera", pos)); }