Example #1
0
    protected void FireBullet(BaseEntity target, Attack attack)
    {
        RaycastHit raycastHit;

        Roost.Debug.Assert(attack != null);
        Roost.Debug.Assert(attack.HitInfo != null);
        Roost.Debug.Assert(this.m_hardpoints.MuzzlePrimary != null);
        Vector3 vector3 = base.transform.forward;

        if (target != null)
        {
            vector3 = target.Center() - this.m_hardpoints.MuzzlePrimary.position;
        }
        if (Physics.Raycast(this.m_hardpoints.MuzzlePrimary.position, vector3, out raycastHit, Single.PositiveInfinity, attack.RangedLayerMask))
        {
            BaseCharacter component = raycastHit.transform.GetComponent <BaseCharacter>();
            if (!(component != null) || !this.IsHostileTowards(component) || !component.CanBeDamaged())
            {
                Prop prop = raycastHit.transform.GetComponent <Prop>();
                if (prop != null)
                {
                    prop.Damage(this, attack);
                }
                FXManager.Instance.CreateEffect(raycastHit.point, base.transform.rotation, 3f, 4f);
            }
            else
            {
                component.Damage(this, attack);
            }
        }
    }