public ShuttleAnim(SmartEntity starport) { this.Starport = starport; this.state = ShuttleState.None; this.states = new Queue <ShuttleState>(); this.timerId = 0u; }
private void AnimateContrabandShuttle(ShuttleAnim anim, float percent) { if (anim.Anim == null) { return; } if (percent < 1f) { ShuttleState state = anim.State; if (state != ShuttleState.Landing && state != ShuttleState.Idle) { anim.EnqueueState(ShuttleState.Landing); anim.EnqueueState(ShuttleState.Idle); return; } } else { ShuttleState state = anim.State; if (state == ShuttleState.Landing || state == ShuttleState.Idle) { anim.EnqueueState(ShuttleState.LiftOff); return; } this.RemoveStarportShuttle(anim.Starport); } }
private void UpdateContraBandGeneratorAnimation(SmartEntity entity, ShuttleAnim currentState) { if (entity.BuildingComp.BuildingType.Type != BuildingType.Resource || entity.BuildingComp.BuildingType.Currency != CurrencyType.Contraband) { return; } if (currentState != null) { BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp; Animation anim = buildingAnimationComp.Anim; ShuttleState state = currentState.State; if (state != ShuttleState.Landing && state != ShuttleState.LiftOff) { if (state == ShuttleState.Idle) { if (anim.GetClip("Active") != null && anim.GetClip("Intro") != null) { anim.Stop(); anim.Play("Intro"); this.EnqueueAnimation(buildingAnimationComp, "Active"); } } } else if (anim.GetClip("Full") != null) { anim.Stop(); anim.Play("Full"); } } }
public void EnqueueState(ShuttleState newState) { this.states.Enqueue(newState); if (this.timerId == 0u) { this.DequeueState(); } }
private void DequeueState() { if (this.Anim == null) { this.Stop(); return; } if (this.states.Count != 0) { this.state = this.states.Dequeue(); if (this.state != ShuttleState.None) { if (this.state == ShuttleState.Landing) { Service.ViewTimerManager.CreateViewTimer((!this.IsContrabandShuttle) ? 0.2f : 3f, false, new TimerDelegate(this.CallbackPlayParticle), this.LandingEffect); } else if (this.state == ShuttleState.LiftOff) { this.PlayParticle(this.TakeOffEffect); } this.Anim.Play(this.state.ToString()); Service.EventManager.SendEvent(EventId.ShuttleAnimStateChanged, this); float num = 0f; if (this.state != ShuttleState.Idle) { IEnumerator enumerator = this.Anim.GetEnumerator(); try { if (enumerator.MoveNext()) { AnimationState animationState = (AnimationState)enumerator.Current; num = animationState.length; } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } if (num > 0f) { Service.ViewTimeEngine.RegisterFrameTimeObserver(this); this.timerId = Service.ViewTimerManager.CreateViewTimer(num, false, new TimerDelegate(this.OnAnimationFinished), null); } else { this.DequeueState(); } } } }
public void Stop() { if (this.timerId != 0u) { Service.ViewTimerManager.KillViewTimer(this.timerId); this.timerId = 0u; } if (this.Anim != null) { this.Anim.Stop(); } this.states.Clear(); this.state = ShuttleState.None; Service.ViewTimeEngine.UnregisterFrameTimeObserver(this); }
private void DequeueState() { if (this.Anim == null) { this.Stop(); return; } if (this.states.Count != 0) { this.state = this.states.Dequeue(); if (this.state != ShuttleState.None) { if (this.state == ShuttleState.Landing) { Service.Get <ViewTimerManager>().CreateViewTimer(this.IsContrabandShuttle ? 3f : 0.2f, false, new TimerDelegate(this.CallbackPlayParticle), this.LandingEffect); } else if (this.state == ShuttleState.LiftOff) { this.PlayParticle(this.TakeOffEffect); } this.Anim.Play(this.state.ToString()); Service.Get <EventManager>().SendEvent(EventId.ShuttleAnimStateChanged, this); float num = 0f; if (this.state != ShuttleState.Idle) { using (IEnumerator enumerator = this.Anim.GetEnumerator()) { if (enumerator.MoveNext()) { AnimationState animationState = (AnimationState)enumerator.get_Current(); num = animationState.length; } } } if (num > 0f) { Service.Get <ViewTimeEngine>().RegisterFrameTimeObserver(this); this.timerId = Service.Get <ViewTimerManager>().CreateViewTimer(num, false, new TimerDelegate(this.OnAnimationFinished), null); return; } this.DequeueState(); } } }
private void AnimateShuttle(ShuttleAnim anim, float percent) { if (percent <= 0f) { this.RemoveStarportShuttle(anim.Starport); return; } if (anim.Anim == null) { return; } if (percent < 1f) { ShuttleState state = anim.State; if (state != ShuttleState.Landing && state != ShuttleState.Idle) { if (state == ShuttleState.None) { anim.EnqueueState(ShuttleState.Landing); anim.EnqueueState(ShuttleState.Idle); } } } else { switch (anim.State) { case ShuttleState.None: anim.EnqueueState(ShuttleState.Landing); anim.EnqueueState(ShuttleState.Idle); anim.EnqueueState(ShuttleState.LiftOff); anim.EnqueueState(ShuttleState.Hover); break; case ShuttleState.Idle: anim.EnqueueState(ShuttleState.LiftOff); anim.EnqueueState(ShuttleState.Hover); break; } } }