private void transferStuckArrows() { if (this.animalArrowSync) { if (this.closestStoredToken == null) { return; } storeLocalMutantInfo2 component = this.closestStoredToken.transform.GetComponent <storeLocalMutantInfo2>(); if (this.closestStoredToken) { if (!this.ast) { this.ast = base.transform.GetComponent <arrowStickToTarget>(); } if (!this.ast) { arrowStickToTarget[] componentsInChildren = base.transform.GetComponentsInChildren <arrowStickToTarget>(true); if (componentsInChildren[0]) { this.ast = componentsInChildren[0]; } } if (this.ast) { int num = 0; foreach (KeyValuePair <Transform, int> keyValuePair in component.stuckArrowsIndex) { if (keyValuePair.Key) { if (this.ast.singleJointMode) { keyValuePair.Key.parent = this.ast.baseJoint; keyValuePair.Key.localPosition = Vector3.zero; keyValuePair.Key.localRotation = component.stuckArrowRot[num]; } else { keyValuePair.Key.parent = this.ast.stickToJoints[keyValuePair.Value]; keyValuePair.Key.localPosition = component.stuckArrowPos[num]; keyValuePair.Key.localRotation = component.stuckArrowRot[num]; } fakeArrowSetup component2 = keyValuePair.Key.GetComponent <fakeArrowSetup>(); if (component2 && BoltNetwork.isRunning) { component2.storedIndex = this.ast.stuckArrows.Count; component2.entityTarget = base.transform.root.GetComponent <BoltEntity>(); } int count = this.ast.stuckArrows.Count; this.ast.stuckArrows.Add(keyValuePair.Key, count); num++; } } } UnityEngine.Object.Destroy(this.closestStoredToken); Scene.SceneTracker.storedRagDollPrefabs.RemoveAll((GameObject o) => o == null); Scene.SceneTracker.storedRagDollPrefabs.TrimExcess(); } } }
public void applyStuckArrowToDummy(Transform arrow, Vector3 pos, Quaternion rot, int index, int arrowType = 0) { if (this.nearestJointOnRagdollMode) { int num = this.returnNearestJointMidPoint(arrow); Vector3 vector = (arrow.position - this.stickToJoints[num].position).normalized; vector = this.stickToJoints[num].position + vector * 0.35f; arrow.parent = this.stickToJoints[num]; arrow.position = vector; arrow.rotation = Quaternion.LookRotation(arrow.position - this.stickToJoints[num].position) * Quaternion.Euler(-90f, 0f, 0f); } else if (this.singleJointMode) { arrow.parent = this.baseJoint; } else { arrow.parent = this.stickToJoints[index]; } if (!this.nearestJointOnRagdollMode) { arrow.localPosition = pos; arrow.localRotation = rot; } if (this.IsCreature) { arrow.localPosition = pos; arrow.localRotation = rot; } int count; if (this.IsCreature) { this.stuckArrows.Add(arrow, index); count = this.stuckArrows.Count; } else { count = this.stuckArrows.Count; this.stuckArrows.Add(arrow, index); } fakeArrowSetup component = arrow.GetComponent <fakeArrowSetup>(); if (component && BoltNetwork.isRunning) { component.storedIndex = count - 1; component.entityTarget = base.transform.root.GetComponent <BoltEntity>(); } if (BoltNetwork.isRunning && BoltNetwork.isServer && this.IsCreature) { bool crossbow = false; if (arrowType == 3) { crossbow = true; } base.StartCoroutine(this.SendArrowMPDelayed(arrow.gameObject, index, (WeaponStatUpgrade.Types)(-1), crossbow)); } }
public override void OnEvent(stuckArrowsSync evnt) { if (!this.ValidateSender(evnt, SenderTypes.Any)) { return; } if (evnt.target) { arrowStickToTarget arrowStickToTarget = evnt.target.GetComponent <arrowStickToTarget>(); if (!arrowStickToTarget) { arrowStickToTarget = evnt.target.GetComponentInChildren <arrowStickToTarget>(); } if (arrowStickToTarget) { if (evnt.removeArrow) { int num = 0; foreach (KeyValuePair <Transform, int> keyValuePair in arrowStickToTarget.stuckArrows) { if (num == evnt.index && keyValuePair.Key) { UnityEngine.Object.Destroy(keyValuePair.Key.gameObject); } num++; } return; } int type = evnt.type; GameObject gameObject; if (type != 1) { gameObject = UnityEngine.Object.Instantiate <GameObject>(arrowStickToTarget.fakeArrowPickup, evnt.target.transform.position, evnt.target.transform.rotation); } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(arrowStickToTarget.fakeArrowBonePickup, evnt.target.transform.position, evnt.target.transform.rotation); } gameObject.transform.parent = arrowStickToTarget.stickToJoints[evnt.index]; gameObject.transform.localPosition = evnt.pos; gameObject.transform.localRotation = evnt.rot; arrowStickToTarget.stuckArrows.Add(gameObject.transform, evnt.index); fakeArrowSetup component = gameObject.GetComponent <fakeArrowSetup>(); if (component && BoltNetwork.isRunning) { component.storedIndex = arrowStickToTarget.stuckArrows.Count - 1; component.entityTarget = evnt.target; } } } }
public bool stickArrowToNearestBone(Transform arrow) { Transform parent = arrow.parent; WeaponStatUpgrade.Types types = (WeaponStatUpgrade.Types)(-1); ItemProperties properties = parent.GetComponent <arrowTrajectory>()._pickup.GetComponent <PickUp>()._properties; if (properties != null && properties.ActiveBonus != (WeaponStatUpgrade.Types)(-1)) { types = properties.ActiveBonus; } GameObject gameObject; if (types != WeaponStatUpgrade.Types.BoneAmmo) { if (types != WeaponStatUpgrade.Types.ModernAmmo) { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowPickup, parent.transform.position, parent.transform.rotation); } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowModernPickup, parent.transform.position, parent.transform.rotation); } } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowBonePickup, parent.transform.position, parent.transform.rotation); } Collider component = gameObject.GetComponent <Collider>(); if (component) { component.enabled = false; } Transform tip = gameObject.GetComponent <fakeArrowSetup>().tip; int num = this.returnNearestJointMidPoint(tip); if (this.singleJointMode) { num = 0; Vector3 vector = (gameObject.transform.position - this.baseJoint.position).normalized; vector = this.baseJoint.position + vector * 0.2f; gameObject.transform.parent = this.baseJoint; gameObject.transform.position = vector; gameObject.transform.rotation = Quaternion.LookRotation(gameObject.transform.position - this.baseJoint.position) * Quaternion.Euler(-90f, 0f, 0f); } else { Transform transform = this.stickToJoints[num]; IEnumerator enumerator = this.stickToJoints[num].GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform2 = (Transform)obj; if (!transform2.GetComponent <MonoBehaviour>()) { transform = transform2; break; } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } Vector3 vector2 = (this.stickToJoints[num].position + transform.position) / 2f; Vector3 vector3 = (gameObject.transform.position - vector2).normalized; vector3 = vector2 + vector3 * 0.35f; gameObject.transform.parent = this.stickToJoints[num]; gameObject.transform.position = vector3; gameObject.transform.rotation = Quaternion.LookRotation(gameObject.transform.position - vector2) * Quaternion.Euler(-90f, 0f, 0f); } bool result = false; if (this.stickToJoints.Length > 0 && this.stickToJoints[num] && this.stickToJoints[num].GetComponent <headShotObject>()) { result = true; } if (!this.stuckArrows.ContainsKey(gameObject.transform)) { this.stuckArrows.Add(gameObject.transform, num); fakeArrowSetup component2 = gameObject.GetComponent <fakeArrowSetup>(); if (component2 && BoltNetwork.isRunning) { component2.storedIndex = this.stuckArrows.Count - 1; component2.entityTarget = base.transform.root.GetComponent <BoltEntity>(); } this.numStuckArrows++; } if (BoltNetwork.isRunning) { BoltEntity component3 = parent.GetComponent <BoltEntity>(); if (component3.isAttached && component3.isOwner) { if (this.IsCreature && BoltNetwork.isServer) { base.StartCoroutine(this.SendArrowMPDelayed(gameObject, num, types)); } else { this.sendArrowMP(gameObject, num, types); } } } return(result); }
private IEnumerator syncRagDollPositions() { yield return(new WaitForFixedUpdate()); float closestDist = float.PositiveInfinity; GameObject closestStoredToken = null; for (int i = 0; i < Scene.SceneTracker.storedRagDollPrefabs.Count; i++) { if (Scene.SceneTracker.storedRagDollPrefabs[i] != null) { float dist = Vector3.Distance(base.transform.position, Scene.SceneTracker.storedRagDollPrefabs[i].transform.position); if (dist < closestDist) { closestDist = dist; closestStoredToken = Scene.SceneTracker.storedRagDollPrefabs[i]; } } } if (closestStoredToken) { storeLocalMutantInfo2 component = closestStoredToken.transform.GetComponent <storeLocalMutantInfo2>(); if (!this.ast) { this.ast = base.transform.GetComponent <arrowStickToTarget>(); } if (!this.ast) { arrowStickToTarget[] componentsInChildren = base.transform.GetComponentsInChildren <arrowStickToTarget>(true); if (componentsInChildren != null && componentsInChildren.Length > 0 && componentsInChildren[0]) { this.ast = componentsInChildren[0]; } } if (this.ast) { int num = 0; foreach (KeyValuePair <Transform, int> keyValuePair in component.stuckArrowsIndex) { if (keyValuePair.Key) { keyValuePair.Key.parent = this.ast.stickToJoints[keyValuePair.Value]; keyValuePair.Key.localPosition = component.stuckArrowPos[num]; keyValuePair.Key.localRotation = component.stuckArrowRot[num]; fakeArrowSetup component2 = keyValuePair.Key.GetComponent <fakeArrowSetup>(); if (component2 && BoltNetwork.isRunning) { component2.storedIndex = this.ast.stuckArrows.Count; component2.entityTarget = base.transform.root.GetComponent <BoltEntity>(); } int count = this.ast.stuckArrows.Count; this.ast.stuckArrows.Add(keyValuePair.Key, count); num++; } } } if (component.fireIndex.Count > 0) { base.StartCoroutine(this.transferClientFire(component)); } if (this.ragDollJoints.Length == 0) { yield break; } CoopMutantMaterialSync component3 = base.GetComponent <CoopMutantMaterialSync>(); if (component3) { component3.setSkinColor(component.matColor); } if (this.rootTr) { this.rootTr.rotation = component.rootRotation; this.rootTr.position = component.rootPosition; if (component.jointAngles.Count > 0) { for (int j = 0; j < this.ragDollJoints.Length; j++) { this.ragDollJoints[j].localRotation = component.jointAngles[j]; } } } } yield return(null); yield break; }
public override void Attached() { if (!this.Creepy) { base.state.Transform.SetTransforms(base.transform); } if (!base.entity.isOwner) { CoopMutantDummyToken coopMutantDummyToken = base.entity.attachToken as CoopMutantDummyToken; if (coopMutantDummyToken != null) { base.transform.localScale = coopMutantDummyToken.Scale; CoopMutantMaterialSync component = base.GetComponent <CoopMutantMaterialSync>(); if (component && coopMutantDummyToken.MaterialIndex >= 0) { component.ApplyMaterial(coopMutantDummyToken.MaterialIndex); component.Disabled = true; if (!this.Creepy) { if (coopMutantDummyToken.OriginalMutant) { Animator componentInChildren = coopMutantDummyToken.OriginalMutant.GetComponentInChildren <Animator>(); AnimatorStateInfo currentAnimatorStateInfo = componentInChildren.GetCurrentAnimatorStateInfo(0); if (this.Replicator) { this.Replicator.ApplyHashToRemote(0, currentAnimatorStateInfo.fullPathHash, false, currentAnimatorStateInfo.normalizedTime, true); } } dummyAnimatorControl component2 = base.GetComponent <dummyAnimatorControl>(); if (component2) { component2.hips.position = coopMutantDummyToken.HipPosition; component2.hips.rotation = coopMutantDummyToken.HipRotation; } float num = float.PositiveInfinity; GameObject gameObject = null; for (int i = 0; i < Scene.SceneTracker.storedRagDollPrefabs.Count; i++) { if (Scene.SceneTracker.storedRagDollPrefabs[i] != null) { float num2 = Vector3.Distance(base.transform.position, Scene.SceneTracker.storedRagDollPrefabs[i].transform.position); if (num2 < num) { num = num2; gameObject = Scene.SceneTracker.storedRagDollPrefabs[i]; } } } if (gameObject) { storeLocalMutantInfo2 component3 = gameObject.transform.GetComponent <storeLocalMutantInfo2>(); this.jointRotations.Clear(); for (int j = 0; j < component3.jointAngles.Count; j++) { this.ragDollJoints[j].localRotation = component3.jointAngles[j]; this.jointRotations.Add(component3.jointAngles[j]); } if (component) { component.setSkinColor(component3.matColor); } if (component3.fireIndex.Count > 0) { base.StartCoroutine(this.transferClientFire(component3)); } if (!this.ast) { this.ast = base.transform.GetComponent <arrowStickToTarget>(); } if (!this.ast) { arrowStickToTarget[] componentsInChildren = base.transform.GetComponentsInChildren <arrowStickToTarget>(true); if (componentsInChildren[0]) { this.ast = componentsInChildren[0]; } } if (this.ast) { int num3 = 0; foreach (KeyValuePair <Transform, int> keyValuePair in component3.stuckArrowsIndex) { if (keyValuePair.Key) { keyValuePair.Key.parent = this.ast.stickToJoints[keyValuePair.Value]; keyValuePair.Key.localPosition = component3.stuckArrowPos[num3]; keyValuePair.Key.localRotation = component3.stuckArrowRot[num3]; fakeArrowSetup component4 = keyValuePair.Key.GetComponent <fakeArrowSetup>(); if (component4 && BoltNetwork.isRunning) { component4.storedIndex = this.ast.stuckArrows.Count; component4.entityTarget = base.transform.root.GetComponent <BoltEntity>(); } int count = this.ast.stuckArrows.Count; this.ast.stuckArrows.Add(keyValuePair.Key, count); num3++; } } } this.doSync = true; } } } if (this.Creepy) { base.StartCoroutine(this.syncRagDollPositions()); } if (!this.Creepy) { CoopMutantPropSync component5 = base.GetComponent <CoopMutantPropSync>(); if (component5) { component5.ApplyPropMask(coopMutantDummyToken.Props); } if (this.RegularParts && this.SkinnyParts) { if (coopMutantDummyToken.Skinny) { this.RegularParts.SetActive(false); this.SkinnyParts.SetActive(true); } else { this.RegularParts.SetActive(true); this.SkinnyParts.SetActive(false); } } } } } }