Beispiel #1
0
    public virtual bool ShotTest()
    {
        AttackEntity heldEntity = base.GetHeldEntity() as AttackEntity;

        if (heldEntity == null)
        {
            return(false);
        }
        BaseProjectile baseProjectile = heldEntity as BaseProjectile;

        if (baseProjectile)
        {
            if (baseProjectile.primaryMagazine.contents <= 0)
            {
                baseProjectile.ServerReload();
                NPCPlayerApex nPCPlayerApex = this as NPCPlayerApex;
                if (nPCPlayerApex && nPCPlayerApex.OnReload != null)
                {
                    nPCPlayerApex.OnReload();
                }
                return(false);
            }
            if (baseProjectile.NextAttackTime > Time.time)
            {
                return(false);
            }
        }
        if (Mathf.Approximately(heldEntity.attackLengthMin, -1f))
        {
            heldEntity.ServerUse(this.damageScale);
            this.lastGunShotTime = Time.time;
            return(true);
        }
        NPCPlayer nPCPlayer = this;

        if (base.IsInvoking(new Action(nPCPlayer.TriggerDown)))
        {
            return(true);
        }
        if (Time.time < this.nextTriggerTime)
        {
            return(true);
        }
        NPCPlayer nPCPlayer1 = this;

        base.InvokeRepeating(new Action(nPCPlayer1.TriggerDown), 0f, 0.01f);
        this.triggerEndTime = Time.time + UnityEngine.Random.Range(heldEntity.attackLengthMin, heldEntity.attackLengthMax);
        this.TriggerDown();
        return(true);
    }
    public virtual bool ShotTest()
    {
        AttackEntity heldEntity = this.GetHeldEntity() as AttackEntity;

        if (Object.op_Equality((Object)heldEntity, (Object)null))
        {
            return(false);
        }
        BaseProjectile baseProjectile = heldEntity as BaseProjectile;

        if (Object.op_Implicit((Object)baseProjectile))
        {
            if (baseProjectile.primaryMagazine.contents <= 0)
            {
                baseProjectile.ServerReload();
                NPCPlayerApex npcPlayerApex = this as NPCPlayerApex;
                if (Object.op_Implicit((Object)npcPlayerApex) && npcPlayerApex.OnReload != null)
                {
                    npcPlayerApex.OnReload();
                }
                return(false);
            }
            if ((double)baseProjectile.NextAttackTime > (double)Time.get_time())
            {
                return(false);
            }
        }
        if (!Mathf.Approximately(heldEntity.attackLengthMin, -1f))
        {
            if (this.IsInvoking(new Action(this.TriggerDown)) || (double)Time.get_time() < (double)this.nextTriggerTime)
            {
                return(true);
            }
            this.InvokeRepeating(new Action(this.TriggerDown), 0.0f, 0.01f);
            this.triggerEndTime = Time.get_time() + Random.Range(heldEntity.attackLengthMin, heldEntity.attackLengthMax);
            this.TriggerDown();
            return(true);
        }
        heldEntity.ServerUse(this.damageScale);
        this.lastGunShotTime = Time.get_time();
        return(true);
    }