using System; using System.Collections.Generic; using UnityEngine; using XUtliPoolLib; namespace XMainClient { internal sealed class XPlayer : XRole { public XRole WatchTo { get { return (this._watch_to != null && !this._watch_to.Deprecated) ? this._watch_to : null; } } public XLocateTargetComponent TargetLocated { get { return this._located_target; } } public bool IsCorrectingMe { get { return this._correct_me; } } public uint[] SkillSlot { get { bool flag = base.Skill != null && base.Skill.IsSkillReplaced; uint[] result; if (flag) { result = base.Skill.ReplacedSlot; } else { result = this.Attributes.skillSlot; } return result; } } public XPlayerAttributes PlayerAttributes { get { return this.Attributes as XPlayerAttributes; } } private XLocateTargetComponent _located_target = null; private XRole _watch_to = null; private IXPlayerAction _action = null; private bool _correct_me = false; public static int PlayerLayer = LayerMask.NameToLayer("Player"); public override bool Initilize(int flag) { base.Initilize(flag); this._xobject.Tag = "Player"; this._eEntity_Type |= XEntity.EnitityType.Entity_Player; this._layer = XPlayer.PlayerLayer; this._using_cc_move = true; this._client_predicted = true; this._action = XSingleton.singleton.AttachInterface(1u, new XPlayerAction()); XSingleton.singleton.AttachInterface(XSingleton.singleton.XHash("IAssociatedCamera"), new XAssociatedCamera()); bool flag2 = !XSingleton.singleton.bSpectator; if (flag2) { XSingleton.singleton.CreateComponent(this, XActionGeneratorComponent.uuID); bool flag3 = XSingleton.singleton.SceneCanNavi(XSingleton.singleton.SceneID); if (flag3) { this._nav = (XSingleton.singleton.CreateComponent(this, XNavigationComponent.uuID) as XNavigationComponent); } bool flag4 = XSingleton.singleton.CanAutoPlay(XSingleton.singleton.SceneID) && this._xobject.IsNotEmptyObject; if (flag4) { bool flag5 = this._ai == null; if (flag5) { this._ai = (XSingleton.singleton.CreateComponent(this, XAIComponent.uuID) as XAIComponent); } bool flag6 = this._nav == null; if (flag6) { this._nav = (XSingleton.singleton.CreateComponent(this, XNavigationComponent.uuID) as XNavigationComponent); } } } bool flag7 = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall && XSingleton.singleton.SpecifiedTargetLocatedRange(XSingleton.singleton.SceneID) != 0f; if (flag7) { this._located_target = (XSingleton.singleton.CreateComponent(this, XLocateTargetComponent.uuID) as XLocateTargetComponent); } return true; } public void UpdatePlayerAttr(XPlayerAttributes attr) { this._attr = attr; } public override void OnCreated() { XSingleton.singleton.Player = this; bool flag = this.Attributes.SkillLevelInfo != null; if (flag) { this.Attributes.SkillLevelInfo.RefreshSelfLinkedLevels(this); } base.OnCreated(); } public override void OnDestroy() { XSingleton.singleton.Player = null; XSingleton.singleton.DetachInterface(1u); XSingleton.singleton.DetachInterface(XSingleton.singleton.XHash("IAssociatedCamera")); this._action = null; this._watch_to = null; base.OnDestroy(); } public override void Dying() { base.Dying(); } public override void Revive() { base.Revive(); XSingleton.singleton.OnPlayerRevive(); } public void PreUpdate() { this._action.RefreshPosition(); } public void WatchIt(XRole role) { this._watch_to = role; this._net.Pause = true; XSpectateSceneDocument specificDocument = XDocuments.GetSpecificDocument(XSpectateSceneDocument.uuID); specificDocument.ChangeSpectator(role); XGuildArenaBattleDocument specificDocument2 = XDocuments.GetSpecificDocument(XGuildArenaBattleDocument.uuID); specificDocument2.ChangeSpectator(role); this.UpdateWatcher(); XCameraSoloComponent solo = XSingleton.singleton.GameCamera.Solo; bool flag = solo == null; if (!flag) { solo.Stop(); XSingleton.singleton.GameCamera.TrySolo(); } } public override void OnTransform(uint to) { base.OnTransform(to); XBattleSkillDocument specificDocument = XDocuments.GetSpecificDocument(XBattleSkillDocument.uuID); bool flag = specificDocument != null; if (flag) { specificDocument.ResetAll(XSingleton.singleton.SceneReady && base.IsTransform, true); } } public override void UpdateWatcher() { bool bSpectator = XSingleton.singleton.bSpectator; if (bSpectator) { bool flag = this._watch_to != null; if (flag) { bool deprecated = this._watch_to.Deprecated; if (deprecated) { this._watch_to = null; } else { base.MoveObj.Position = this._watch_to.MoveObj.Position; base.MoveObj.Rotation = this._watch_to.MoveObj.Rotation; } } } } protected override void PositionTo(Vector3 pos) { base.PositionTo(pos); this._correct_me = false; this._action.RefreshPosition(); } public override void CorrectMe(Vector3 pos, Vector3 face, bool reconnected = false, bool fade = false) { XSingleton.singleton.Empty(); bool flag = XSingleton.singleton.bSpectator && XSingleton.singleton.bSceneServerReady; if (!flag) { this._correct_me = true; base.CorrectMe(pos, face, reconnected, fade); } } public void OnGamePause(bool pause) { if (pause) { XSingleton.singleton.Cancel(); base.Net.ReportMoveAction(Vector3.zero, 0.0); XSingleton.singleton.Flush(true); XSingleton.singleton.AddLog("Player to BackGround.", null, null, null, null, null, XDebugColor.XDebug_None); } } protected override void Move() { bool bSpectator = XSingleton.singleton.bSpectator; if (bSpectator) { this.UpdateWatcher(); } else { Vector3 hitNormal = XSingleton.singleton.GameCamera.Collision.HitNormal; hitNormal.y = 0f; Vector3 movement = this._movement; movement.y = 0f; bool flag = hitNormal.sqrMagnitude > 0f && movement.sqrMagnitude > 0f && Vector3.Angle(movement, hitNormal) > 90f; if (flag) { this.EdgeDetection(this.EngineObject.Forward, ref movement); float num = Vector3.SqrMagnitude(XSingleton.singleton.GameCamera.CameraTrans.position - this.EngineObject.Position); bool flag2 = num < 1f; if (flag2) { this.ProjectNormal(hitNormal, ref movement); } this._movement.x = movement.x; this._movement.z = movement.z; } base.Move(); this.MoveLateUpdate(); } } private void MoveLateUpdate() { bool flag = XSingleton.singleton.SyncMode && !XStateMgr.IsUnBattleState(base.Machine.Current); if (!flag) { List opponent = XSingleton.singleton.GetOpponent(this); for (int i = 0; i < opponent.Count; i++) { Vector3 position = base.MoveObj.Position; bool isRole = opponent[i].IsRole; if (!isRole) { bool flag2 = (opponent[i].IsPuppet || opponent[i].IsSubstance) && !XEntity.ValideEntity(opponent[i]); if (!flag2) { bool flag3 = opponent[i].Skill != null && opponent[i].Skill.IsCasting() && opponent[i].Skill.CurrentSkill.MainCore.Soul.IgnoreCollision; if (!flag3) { XOthersAttributes xothersAttributes = opponent[i].Attributes as XOthersAttributes; bool flag4 = xothersAttributes == null || !xothersAttributes.Blocked; if (!flag4) { bool flag5 = opponent[i].MoveObj.Position.y > position.y + base.Height; if (!flag5) { bool flag6 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge; if (flag6) { SeqListRef hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders; for (int j = 0; j < hugeMonsterColliders.Count; j++) { float num = hugeMonsterColliders[j, 2] * opponent[i].Scale; this.A(position, opponent[i].HugeMonsterColliderCenter(j), base.Radius + num); } } else { this.A(position, opponent[i].RadiusCenter, base.Radius + opponent[i].Radius); } } } } } } } } } private void A(Vector3 me, Vector3 it, float r) { Vector3 v = me - it; v.y = 0f; float sqrMagnitude = v.sqrMagnitude; bool flag = sqrMagnitude - r * r < -0.001f; if (flag) { Vector3 vector = XSingleton.singleton.Horizontal(v); Vector3 vector2 = it + vector * r; float y = vector2.y; bool flag2 = XSingleton.singleton.TryGetTerrainY(vector2, out y) && y >= 0f; if (flag2) { bool flag3 = XSingleton.singleton.CheckDynamicBlock(base.MoveObj.Position, vector2); if (flag3) { bool standOn = base.StandOn; if (standOn) { vector2.y = y + 0.25f; base.MoveObj.Position = vector2; base.MoveObj.Move(Vector3.down); } else { vector2.y = me.y; base.MoveObj.Position = vector2; } } } } } private bool EdgeDetection(Vector3 forward, ref Vector3 move) { RaycastHit raycastHit; bool flag = this.RayDetection(forward, out raycastHit); bool result; if (flag) { this.ProjectNormal(raycastHit.normal, ref move); result = true; } else { result = false; } return result; } private void ProjectNormal(Vector3 normal, ref Vector3 move) { Vector3 forward = Vector3.forward; Vector3 vector = normal; Vector3.OrthoNormalize(ref vector, ref forward); move = Vector3.Project(move, forward); } private bool RayDetection(Vector3 ray, out RaycastHit hit) { int num = 513; Vector3 position = this.EngineObject.Position; position.y += base.Height; return Physics.Raycast(position, ray, out hit, 1f, num); } public override bool CastFakeShadow() { return true; } } }