protected override void Update() { if (FSM != null) { Object.Destroy(FSM); } else if (!string.IsNullOrEmpty(FSMName)) { PlayMakerFSM[] components = GetTarget().GetComponents <PlayMakerFSM>(); for (int i = 0; i < components.Length; i++) { if (components[i].FsmName == FSMName) { Object.Destroy(components[i]); } } } else if (IncomingUserData != null && IncomingUserData.GetType() == typeof(PlayMakerFSM)) { Object.Destroy((PlayMakerFSM)IncomingUserData); } else { PlayMakerFSM[] components = GetTarget().GetComponents <PlayMakerFSM>(); for (int i = 0; i < components.Length; i++) { Object.Destroy(components[i]); } } Completed(); }
public async Task <ActionResult> SignUpUser(IncomingUserData userData) { //Check to see if the User Name already exists var userExists = _context.Users.Any(user => user.UserName == userData.UserName); //If User Already Exists, return BadRequest if (userExists) { return(BadRequest("User Name already in use")); } //If First Name is blank, return BadRequest (Home page uses this property) if (userData.FirstName == "") { return(BadRequest("First Name cannot be blank")); } //If User Name is blank, return BadRequest if (userData.UserName == "") { return(BadRequest("User Name cannot be blank")); } //If Password is blank, return BadRequest if (userData.Password == "") { return(BadRequest("Password cannot be blank")); } //Otherwise, proceed to create new User var newUser = new User { FirstName = userData.FirstName, LastName = userData.LastName, UserName = userData.UserName, IsDemoAccount = false, }; //Hash new users password var hashedPassword = new PasswordHasher <User>().HashPassword(newUser, userData.Password); newUser.HashedPassword = hashedPassword; //Save User _context.Users.Add(newUser); await _context.SaveChangesAsync(); //Generate and return JWT Token return(Ok(new { Token = CreateJWT(newUser), UserInfo = newUser })); }
protected override void Update() { if (TargetRotation != null) { actionTarget.transform.rotation = TargetRotation.rotation; } else if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { Vector3 vector = (Vector3)IncomingUserData; vector.y = 0f; if (vector == Vector3.zero) { vector = actionTarget.transform.forward; } actionTarget.transform.rotation = Quaternion.LookRotation(vector); } else if (motionTracker != null) { Vector3 normalized = motionTracker.FrameVelocity.normalized; if (normalized != Vector3.zero) { Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; zero = ((!(normalized != Vector3.up) || !(normalized != Vector3.down)) ? Vector3.Cross(Vector3.back, normalized) : Vector3.Cross(Vector3.up, normalized)); zero2 = Vector3.Cross(zero, normalized); if (runController != null) { runController.SnapToFacing(Quaternion.LookRotation(zero2, normalized) * Vector3.forward, normalized); } else { actionTarget.transform.rotation = Quaternion.LookRotation(zero2, normalized); } } isUsingControllerVelocity = true; } if (!Loop) { Completed(); } }
protected override void OnEnable() { runController = GetComponent <RunController>(); thisTransform = base.transform; prevPos = thisTransform.position; if (runController != null) { runController.ResetState(); runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = true, IgnoreRotation = true, IgnoreGravity = true, IgnoreTranslation = true }; } pilot = PilotTransform; if (pilot == null && IncomingUserData != null && IncomingUserData.GetType() == typeof(GameObject)) { pilot = ((GameObject)IncomingUserData).transform; } base.OnEnable(); }
protected override void OnEnable() { fsm = FSM; if (fsm == null) { if (!string.IsNullOrEmpty(FSMName)) { PlayMakerFSM[] components = GetTarget().GetComponents <PlayMakerFSM>(); for (int i = 0; i < components.Length; i++) { if (components[i].FsmName == FSMName) { fsm = components[i]; break; } } } else if (IncomingUserData != null && IncomingUserData.GetType() == typeof(PlayMakerFSM)) { fsm = (PlayMakerFSM)IncomingUserData; } } base.OnEnable(); }
protected override void Update() { GameObject target = GetTarget(); if (target != null) { Vector3 vector = base.transform.forward; if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { vector = ((Vector3)IncomingUserData).normalized; } else if (DirectionY != null) { vector = DirectionY.up; } else if (DirectionZ != null) { vector = DirectionZ.forward; } else if (DirectionTo != null) { vector = (DirectionTo.position - target.transform.position).normalized; } else if (Direction != Vector3.zero) { vector = Direction; } Vector3 vector2 = vector * Magnitude + AddDirection * AddMagnitude; bool flag = LocomotionHelper.IsCurrentControllerOfType <SlideController>(target); Rigidbody component = target.GetComponent <Rigidbody>(); if (!flag && component != null) { if (StartTransform != null) { component.transform.position = StartTransform.position; component.transform.rotation = StartTransform.rotation; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.WakeUp(); } component.AddForce(vector2, ForceMode.VelocityChange); } else { if (SetRunLocomotion && (!PreserveTubing || !flag)) { LocomotionHelper.SetCurrentController <RunController>(target); flag = false; } if (!flag && StartTransform != null) { target.transform.position = StartTransform.position; target.transform.rotation = StartTransform.rotation; } LocomotionController currentController = LocomotionHelper.GetCurrentController(target); if (currentController != null) { if (currentController is RunController) { ((RunController)currentController).ClearAllVelocityInputs(); } currentController.SetForce(vector2, base.gameObject); } } } Completed(); }
protected override void Update() { if (base.Complete) { return; } GameObject gameObject = null; Vector3 vector = Vector3.zero; Quaternion quaternion = Quaternion.identity; bool flag = false; if (SpawnTransform == null) { if (SpawnAtOwnerTransform) { vector = GetTarget().transform.position; quaternion = GetTarget().transform.rotation; flag = true; } } else { vector = SpawnTransform.position; quaternion = SpawnTransform.rotation; flag = true; } if (ObjectPool != null) { gameObject = ((!flag) ? ObjectPool.Spawn() : ObjectPool.Spawn(vector, quaternion)); } else if (ObjectPrefab != null) { if (flag) { gameObject = UnityEngine.Object.Instantiate(ObjectPrefab); gameObject.transform.position = quaternion * ObjectPrefab.transform.position + vector; gameObject.transform.rotation = quaternion * ObjectPrefab.transform.rotation; } else { GameObject target = GetTarget(); Transform transform = target.transform; gameObject = UnityEngine.Object.Instantiate(ObjectPrefab); gameObject.transform.position = transform.rotation * gameObject.transform.position + transform.position; gameObject.transform.rotation *= transform.rotation; gameObject.transform.parent = transform; } if (ParentToOwner) { GameObject target = GetTarget(); Transform transform = target.transform; gameObject.transform.parent = transform; } } if (gameObject != null) { Rigidbody component = gameObject.GetComponent <Rigidbody>(); if (component != null) { if (TransferOwnerMomentum) { MotionTracker component2 = GetComponent <MotionTracker>(); if (component2 != null) { component.AddForce(component2.Velocity, ForceMode.VelocityChange); } } else if (ImpulseMagnitude != 0f) { float num = ImpulseMagnitude + (MagNoise - 2f * MagNoise * UnityEngine.Random.value); Vector3 dir = ImpulseDirection; if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { dir = ((Vector3)IncomingUserData).normalized; } if (dir == Vector3.zero) { dir = gameObject.transform.forward; } if (DirNoise != 0f) { Vector3 morphedDirection = GetMorphedDirection(ref dir, DirNoise, UnityEngine.Random.value, UnityEngine.Random.value); Quaternion quaternion2 = Quaternion.LookRotation(dir); dir = quaternion2 * morphedDirection; } dir.Normalize(); component.AddForce(dir * num, ForceMode.VelocityChange); } } } if (Owner != null) { Completed(gameObject); return; } Log.LogError(this, "Owner was null. Cannot remove from Sequencer. Action will now be ignored."); base.Complete = true; }
private IEnumerator doMoveTo() { if (runController != null && runController.enabled) { Animator anim = actionTarget.GetComponent <Animator>(); Transform tempTransform = null; RunController.ControllerBehaviour oldRunBehaviour = runController.Behaviour; runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = false, IgnoreGravity = false, IgnoreRotation = false, IgnoreTranslation = false, IgnoreJumpRequests = true, IgnoreStickInput = true, Style = Style }; bool runControllerBehaviourWasSet = true; AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo)) { yield return(null); animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); } runController.ResetMomentum(); if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { Vector3 vector = (Vector3)IncomingUserData; Vector3 vector2 = vector - actionTarget.transform.position; vector2.y = 0f; if (vector2 == Vector3.zero) { vector2 = base.transform.forward; } tempTransform = new GameObject().transform; tempTransform.rotation = Quaternion.LookRotation(vector2); tempTransform.position = vector; Waypoints.Clear(); Waypoints.Add(tempTransform); } if (Waypoints.Count > 0) { float distThresholdSq = DistanceThreshold * DistanceThreshold; float prevDistSq = float.PositiveInfinity; float elapsedTime = 0f; bool done = false; int curWaypoint2 = 0; do { if (thisTransform.IsDestroyed() || actionTarget.IsDestroyed()) { Log.LogError(this, "Aborting LocomoteToAction as an object has been destroyed"); break; } if (UseShortestPath) { curWaypoint2 = FindFarthestReachableWaypoint(curWaypoint2); } Vector3 toTarget = Waypoints[curWaypoint2].position - thisTransform.position; toTarget.y = 0f; float distSq = toTarget.sqrMagnitude; if (distSq <= distThresholdSq || distSq > prevDistSq) { curWaypoint2++; if (curWaypoint2 >= Waypoints.Count) { done = true; } else { toTarget = Waypoints[curWaypoint2].position - thisTransform.position; toTarget.y = 0f; runController.Steer(toTarget.normalized); } } else { runController.Steer(toTarget.normalized); } elapsedTime += Time.deltaTime; if (elapsedTime > 5f) { done = true; } yield return(null); }while (!done); curWaypoint2 = Waypoints.Count - 1; runController.Steer(Vector3.zero); if (DontSnapYPosAtEnd) { Vector3 position = Waypoints[curWaypoint2].position; position.y = thisTransform.position.y; runController.SnapToPosition(position); } else { runController.SnapToPosition(Waypoints[curWaypoint2].position); } if (SnapRotAtEnd) { runController.SnapToFacing(Waypoints[curWaypoint2].forward); } } if (tempTransform != null) { Object.Destroy(tempTransform.gameObject); Waypoints.Clear(); } if (runControllerBehaviourWasSet) { runController.Behaviour = oldRunBehaviour; } } Completed(); }