public IEnumerator <float> ResurrectCoroutine(Creature creature, float resurrectionTime, float cooldownTime) { if (isResurrecting == false) { float time = 0; bool failedResurrect = false; isResurrecting = true; var setting = new VfxUtils.VfxSettings { thickness = VfxUtils.defaultVfxSettings.thickness / 2f, periodicTime = VfxUtils.defaultVfxSettings.periodicTime / 2f }; vfx.SetVfx(1f, setting); //vfxObj.transform.Rotate(vfxObj.transform.InverseTransformDirection(Vector3.up), 180); PlayerControl.GetHand(spellCaster.bodyHand.side).HapticPlayClip(new GameData.HapticClip(AnimationCurve.Linear(0f, 0.05f, 1f, 0.2f), 1f, resurrectionTime)); while (time < 1f) { time += Time.fixedDeltaTime / resurrectionTime; if (!failedResurrect) { HandPoseBend handPose = HandPoseChecker(spellCaster); if (!(handPose == HandPoseBend.FlatPalm) || !(Vector3.Angle(spellCaster.transform.TransformDirection(Vector3.down).normalized, Vector3.down) < 30f) || !(Vector3.Distance(creature.ragdoll.hipsPart.transform.position.ToXZ(), spellCaster.transform.position.ToXZ()) < 1f) || !(Mathf.Abs(creature.ragdoll.hipsPart.transform.position.y - spellCaster.transform.position.y) < 0.6f)) { failedResurrect = true; //vfxObj.transform.Rotate(vfxObj.transform.InverseTransformDirection(Vector3.up), 180); PlayerControl.GetHand(spellCaster.bodyHand.side).hapticPlayClipEnabled = false; Timing.RunCoroutine(CooldownResurrect(cooldownTime)); } } yield return(Time.fixedDeltaTime); } if (!failedResurrect) { PlayerControl.GetHand(spellCaster.bodyHand.side).HapticPlayClip(new GameData.HapticClip(AnimationCurve.Linear(0f, 0.5f, 1f, 0.5f), 1f, resurrectionTime)); //vfxObj.transform.Rotate(vfxObj.transform.InverseTransformDirection(Vector3.up), 180); creature.ragdoll.SetState(Creature.State.Alive); creature.ragdoll.SetState(Creature.State.Destabilized); creature.ragdoll.knockoutDuration = 0.1f; creature.health.Resurrect(creature.health.maxHealth, Creature.player); creature.SetFaction(2); creature.StartBrain(); lastHandPose = HandPoseBend.Default; Timing.RunCoroutine(CooldownResurrect(cooldownTime)); } } }
public override void UpdateCaster() { base.UpdateCaster(); gesture[(int)spellCaster.bodyHand.side].GestureUpdate(); if (spellCaster.bodyHand.interactor.grabbedHandle != null) { vfx.ResetVfx(0.3f); return; } if (spellCaster.telekinesis.catchedHandle != null && spellCaster.telekinesis.catchedHandle.item.data.id == "WaterBendDynamicProjectile") { var vel = spellCaster.telekinesis.catchedHandle.item.rb.velocity; vfx.SetRadius(Mathf.Min(1 / vel.magnitude, 1f)); return; } HandPoseBend handPose = HandPoseChecker(spellCaster); if (!isResurrecting && handPose != lastHandPose) { VfxUtils.VfxSettings setting; switch (handPose) { case HandPoseBend.IndexPointing: case HandPoseBend.FlatPalm: setting = new VfxUtils.VfxSettings { rotDir = Quaternion.Euler(0, 0, 0), size = VfxUtils.defaultVfxSettings.size / 4f, localPosition = VfxUtils.defaultVfxSettings.localPosition / 4f, }; break; default: setting = VfxUtils.defaultVfxSettings; break; } vfx.SetVfx(1.6f, setting); lastHandPose = handPose; //Debug.Log(handPose); } if (handPose == HandPoseBend.FlatPalm && Vector3.Angle(spellCaster.transform.TransformDirection(Vector3.down).normalized, Vector3.down) < 30f) { foreach (Creature creature in Creature.list) { bool sliced = false; foreach (var part in creature.ragdoll.parts) { if (part.isSliced == true) { sliced = true; break; } } if (creature == Player.local.body.creature || sliced) { continue; } if (!(Vector3.Distance(creature.ragdoll.hipsPart.transform.position.ToXZ(), spellCaster.transform.position.ToXZ()) <= 1f)) { continue; } if (Mathf.Abs(creature.ragdoll.hipsPart.transform.position.y - spellCaster.transform.position.y) > 0.6f) { continue; } Resurrect(creature); } } }