public virtual void FireSingleBullet(uLink.BitStream sendStream, Ray ray, ItemRepresentation itemRep, out Component hitComponent, out bool allowBlood) { RaycastHit2 raycastHit2; Vector3 point; IDMain dMain; Component component; IDMain dMain1; NetEntityID netEntityID = NetEntityID.unassigned; bool flag = false; bool flag1 = Physics2.Raycast2(ray, out raycastHit2, this.GetBulletRange(itemRep), 406721553); if (!flag1) { dMain = null; point = ray.GetPoint(this.GetBulletRange(itemRep)); hitComponent = null; } else { point = raycastHit2.point; IDBase dBase = raycastHit2.id; if (!raycastHit2.remoteBodyPart) { component = raycastHit2.collider; } else { component = raycastHit2.remoteBodyPart; } hitComponent = component; if (!dBase) { dMain1 = null; } else { dMain1 = dBase.idMain; } dMain = dMain1; if (dMain) { netEntityID = NetEntityID.Get(dMain); if (!netEntityID.isUnassigned) { TakeDamage takeDamage = dMain.GetComponent <TakeDamage>(); if (takeDamage) { flag = true; if (takeDamage.ShouldPlayHitNotification()) { this.PlayHitNotification(point, null); } } } } } this.WriteHitInfo(sendStream, ref ray, flag1, ref raycastHit2, flag, netEntityID); allowBlood = (!flag1 ? false : flag); }
public void ArrowReportHit(IDMain hitMain, ArrowMovement arrow, ItemRepresentation itemRepresentation, IBowWeaponItem itemInstance) { if (hitMain != null) { TakeDamage component = hitMain.GetComponent <TakeDamage>(); if (component != null) { BitStream stream = new BitStream(false); stream.Write <NetEntityID>(NetEntityID.Get((MonoBehaviour)hitMain), new object[0]); stream.Write <Vector3>(hitMain.transform.position, new object[0]); itemRepresentation.ActionStream(2, RPCMode.Server, stream); Character shooterOrNull = itemInstance.character; if ((component != null) && component.ShouldPlayHitNotification()) { this.PlayHitNotification(arrow.transform.position, shooterOrNull); } } } }
public virtual void FireSingleBullet(uLink.BitStream sendStream, Ray ray, ItemRepresentation itemRep, out Component hitComponent, out bool allowBlood) { RaycastHit2 hit; Vector3 point; IDMain main; NetEntityID unassigned = NetEntityID.unassigned; bool hitNetworkView = false; bool didHit = Physics2.Raycast2(ray, out hit, this.GetBulletRange(itemRep), 0x183e1411); if (didHit) { point = hit.point; IDBase id = hit.id; hitComponent = (hit.remoteBodyPart == null) ? ((Component)hit.collider) : ((Component)hit.remoteBodyPart); main = (id == null) ? null : id.idMain; if (main != null) { unassigned = NetEntityID.Get((UnityEngine.MonoBehaviour)main); if (!unassigned.isUnassigned) { TakeDamage component = main.GetComponent <TakeDamage>(); if (component != null) { hitNetworkView = true; if (component.ShouldPlayHitNotification()) { this.PlayHitNotification(point, null); } } } } } else { main = null; point = ray.GetPoint(this.GetBulletRange(itemRep)); hitComponent = null; } this.WriteHitInfo(sendStream, ref ray, didHit, ref hit, hitNetworkView, unassigned); allowBlood = didHit && hitNetworkView; }
public void ArrowReportHit(IDMain hitMain, ArrowMovement arrow, ItemRepresentation itemRepresentation, IBowWeaponItem itemInstance) { if (!hitMain) { return; } TakeDamage component = hitMain.GetComponent <TakeDamage>(); if (!component) { return; } uLink.BitStream bitStream = new uLink.BitStream(false); bitStream.Write <NetEntityID>(NetEntityID.Get(hitMain), new object[0]); bitStream.Write <Vector3>(hitMain.transform.position, new object[0]); itemRepresentation.ActionStream(2, uLink.RPCMode.Server, bitStream); Character character = itemInstance.character; if (component && component.ShouldPlayHitNotification()) { this.PlayHitNotification(arrow.transform.position, character); } }
public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample) { Character shooterOrNull = itemInstance.character; if (shooterOrNull != null) { BodyPart part; Ray eyesRay = shooterOrNull.eyesRay; bool flag = false; Collider hitCollider = null; Vector3 zero = Vector3.zero; Vector3 up = Vector3.up; NetEntityID unassigned = NetEntityID.unassigned; bool flag2 = false; flag = this.Physics2SphereCast(eyesRay, 0.3f, this.GetRange(), 0x183e1411, out zero, out up, out hitCollider, out part); bool flag3 = false; TakeDamage component = null; if (flag) { IDBase base2; TransformHelpers.GetIDBaseFromCollider(hitCollider, out base2); IDMain main = (base2 == null) ? null : base2.idMain; if (main != null) { unassigned = NetEntityID.Get((MonoBehaviour)main); flag2 = !unassigned.isUnassigned; component = main.GetComponent <TakeDamage>(); if ((component != null) && component.ShouldPlayHitNotification()) { this.PlayHitNotification(zero, shooterOrNull); } } flag3 = hitCollider.gameObject.CompareTag("Tree Collider"); if (flag3) { WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(zero); if (!blockerForPoint.HasWood()) { flag3 = false; Notice.Popup("", "There's no wood left here", 2f); } else { blockerForPoint.ConsumeWood(this.efficiencies[2]); } } this.DoMeleeEffects(eyesRay.origin, zero, Quaternion.LookRotation(up), hitCollider.gameObject); if ((vm != null) && ((component != null) || flag3)) { vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f); } } BitStream stream = new BitStream(false); if (flag2) { stream.WriteBoolean(flag2); stream.Write <NetEntityID>(unassigned, new object[0]); stream.WriteVector3(zero); } else { stream.WriteBoolean(false); stream.WriteVector3(zero); } stream.WriteBoolean(flag3); itemRep.ActionStream(1, RPCMode.Server, stream); this.EndSwingWorldAnimations(itemRep); } }
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); }
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); }
public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample) { BodyPart bodyPart; IDBase dBase; IDMain dMain; Character character = itemInstance.character; if (character == null) { return; } Ray ray = character.eyesRay; bool flag = false; Collider collider = null; Vector3 vector3 = Vector3.zero; Vector3 vector31 = Vector3.up; NetEntityID netEntityID = NetEntityID.unassigned; bool flag1 = false; flag = this.Physics2SphereCast(ray, 0.3f, this.GetRange(), 406721553, out vector3, out vector31, out collider, out bodyPart); bool flag2 = false; TakeDamage component = null; if (flag) { TransformHelpers.GetIDBaseFromCollider(collider, out dBase); if (!dBase) { dMain = null; } else { dMain = dBase.idMain; } IDMain dMain1 = dMain; if (dMain1) { netEntityID = NetEntityID.Get(dMain1); flag1 = !netEntityID.isUnassigned; component = dMain1.GetComponent <TakeDamage>(); if (component && component.ShouldPlayHitNotification()) { this.PlayHitNotification(vector3, character); } } flag2 = collider.gameObject.CompareTag("Tree Collider"); if (flag2) { WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(vector3); if (blockerForPoint.HasWood()) { blockerForPoint.ConsumeWood(this.efficiencies[2]); } else { flag2 = false; Notice.Popup("", "There's no wood left here", 2f); } } this.DoMeleeEffects(ray.origin, vector3, Quaternion.LookRotation(vector31), collider.gameObject); if (vm && (component || flag2)) { vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f); } } uLink.BitStream bitStream = new uLink.BitStream(false); if (!flag1) { bitStream.WriteBoolean(false); bitStream.WriteVector3(vector3); } else { bitStream.WriteBoolean(flag1); bitStream.Write <NetEntityID>(netEntityID, new object[0]); bitStream.WriteVector3(vector3); } bitStream.WriteBoolean(flag2); itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream); this.EndSwingWorldAnimations(itemRep); }