예제 #1
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Transform hitTransform, Vector3 localHitPoint, Vector3 localHitDirection)
     : base(dataBlock, item, itemRep)
 {
     this.hitTransform = hitTransform;
     this.hitPoint = localHitPoint;
     this.hitDirection = localHitDirection;
 }
예제 #2
0
    public override void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Character character = itemInstance.character;

        if ((character != null) && (itemInstance.clipAmmo > 0))
        {
            Socket muzzle;
            Ray    eyesRay = character.eyesRay;
            int    count   = 1;
            itemInstance.Consume(ref count);
            uLink.BitStream sendStream  = new uLink.BitStream(false);
            float           bulletRange = this.GetBulletRange(itemRep);
            for (int i = 0; i < this.numPellets; i++)
            {
                bool flag;
                Ray  ray = eyesRay;
                ray.direction = (Vector3)((Quaternion.LookRotation(eyesRay.direction) * Quaternion.Euler(UnityEngine.Random.Range(-this.xSpread, this.xSpread), UnityEngine.Random.Range(-this.ySpread, this.ySpread), 0f)) * Vector3.forward);
                Component hitComponent = null;
                this.FireSingleBullet(sendStream, ray, itemRep, out hitComponent, out flag);
                this.MakeTracer(ray.origin, ray.origin + ((Vector3)(ray.direction * bulletRange)), bulletRange, hitComponent, flag);
            }
            itemRep.ActionStream(1, uLink.RPCMode.Server, sendStream);
            bool firstPerson = (bool)vm;
            if (firstPerson)
            {
                muzzle = vm.muzzle;
            }
            else
            {
                muzzle = itemRep.muzzle;
            }
            this.DoWeaponEffects(character.transform, muzzle, firstPerson, itemRep);
            if (firstPerson)
            {
                vm.PlayFireAnimation();
            }
            float num4 = 1f;
            if (sample.aim)
            {
                num4 -= base.aimingRecoilSubtract;
            }
            else if (sample.crouch)
            {
                num4 -= base.crouchRecoilSubtract;
            }
            float            pitch            = UnityEngine.Random.Range(base.recoilPitchMin, base.recoilPitchMax) * num4;
            float            yaw              = UnityEngine.Random.Range(base.recoilYawMin, base.recoilYawMax) * num4;
            RecoilSimulation recoilSimulation = character.recoilSimulation;
            if (recoilSimulation != null)
            {
                recoilSimulation.AddRecoil(base.recoilDuration, pitch, yaw);
            }
            HeadBob bob = CameraMount.current.GetComponent <HeadBob>();
            if ((bob != null) && (base.shotBob != null))
            {
                bob.AddEffect(base.shotBob);
            }
        }
    }
예제 #3
0
    public override void InstallData(IInventoryItem item)
    {
        base.InstallData(item);
        IBulletWeaponItem bulletWeaponItem = item as IBulletWeaponItem;

        this._maxUses             = this.maxClipAmmo;
        bulletWeaponItem.clipAmmo = this.maxClipAmmo;
    }
예제 #4
0
 public virtual void Local_Reload(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
 {
     if (vm)
     {
         vm.PlayReloadAnimation();
     }
     this.reloadSound.PlayLocal(itemRep.transform, Vector3.zero, 1f, 0);
     itemRep.Action(3, uLink.RPCMode.Server);
 }
예제 #5
0
        public ShotgunShootEvent(ShotgunDataBlock bw, ItemRepresentation ir, uLink.NetworkMessageInfo ui, IBulletWeaponItem ibw)
        {
            TakeDamage local = ibw.inventory.GetLocal <TakeDamage>();

            _player = Fougerite.Server.GetServer().FindPlayer(local.GetComponent <Character>().netUser.userID);
            _bw     = bw;
            _ir     = ir;
            _ibw    = ibw;
            _unmi   = ui;
        }
예제 #6
0
        public ShootEvent(BulletWeaponDataBlock bw, UnityEngine.GameObject go, ItemRepresentation ir, uLink.NetworkMessageInfo ui, IBulletWeaponItem ibw)
        {
            TakeDamage local = ibw.inventory.GetLocal <TakeDamage>();

            _player = Fougerite.Server.Cache[local.GetComponent <Character>().netUser.userID];
            _bw     = bw;
            _go     = go;
            _ir     = ir;
            _ibw    = ibw;
            _unmi   = ui;
        }
예제 #7
0
        public ShotgunShootEvent(ShotgunDataBlock bw, ItemRepresentation ir, uLink.NetworkMessageInfo ui, IBulletWeaponItem ibw, ShotgunEventType type,
                                 IDRemoteBodyPart part, bool flag, bool flag2, bool flag3, BodyPart part2, Vector3 vector, Vector3 vector2)
        {
            TakeDamage local = ibw.inventory.GetLocal <TakeDamage>();

            _player        = Fougerite.Server.GetServer().FindPlayer(local.GetComponent <Character>().netUser.userID);
            _bw            = bw;
            _ir            = ir;
            _ibw           = ibw;
            _unmi          = ui;
            _type          = type;
            _part          = part;
            _hitnetworkobj = flag;
            _hitbodypart   = flag2;
            _isheadshot    = flag3;
            _bodypart      = part2;
            _endpos        = vector;
            _offset        = vector2;
        }
예제 #8
0
        public ShotgunShootEvent(ShotgunDataBlock bw, ItemRepresentation ir, uLink.NetworkMessageInfo ui, IBulletWeaponItem ibw, int pellets, ShotgunEventType type)
        {
            TakeDamage local = ibw.inventory.GetLocal <TakeDamage>();

            _player        = Fougerite.Server.GetServer().FindPlayer(local.GetComponent <Character>().netUser.userID);
            _bw            = bw;
            _ir            = ir;
            _ibw           = ibw;
            _unmi          = ui;
            _type          = type;
            _part          = null;
            _pellets       = pellets;
            _hitnetworkobj = false;
            _hitbodypart   = false;
            _isheadshot    = false;
            _bodypart      = BodyPart.Spine0;
            _endpos        = Vector3.zero;
            _offset        = Vector3.zero;
        }
예제 #9
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Vector3 worldHitPoint, Vector3 worldHitDirection)
     : this(dataBlock, item, itemRep, null, worldHitPoint, worldHitDirection)
 {
 }
예제 #10
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Vector3 worldHitPoint, Vector3 worldHitDirection) : this(dataBlock, item, itemRep, null, worldHitPoint, worldHitDirection)
 {
 }
예제 #11
0
 public BulletWeaponImpact(BulletWeaponDataBlock dataBlock, IBulletWeaponItem item, ItemRepresentation itemRep, Transform hitTransform, Vector3 localHitPoint, Vector3 localHitDirection) : base(dataBlock, item, itemRep)
 {
     this.hitTransform = hitTransform;
     this.hitPoint     = localHitPoint;
     this.hitDirection = localHitDirection;
 }
예제 #12
0
    public virtual void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Component   component;
        Vector3     point;
        RaycastHit2 raycastHit2;
        IDMain      dMain;
        Socket      item;
        bool        flag;
        bool        flag1;
        Component   component1;
        IDMain      dMain1;
        Character   character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray         ray         = character.eyesRay;
        NetEntityID netEntityID = NetEntityID.unassigned;
        bool        flag2       = false;
        int         num         = 1;

        itemInstance.Consume(ref num);
        bool       flag3      = Physics2.Raycast2(ray, out raycastHit2, this.GetBulletRange(itemRep), 406721553);
        TakeDamage takeDamage = null;

        if (!flag3)
        {
            dMain     = null;
            point     = ray.GetPoint(1000f);
            component = null;
        }
        else
        {
            point = raycastHit2.point;
            IDBase dBase = raycastHit2.id;
            if (!raycastHit2.remoteBodyPart)
            {
                component1 = raycastHit2.collider;
            }
            else
            {
                component1 = raycastHit2.remoteBodyPart;
            }
            component = component1;
            if (!dBase)
            {
                dMain1 = null;
            }
            else
            {
                dMain1 = dBase.idMain;
            }
            dMain = dMain1;
            if (dMain)
            {
                netEntityID = NetEntityID.Get(dMain);
                if (!netEntityID.isUnassigned)
                {
                    flag2      = true;
                    takeDamage = dMain.GetComponent <TakeDamage>();
                    if (takeDamage && takeDamage.ShouldPlayHitNotification())
                    {
                        this.PlayHitNotification(point, character);
                    }
                    bool flag4 = false;
                    if (raycastHit2.remoteBodyPart)
                    {
                        BodyPart bodyPart = raycastHit2.remoteBodyPart.bodyPart;
                        switch (bodyPart)
                        {
                        case BodyPart.Brain:
                        case BodyPart.L_Eye:
                        case BodyPart.R_Eye:
                        {
Label0:
                            flag4 = true;
                            break;
                        }

                        default:
                        {
                            switch (bodyPart)
                            {
                            case BodyPart.Head:
                            case BodyPart.Jaw:
                            {
                                goto Label0;
                            }

                            case BodyPart.Scalp:
                            case BodyPart.Nostrils:
                            {
                                flag4 = false;
                                break;
                            }

                            default:
                            {
                                goto case BodyPart.Nostrils;
                            }
                            }
                            break;
                        }
                        }
                    }
                    if (flag4)
                    {
                        this.headshotSound.Play();
                    }
                }
            }
        }
        if (!flag3)
        {
            flag1 = false;
        }
        else
        {
            flag1 = (!raycastHit2.isHitboxHit || raycastHit2.bodyPart.IsDefined() ? true : takeDamage != null);
        }
        bool flag5 = flag1;

        if (!vm)
        {
            item = itemRep.muzzle;
            flag = false;
        }
        else
        {
            item = vm.socketMap["muzzle"].socket;
            flag = true;
        }
        Vector3 vector3 = item.position;

        this.DoWeaponEffects(character.transform, vector3, point, item, flag, component, flag5, itemRep);
        if (flag)
        {
            vm.PlayFireAnimation();
        }
        float single = 1f;

        if ((!sample.aim ? false : sample.crouch))
        {
            single = single - (this.aimingRecoilSubtract + this.crouchRecoilSubtract * 0.5f);
        }
        else if (sample.aim)
        {
            single = single - this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            single = single - this.crouchRecoilSubtract;
        }
        single = Mathf.Clamp01(single);
        float single1 = UnityEngine.Random.Range(this.recoilPitchMin, this.recoilPitchMax) * single;
        float single2 = UnityEngine.Random.Range(this.recoilYawMin, this.recoilYawMax) * single;

        if (BulletWeaponDataBlock.weaponRecoil && character.recoilSimulation)
        {
            character.recoilSimulation.AddRecoil(this.recoilDuration, single1, single2);
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob && this.shotBob && BulletWeaponDataBlock.headRecoil)
        {
            headBob.AddEffect(this.shotBob);
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        this.WriteHitInfo(bitStream, ref ray, flag3, ref raycastHit2, flag2, netEntityID);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
    }
예제 #13
0
        public static bool Test_WeaponShot(Character Killer, GameObject hitObj, IBulletWeaponItem weapon, ItemRepresentation rep, Transform transform, Vector3 endPos, bool isHeadshot)
        {
            if ((Killer == null) || (transform == null))
            {
                return(true);
            }
            if (((transform == null) || (Killer == null)) || (Killer.netUser == null))
            {
                return(true);
            }
            if ((float.IsNaN(endPos.x) || float.IsNaN(endPos.y)) || float.IsNaN(endPos.z))
            {
                return(true);
            }
            Character component   = hitObj.GetComponent <Character>();
            NetUser   key         = ((Killer == null) || (Killer.controllable == null)) ? null : Killer.netUser;
            NetUser   user2       = ((component == null) || (component.controllable == null)) ? null : component.netUser;
            Vector3   origin      = Helper.GetEyesRay(Killer).origin;
            float     num         = Vector3.Distance(origin, endPos);
            float     bulletRange = ((BulletWeaponDataBlock)rep.datablock).bulletRange;

            if (component == null)
            {
                if (num > bulletRange)
                {
                    return(true);
                }
                foreach (Collider collider in Physics.OverlapSphere(Killer.eyesRay.origin, 0.2f))
                {
                    IDBase base2 = collider.gameObject.GetComponent <IDBase>();
                    if ((base2 != null) && (base2.idMain is StructureMaster))
                    {
                        return(true);
                    }
                }
                IDMain idMain = IDBase.GetMain(hitObj).idMain;
                if ((idMain.GetComponent <StructureComponent>() == null) && (idMain.GetComponent <SleepingAvatar>() == null))
                {
                    Ray     lookRay  = Helper.GetLookRay(Killer);
                    Vector3 position = hitObj.transform.position;
                    position.y += 0.1f;
                    if (Physics.RaycastAll(lookRay, Vector3.Distance(lookRay.origin, position), -1).Length > 1)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if ((CheckAimbot && !key.admin) && !component.dead)
            {
                string newValue = Helper.NiceName((user2 != null) ? user2.displayName : component.name);
                if (!WeaponShotEyes.ContainsKey(key))
                {
                    PlayerShotEyes eyes = new PlayerShotEyes {
                        origin = Killer.eyesRay.origin,
                        angles = Killer.eyesAngles,
                        count  = 0
                    };
                    WeaponShotEyes.Add(key, eyes);
                }
                Vector3 vector5 = transform.position - endPos;
                if (vector5.magnitude > 3f)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.JackedSilent", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, true);
                    return(true);
                }
                if (num < 1f)
                {
                    return(false);
                }
                if (ShotThroughObjectBlock)
                {
                    Vector3    vector3;
                    GameObject obj2 = Helper.GetLineObject(origin, endPos, out vector3, 0x183e1411);
                    if ((obj2 != null) && ((obj2.GetComponent <StructureComponent>() != null) || (obj2.GetComponent <BasicDoor>() != null)))
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ShootBlocked", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%OBJECT%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.POS%", obj2.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%POINT%", vector3.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        if (!Killer.stateFlags.movement)
                        {
                            if (ShotThroughObjectPunish)
                            {
                                Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                            }
                            else
                            {
                                Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            }
                            return(true);
                        }
                        Vector3 pos = key.truthDetector.prevSnap.pos;
                        pos.x = origin.x;
                        pos.z = origin.z;
                        if (Helper.GetLineObject(pos, endPos, out vector3, 0x183e1411) == obj2)
                        {
                            Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            return(true);
                        }
                    }
                }
                uint num4 = ((uint)Environment.TickCount) - key.truthDetector.prevHitTime;
                if (num4 == Environment.TickCount)
                {
                    num4 = 0;
                }
                key.truthDetector.prevHitTime = (uint)Environment.TickCount;
                if ((num4 > 100) && (num4 < Environment.TickCount))
                {
                    float minShotRateByRange = MinShotRateByRange;
                    float num6 = ((float)num4) / num;
                    Config.Get("SERVER", "Truth.MinShotRateByRange." + weapon.datablock.name, ref minShotRateByRange, true);
                    if (num6 < minShotRateByRange)
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.HighFireRate", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        PunishDetails = PunishDetails.Replace("%SHOTRATE%", num6.ToString("N2"));
                        PunishDetails = PunishDetails.Replace("%MINRATE%", minShotRateByRange.ToString("N2"));
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                        return(true);
                    }
                }
                if (CheckShotRange && (Math.Abs(num) > bulletRange))
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.OverWeaponRange", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    if (user2 != null)
                    {
                        bool punishBan = (ShotAboveMaxDistance > 0f) && ((num - bulletRange) >= ShotAboveMaxDistance);
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, punishBan);
                    }
                    else
                    {
                        Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                        Helper.LogError(string.Concat(new object[] { "Noticed [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                    }
                    return(true);
                }
                float num7 = HeadshotAimTime * num;
                if (num4 > num7)
                {
                    key.truthDetector.headshotHold = 0;
                }
                if (isHeadshot)
                {
                    key.truthDetector.headshotHold += (int)num;
                }
                if (key.truthDetector.headshotHold >= HeadshotThreshold)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ThresholdHeadshots", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                    return(true);
                }
            }
            return(false);
        }
예제 #14
0
    public override void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        bool      flag;
        Socket    socket;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray ray = character.eyesRay;
        int num = 1;

        itemInstance.Consume(ref num);
        uLink.BitStream bitStream   = new uLink.BitStream(false);
        float           bulletRange = this.GetBulletRange(itemRep);

        for (int i = 0; i < this.numPellets; i++)
        {
            Ray ray1 = ray;
            ray1.direction = (Quaternion.LookRotation(ray.direction) * Quaternion.Euler(UnityEngine.Random.Range(-this.xSpread, this.xSpread), UnityEngine.Random.Range(-this.ySpread, this.ySpread), 0f)) * Vector3.forward;
            Component component = null;
            this.FireSingleBullet(bitStream, ray1, itemRep, out component, out flag);
            this.MakeTracer(ray1.origin, ray1.origin + (ray1.direction * bulletRange), bulletRange, component, flag);
        }
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        bool flag1 = vm;

        if (!flag1)
        {
            socket = itemRep.muzzle;
        }
        else
        {
            socket = vm.muzzle;
        }
        this.DoWeaponEffects(character.transform, socket, flag1, itemRep);
        if (flag1)
        {
            vm.PlayFireAnimation();
        }
        float single = 1f;

        if (sample.aim)
        {
            single = single - this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            single = single - this.crouchRecoilSubtract;
        }
        float            single1          = UnityEngine.Random.Range(this.recoilPitchMin, this.recoilPitchMax) * single;
        float            single2          = UnityEngine.Random.Range(this.recoilYawMin, this.recoilYawMax) * single;
        RecoilSimulation recoilSimulation = character.recoilSimulation;

        if (recoilSimulation)
        {
            recoilSimulation.AddRecoil(this.recoilDuration, single1, single2);
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob && this.shotBob)
        {
            headBob.AddEffect(this.shotBob);
        }
    }
예제 #15
0
    public virtual void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Component   component;
        Vector3     point;
        RaycastHit2 hit;
        IDMain      main;
        bool        flag4;
        Socket      muzzle;
        bool        flag5;
        Character   shooterOrNull = itemInstance.character;

        if (shooterOrNull == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray         eyesRay        = shooterOrNull.eyesRay;
        NetEntityID unassigned     = NetEntityID.unassigned;
        bool        hitNetworkView = false;
        int         count          = 1;

        itemInstance.Consume(ref count);
        bool       didHit = Physics2.Raycast2(eyesRay, out hit, this.GetBulletRange(itemRep), 0x183e1411);
        TakeDamage damage = null;

        if (!didHit)
        {
            main      = null;
            point     = eyesRay.GetPoint(1000f);
            component = null;
            goto Label_019E;
        }
        point = hit.point;
        IDBase id = hit.id;

        component = (hit.remoteBodyPart == null) ? ((Component)hit.collider) : ((Component)hit.remoteBodyPart);
        main      = (id == null) ? null : id.idMain;
        if (main == null)
        {
            goto Label_019E;
        }
        unassigned = NetEntityID.Get((MonoBehaviour)main);
        if (unassigned.isUnassigned)
        {
            goto Label_019E;
        }
        hitNetworkView = true;
        damage         = main.GetComponent <TakeDamage>();
        if ((damage != null) && damage.ShouldPlayHitNotification())
        {
            this.PlayHitNotification(point, shooterOrNull);
        }
        bool flag3 = false;

        if (hit.remoteBodyPart != null)
        {
            BodyPart bodyPart = hit.remoteBodyPart.bodyPart;
            switch (bodyPart)
            {
            case BodyPart.Brain:
            case BodyPart.L_Eye:
            case BodyPart.R_Eye:
                break;

            default:
                switch (bodyPart)
                {
                case BodyPart.Head:
                case BodyPart.Jaw:
                    break;

                case BodyPart.Scalp:
                case BodyPart.Nostrils:
                    goto Label_016C;

                default:
                    goto Label_016C;
                }
                break;
            }
            flag3 = true;
        }
        goto Label_0174;
Label_016C:
        flag3 = false;
Label_0174:
        if (flag3)
        {
            this.headshotSound.Play();
        }
Label_019E:
        flag4 = didHit && ((!hit.isHitboxHit || hit.bodyPart.IsDefined()) || (damage != null));
        if (vm != null)
        {
            Socket.Slot slot = vm.socketMap["muzzle"];
            muzzle = slot.socket;
            flag5  = true;
        }
        else
        {
            muzzle = itemRep.muzzle;
            flag5  = false;
        }
        Vector3 position = muzzle.position;

        this.DoWeaponEffects(shooterOrNull.transform, position, point, muzzle, flag5, component, flag4, itemRep);
        if (flag5)
        {
            vm.PlayFireAnimation();
        }
        float num2 = 1f;

        if (sample.aim && sample.crouch)
        {
            num2 -= this.aimingRecoilSubtract + (this.crouchRecoilSubtract * 0.5f);
        }
        else if (sample.aim)
        {
            num2 -= this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            num2 -= this.crouchRecoilSubtract;
        }
        num2 = Mathf.Clamp01(num2);
        float pitch = Random.Range(this.recoilPitchMin, this.recoilPitchMax) * num2;
        float yaw   = Random.Range(this.recoilYawMin, this.recoilYawMax) * num2;

        if (weaponRecoil && (shooterOrNull.recoilSimulation != null))
        {
            shooterOrNull.recoilSimulation.AddRecoil(this.recoilDuration, pitch, yaw);
        }
        HeadBob bob = CameraMount.current.GetComponent <HeadBob>();

        if (((bob != null) && (this.shotBob != null)) && headRecoil)
        {
            bob.AddEffect(this.shotBob);
        }
        BitStream sendStream = new BitStream(false);

        this.WriteHitInfo(sendStream, ref eyesRay, didHit, ref hit, hitNetworkView, unassigned);
        itemRep.ActionStream(1, RPCMode.Server, sendStream);
    }