public CharacterBody SpawnBody(GameObject bodyPrefab, Vector3 position, Quaternion rotation) { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'RoR2.CharacterBody RoR2.CharacterMaster::SpawnBody(UnityEngine.GameObject,UnityEngine.Vector3,UnityEngine.Quaternion)' called on client"); return(null); } if (this.bodyInstanceObject) { Debug.LogError("Character cannot have more than one body at this time."); return(null); } if (!bodyPrefab) { Debug.LogErrorFormat("Attempted to spawn body of character master {0} with no body prefab.", new object[] { base.gameObject }); } if (!bodyPrefab.GetComponent <CharacterBody>()) { Debug.LogErrorFormat("Attempted to spawn body of character master {0} with a body prefab that has no {1} component attached.", new object[] { base.gameObject, typeof(CharacterBody).Name }); } bool flag = bodyPrefab.GetComponent <CharacterDirection>(); GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(bodyPrefab, position, flag ? Quaternion.identity : rotation); CharacterBody component = gameObject.GetComponent <CharacterBody>(); component.masterObject = base.gameObject; component.teamComponent.teamIndex = this.teamIndex; component.SetLoadoutServer(this.loadout); if (flag) { CharacterDirection component2 = gameObject.GetComponent <CharacterDirection>(); float y = rotation.eulerAngles.y; component2.yaw = y; } NetworkConnection clientAuthorityOwner = base.GetComponent <NetworkIdentity>().clientAuthorityOwner; if (clientAuthorityOwner != null) { NetworkServer.SpawnWithClientAuthority(gameObject, clientAuthorityOwner); } else { NetworkServer.Spawn(gameObject); } this.bodyInstanceObject = gameObject; Run.instance.OnServerCharacterBodySpawned(component); return(component); }
// Token: 0x06000CC7 RID: 3271 RVA: 0x0003F628 File Offset: 0x0003D828 private void Simulate(float deltaTime) { Quaternion quaternion = Quaternion.Euler(0f, this.yaw, 0f); if (this.hasEffectiveAuthority) { if (this.driveFromRootRotation) { Quaternion rhs = this.rootMotionAccumulator.ExtractRootRotation(); if (this.targetTransform) { this.targetTransform.rotation = quaternion * rhs; float y = this.targetTransform.rotation.eulerAngles.y; this.yaw = y; float angle = 0f; if (this.moveVector.sqrMagnitude > 0f) { angle = Util.AngleSigned(Vector3.ProjectOnPlane(this.moveVector, Vector3.up), this.targetTransform.forward, -Vector3.up); } int num = CharacterDirection.PickIndex(angle); CharacterDirection.turnAnimatorParamsSets[num].Apply(this.modelAnimator); } } this.targetVector = this.moveVector; this.targetVector.y = 0f; if (this.targetVector != Vector3.zero && deltaTime != 0f) { this.targetVector.Normalize(); Quaternion quaternion2 = Util.QuaternionSafeLookRotation(this.targetVector, Vector3.up); float num2 = Mathf.SmoothDampAngle(this.yaw, quaternion2.eulerAngles.y, ref this.yRotationVelocity, 360f / this.turnSpeed * 0.25f, float.PositiveInfinity, deltaTime); quaternion = Quaternion.Euler(0f, num2, 0f); this.yaw = num2; } if (this.targetTransform) { this.targetTransform.rotation = quaternion; } } }