protected internal override void OnTick(float dt) { switch (this._state) { case Bird.State.TakingOff: this.ApplyDisplacement(dt); if ((double)this.GameEntity.Skeleton.GetAnimationParameterAtChannel(0) <= 0.990000009536743) { break; } this.GameEntity.Skeleton.SetAnimationAtChannel("anim_bird_cycle", 0); this._timer.Reset(); this.SetDisplacement(); this._state = Bird.State.Airborne; Debug.Print("Start flying", color: Debug.DebugColor.Blue, debugFilter: 32768UL); break; case Bird.State.Airborne: if ((double)this._timer.ElapsedTime > 5.0) { if (this._canLand) { Debug.Print("Start landing", color: Debug.DebugColor.Cyan, debugFilter: 32768UL); this.GameEntity.Skeleton.SetAnimationAtChannel("anim_bird_landing", 0); this._timer.Reset(); this._state = Bird.State.Landing; this.SetDisplacement(); break; } this.GameEntity.SetVisibilityExcludeParents(false); break; } this.ApplyDisplacement(dt); break; case Bird.State.Landing: this.ApplyDisplacement(dt); if ((double)this.GameEntity.Skeleton.GetAnimationParameterAtChannel(0) <= 0.990000009536743) { break; } Debug.Print("Start perched", color: Debug.DebugColor.DarkBlue, debugFilter: 32768UL); this.GameEntity.Skeleton.SetAnimationAtChannel("anim_bird_idle", 0); this._timer.Reset(); this._state = Bird.State.Perched; break; case Bird.State.Perched: if (!this.CanFly || (double)this._timer.ElapsedTime <= 5.0 + (double)MBRandom.RandomFloat * 13.0 || (double)this.GameEntity.Skeleton.GetAnimationParameterAtChannel(0) <= 0.990000009536743) { break; } Debug.Print("Start taking off", color: Debug.DebugColor.DarkCyan, debugFilter: 32768UL); this.GameEntity.Skeleton.SetAnimationAtChannel("anim_bird_flying", 0); this._timer.Reset(); this._state = Bird.State.TakingOff; break; } }
protected internal override void OnInit() { base.OnInit(); this.GameEntity.SetAnimationSoundActivation(true); this.GameEntity.Skeleton.SetAnimationAtChannel("anim_bird_idle", 0); this.GameEntity.Skeleton.SetAnimationParameterAtChannel(0, MBRandom.RandomFloat * 0.5f); this._kmPerHour = 4f; this._state = this.GetState(); if (this._timer == null) { this._timer = new BasicTimer(MBCommon.TimeType.Mission); } this.SetScriptComponentToTick(this.GetTickRequirement()); }