Example #1
0
        protected override void Update()
        {
            float num;

            if (!this.actDropAnim)
            {
                num = (Time.deltaTime * 100f) * this.TimeScale;
            }
            else if (this.actDropAnim && !this.dropAnimFinished)
            {
                num = (Time.deltaTime * this._selfRotateSpeed) * this.TimeScale;
                this.CheckBarrierCollider();
            }
            else
            {
                this._selfRotateAcceleration = (this._selfRotateAcceleration >= 10f) ? (this._selfRotateAcceleration - 3f) : 10f;
                this._selfRotateSpeed        = (this._selfRotateSpeed >= 100f) ? (this._selfRotateSpeed - this._selfRotateAcceleration) : 100f;
                num = (Time.deltaTime * this._selfRotateSpeed) * this.TimeScale;
            }
            base.transform.Rotate(base.transform.up, num);
            if (this._state == GoodsState.Appear)
            {
                this._state = GoodsState.Idle;
            }
            else if (((this._state == GoodsState.Idle) && (base.transform.position.y <= 0.3f)) && ((this._rigidbody != null) && (this._rigidbody.velocity.y <= 0f)))
            {
                if (this.reboundTimes > 0)
                {
                    this._rigidbody.velocity = new Vector3(this._rigidbody.velocity.x, -0.8f * this._rigidbody.velocity.y, this._rigidbody.velocity.z);
                    this.reboundTimes--;
                }
                else if (!this.dropAnimFinished)
                {
                    this.dropAnimFinished = true;
                    UnityEngine.Object.Destroy(this._rigidbody);
                    this._rigidbody = null;
                    base.transform.SetLocalPositionY(0.3f);
                    if (!string.IsNullOrEmpty(this.AttachEffectPattern) && (Singleton <EventManager> .Instance.GetActor <EquipItemActor>(base.GetRuntimeID()) != null))
                    {
                        bool flag = true;
                        switch (GraphicsSettingData.GetGraphicsRecommendGrade())
                        {
                        case GraphicsRecommendGrade.Off:
                        case GraphicsRecommendGrade.Low:
                        {
                            ConfigGraphicsPersonalSetting personalGraphicsSetting = Singleton <MiHoYoGameData> .Instance.GeneralLocalData.PersonalGraphicsSetting;
                            if (!personalGraphicsSetting.IsUserDefinedGrade)
                            {
                                flag = false;
                            }
                            else if (personalGraphicsSetting.RecommendGrade != GraphicsRecommendGrade.High)
                            {
                                flag = false;
                            }
                            break;
                        }
                        }
                        if (flag)
                        {
                            int rarity = Singleton <EventManager> .Instance.GetActor <EquipItemActor>(base.GetRuntimeID()).rarity;

                            this.effects = Singleton <EffectManager> .Instance.TriggerEntityEffectPatternReturnValue(this.AttachEffectPattern, this, true);

                            int num3  = 0;
                            int count = this.OutsideEffects.Count;
                            while (num3 < count)
                            {
                                this.SetOutsideParticleColorByRarity(this.OutsideEffects[num3].gameObject, rarity);
                                num3++;
                            }
                        }
                    }
                }
            }
            BaseMonoAvatar localAvatar = Singleton <AvatarManager> .Instance.GetLocalAvatar();

            if (this._state == GoodsState.Idle)
            {
                if (this.dropAnimFinished || (this.reboundTimes <= 0))
                {
                    float property = localAvatar.GetProperty("Actor_GoodsAttrackRadius");
                    property           = Mathf.Clamp(property, 0f, property);
                    this.attractRadius = localAvatar.config.CommonArguments.GoodsAttractRadius * property;
                    if (Vector3.Distance(this.XZPosition, localAvatar.XZPosition) < this.attractRadius)
                    {
                        this._state = GoodsState.Attract;
                        this.attractTimer.SetActive(false);
                        if (!string.IsNullOrEmpty(this.AttachEffectPattern) && (Singleton <EventManager> .Instance.GetActor <EquipItemActor>(base.GetRuntimeID()) != null))
                        {
                            foreach (MonoEffect effect in this.effects)
                            {
                                if (effect != null)
                                {
                                    effect.SetDestroyImmediately();
                                }
                            }
                        }
                    }
                }
            }
            else if ((this._state == GoodsState.Attract) || this.forceFlyToAvatar)
            {
                this.speed += (this.acceleration * this.TimeScale) * Time.deltaTime;
                this.speed  = (this.speed >= 20f) ? 20f : this.speed;
                Vector3   vector7   = localAvatar.RootNodePosition - base.transform.position;
                Vector3   vector    = (Vector3)((vector7.normalized * this.speed) * this.TimeScale);
                Transform transform = base.transform;
                transform.position += (Vector3)(vector * Time.deltaTime);
                this.attractTimer.Core(1f);
                if ((Vector3.Distance(this.XZPosition, localAvatar.XZPosition) < localAvatar.config.CommonArguments.CollisionRadius) || this.attractTimer.isTimeUp)
                {
                    this.OnTriggerEnter(localAvatar.hitbox);
                }
            }
            base.Update();
        }