Пример #1
0
 public override void refreshDisplay()
 {
     base.refreshDisplay();
     this.hasWeapon   = false;
     this.attachments = null;
     this.sound       = null;
     this.destroyEffects();
     if (this.spotGameObject != null)
     {
         this.spotGameObject.SetActive(false);
     }
     if (this.displayAsset == null || this.displayAsset.type != EItemType.GUN || ((ItemGunAsset)this.displayAsset).action == EAction.String || ((ItemGunAsset)this.displayAsset).action == EAction.Rocket)
     {
         return;
     }
     this.hasWeapon   = true;
     this.attachments = this.displayModel.gameObject.GetComponent <Attachments>();
     this.interact    = (this.displayItem.state[12] == 1);
     if (!Dedicator.isDedicated)
     {
         this.sound              = this.displayModel.gameObject.AddComponent <AudioSource>();
         this.sound.clip         = null;
         this.sound.spatialBlend = 1f;
         this.sound.rolloffMode  = 1;
         this.sound.volume       = 1f;
         this.sound.minDistance  = 8f;
         this.sound.maxDistance  = 256f;
         this.sound.playOnAwake  = false;
     }
     if (this.attachments.ejectHook != null && ((ItemGunAsset)this.displayAsset).action != EAction.String && ((ItemGunAsset)this.displayAsset).action != EAction.Rocket)
     {
         EffectAsset effectAsset = null;
         if (((ItemGunAsset)this.displayAsset).action == EAction.Pump || ((ItemGunAsset)this.displayAsset).action == EAction.Break)
         {
             effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, 33);
         }
         else if (((ItemGunAsset)this.displayAsset).action != EAction.Rail)
         {
             effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, 1);
         }
         if (effectAsset != null)
         {
             Transform transform = EffectManager.Instantiate(effectAsset.effect).transform;
             transform.name          = "Emitter";
             transform.parent        = this.attachments.ejectHook;
             transform.localPosition = Vector3.zero;
             transform.localRotation = Quaternion.identity;
             this.shellEmitter       = transform.GetComponent <ParticleSystem>();
         }
     }
     if (this.attachments.barrelHook != null)
     {
         EffectAsset effectAsset2 = (EffectAsset)Assets.find(EAssetType.EFFECT, ((ItemGunAsset)this.displayAsset).muzzle);
         if (effectAsset2 != null)
         {
             Transform transform2 = EffectManager.Instantiate(effectAsset2.effect).transform;
             transform2.name          = "Emitter";
             transform2.parent        = this.attachments.barrelHook;
             transform2.localPosition = Vector3.zero;
             transform2.localRotation = Quaternion.identity;
             this.muzzleEmitter       = transform2.GetComponent <ParticleSystem>();
         }
     }
     if (this.muzzleEmitter != null)
     {
         if (this.attachments.barrelModel != null)
         {
             this.muzzleEmitter.transform.localPosition = Vector3.up * 0.25f;
         }
         else
         {
             this.muzzleEmitter.transform.localPosition = Vector3.zero;
         }
     }
     if (this.attachments.magazineAsset != null)
     {
         EffectAsset effectAsset3 = (EffectAsset)Assets.find(EAssetType.EFFECT, this.attachments.magazineAsset.tracer);
         if (effectAsset3 != null)
         {
             Transform transform3 = EffectManager.Instantiate(effectAsset3.effect).transform;
             transform3.name          = "Tracer";
             transform3.parent        = Level.effects;
             transform3.localPosition = Vector3.zero;
             transform3.localRotation = Quaternion.identity;
             this.tracerEmitter       = transform3.GetComponent <ParticleSystem>();
         }
     }
     if (!Dedicator.isDedicated)
     {
         if (this.attachments.tacticalAsset != null && (this.attachments.tacticalAsset.isLight || this.attachments.tacticalAsset.isLaser) && this.attachments.lightHook != null)
         {
             this.attachments.lightHook.gameObject.SetActive(this.interact);
         }
         if (this.spotGameObject != null)
         {
             this.spotGameObject.SetActive(this.attachments.tacticalAsset != null && this.attachments.tacticalAsset.isLight && this.interact);
         }
     }
     this.fireTime  = (float)(((ItemGunAsset)this.displayAsset).firerate - ((this.attachments.tacticalAsset == null) ? 0 : this.attachments.tacticalAsset.firerate));
     this.fireTime /= 50f;
     this.fireTime *= 3.33f;
 }