private void SplitPrimaryAndDeputyGameObject() { _needAssemble = true; if (null != PrimaryAsGameObject) { PrimaryAsGameObject.transform.SetParent(null, false); BoneTool.CacheTransform(PrimaryAsGameObject); } if (null != DeputyAsGameObject) { DeputyAsGameObject.transform.SetParent(null, false); BoneTool.CacheTransform(DeputyAsGameObject); } }
private static void SetObjParam(GameObject obj, int layer) { if (null == obj) { return; } BoneTool.CacheTransform(obj); var childCount = obj.transform.childCount; for (var i = 0; i < childCount; ++i) { obj.transform.GetChild(i).gameObject.layer = layer; } AppearanceUtils.EnableShadow(obj); ReplaceMaterialShaderBase.ResetShader(obj); }
private void OnPartLoaded(T go, WeaponPartLocation partType) { BoneTool.CacheTransform(go as GameObject); _partGoDic[partType] = go; if (null != _weaponGo) { Attach(partType, go, _weaponGo); } else { _waitPartGoDic[partType] = go; } if (partType.Equals(WeaponPartLocation.Scope)) { _weaponModelAssemblyController.RefreshRemovableAttachment(_weaponGo as GameObject, true); } }
private void SetObjParam(GameObject obj, int layer) { if (obj == null) { return; } BoneTool.CacheTransform(obj); var childCount = obj.transform.childCount; for (var i = 0; i < childCount; ++i) { obj.transform.GetChild(i).gameObject.layer = layer; } AppearanceUtils.EnableShadow(obj); _dataSource.ResetWardrobeShader(obj, _dataSource._p1Index); }
public void OnLoadSuccess <T>(T source, UnityObject unityObj) { var go = unityObj.AsGameObject; if (null == go) { return; } BoneTool.CacheTransform(go); if (_dataSource._p1Index == _index) { AppearanceUtils.DisableRender(_dataSource._propObjP1); _dataSource._propObjP1 = go; if (!_dataSource.IsFirstPerson) { AppearanceUtils.DisableRender(go); _dataSource.AddRecycleObject(unityObj); } } else if (_dataSource._p3Index == _index) { AppearanceUtils.DisableRender(_dataSource._propObjP3); _dataSource._propObjP3 = go; if (_dataSource.IsFirstPerson) { AppearanceUtils.DisableRender(go); _dataSource.AddRecycleObject(unityObj); } } else { AppearanceUtils.DisableRender(go); _dataSource.AddRecycleObject(unityObj); } _dataSource.MountPropToHand(_index); }
private void OnWeaponLoaded(T go) { #if !UnitTest if (Logger.IsDebugEnabled) { Logger.DebugFormat("on weapon loaded"); } #endif _weaponGo = go; BoneTool.CacheTransform(go as GameObject); if (_waitPartGoDic.Count > 0) { foreach (var pair in _waitPartGoDic) { Attach(pair.Key, pair.Value, _weaponGo); } _waitPartGoDic.Clear(); } else { ShowWeapon(go); } }
public void OnLoadSucc(PlayerEntity player, UnityObject unityObj) { GameObject go = unityObj; HandleLoadedModel(player, go); if (player.hasFirstPersonModel) { _assetManager.Recycle(player.firstPersonModel.UnityObjectValue); player.RemoveAsset(player.firstPersonModel.UnityObjectValue); } player.ReplaceFirstPersonModel(go, unityObj); player.AddAsset(unityObj); player.appearanceInterface.FirstPersonAppearance = new FirstPersonAppearanceManager(player.firstPersonAppearance); go.name = "P1_" + player.entityKey; go.transform.SetParent(player.RootGo().transform); go.transform.localPosition = new Vector3(0, player.firstPersonAppearance.FirstPersonHeight, player.firstPersonAppearance.FirstPersonForwardOffset); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; Logger.InfoFormat("P1 loaded: {0}", player.entityKey); player.ReplaceFirstPersonAnimator(go.GetComponent <Animator>()); var ik = go.AddComponent <PlayerIK>(); ik.SetAnimator(AvatarIKGoal.LeftHand, player.firstPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.FirstPersonIKPassLayer); ik.SetAnimator(AvatarIKGoal.RightHand, player.firstPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.FirstPersonIKPassLayer); BoneTool.CacheTransform(go); if (player.isFlagSelf) { var animationEvent = go.AddComponent <AnimationClipEvent>(); animationEvent.Player = player; player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent .InterruptAnimationEventFunc); } else { go.AddComponent <ThirdPersonAnimationClipEvent>(); } player.firstPersonAnimator.UnityAnimator.Update(0); player.appearanceInterface.Appearance.SetFirstPersonCharacter(go); player.appearanceInterface.FirstPersonAppearance.SetFirstPersonCharacter(go); player.appearanceInterface.Appearance.SetAnimatorP1(player.firstPersonAnimator.UnityAnimator); player.stateInterface.State.SetName(player.RootGo().name); player.characterBoneInterface.CharacterBone.SetFirstPersonCharacter(go); player.ReplaceFpAnimStatus( NetworkAnimatorUtil.CreateAnimatorLayers(player.firstPersonAnimator.UnityAnimator), NetworkAnimatorUtil.GetAnimatorParams(player.firstPersonAnimator.UnityAnimator)); // 禁用非可见状态下的动画更新 if (!player.isFlagSelf) { player.firstPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } else { player.firstPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } }
public void OnLoadSucc(PlayerEntity player, UnityObject unityObj) { if (null == unityObj || null == unityObj.AsGameObject) { Logger.ErrorFormat("CharacterLog-- playerEntity: {0} unityObj is Null", player.entityKey); } GameObject go = unityObj; if (player.hasThirdPersonModel) { _assetManager.Recycle(player.thirdPersonModel.UnityObjectValue); player.RemoveAsset(player.thirdPersonModel.UnityObjectValue); } player.ReplaceThirdPersonModel(go, unityObj); var provider = SingletonManager.Get <HitBoxTransformProviderCache>() .GetProvider(player.thirdPersonModel.Value); HitBoxComponentUtility.InitHitBoxComponent(player.entityKey.Value, player, provider); RemoveRagdollOnServerSide(go, provider.GetHitBoxColliders().Values.ToList()); HandleLoadedModel(player, go); InitCharacterControllerSetting(player); player.AddAsset(unityObj); go.name = go.name.Replace("(Clone)", ""); go.transform.SetParent(GetThirdModelParent(player.RootGo().transform)); go.transform.localPosition = new Vector3(0, 0, 0); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; Logger.InfoFormat("CharacterLog-- P3 loaded: {0}", player.entityKey); BoneTool.CacheTransform(go); player.ReplaceBones(null, null, null); player.bones.Head = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterHeadBoneName); player.bones.Spine = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterSpineName); player.ReplaceThirdPersonAnimator(go.GetComponent <Animator>()); if (player.hasFsmInputRelateInterface) { player.fsmInputRelateInterface.Relate.InitLimit(); player.fsmInputRelateInterface.Relate.CreateAllLimitFsmInput(player.thirdPersonAnimator.UnityAnimator); } var ik = go.AddComponent <PlayerIK>(); ik.SetAnimator(AvatarIKGoal.LeftHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); ik.SetAnimator(AvatarIKGoal.RightHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); if (player.isFlagSelf) { var animationEvent = go.AddComponent <AnimationClipEvent>(); animationEvent.Player = player; player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent .InterruptAnimationEventFunc); } else { go.AddComponent <ThirdPersonAnimationClipEvent>(); } // 设置大厅传入的roleId和avatarId player.appearanceInterface.Appearance.SetRoleModelIdAndInitAvatar(player.playerInfo.RoleModelId, player.playerInfo.AvatarIds); player.characterControllerInterface.CharacterController.SetCharacterRoot(player.characterContoller.Value .gameObject); player.appearanceInterface.Appearance.SetRootGo(player.RootGo()); player.appearanceInterface.Appearance.SetThirdPersonCharacter(go); player.appearanceInterface.Appearance.SetRagDollComponent(player.ragDoll); player.characterControllerInterface.CharacterController.SetThirdModel(player.thirdPersonModel.Value); player.characterBoneInterface.CharacterBone.SetCharacterRoot(player.characterContoller.Value .gameObject); player.characterBoneInterface.CharacterBone.SetThirdPersonCharacter(go); ForceCrouch(player.thirdPersonAnimator.UnityAnimator); player.characterBoneInterface.CharacterBone.SetStableCrouchPelvisRotation(); ForceStand(player.thirdPersonAnimator.UnityAnimator); player.characterBoneInterface.CharacterBone.SetStableStandPelvisRotation(); player.appearanceInterface.Appearance.SetAnimatorP3(player.thirdPersonAnimator.UnityAnimator); player.appearanceInterface.Appearance.PlayerReborn(); player.characterControllerInterface.CharacterController.PlayerReborn(); if (player.hasStateInterface) { player.stateInterface.State.PlayerReborn(); } if (player.hasPlayerInfo) { player.playerInfo.InitTransform(); } player.ReplaceNetworkAnimator( NetworkAnimatorUtil.CreateAnimatorLayers(player.thirdPersonAnimator.UnityAnimator), NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator)); player.networkAnimator.SetEntityName(player.entityKey.ToString()); player.ReplaceOverrideNetworkAnimator(); if (SharedConfig.IsServer) { player.ReplaceNetworkAnimatiorServerTime(0); } // 禁用非可见状态下的动画更新,在获取Stable状态之后 if (SharedConfig.IsServer || !player.isFlagSelf) { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } else { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } //人物变身、换肤时,清空特效数据 if (player.hasEffects) { player.effects.ResetEffects(); } // 处理显隐 if (player.hasGamePlay) { PlayerEntityUtility.SetVisibility(go, player.gamePlay.Visibility); } }
public void Init(IEntity entity, AssetStatus status) { var player = entity as PlayerEntity; var obj = status.Object.AsGameObject; obj.layer = UnityLayerManager.GetLayerIndex(EUnityLayerName.Player); PlayerEntityUtility.DisableCollider(obj.transform); var go = obj; player.AddFirstPersonModel(go); player.appearanceInterface.FirstPersonAppearance = new FirstPersonAppearanceManager(player.firstPersonAppearance); go.name = "P1_" + player.entityKey; go.transform.SetParent(player.playerResource.Root.transform); go.transform.localPosition = new Vector3(0, player.firstPersonAppearance.FirstPersonHeight, player.firstPersonAppearance.FirstPersonForwardOffset); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; Logger.InfoFormat("P1 loaded: {0}", player.entityKey); player.AddFirstPersonAnimator(go.GetComponent <Animator>()); var ik = go.AddComponent <PlayerIK>(); ik.SetAnimator(AvatarIKGoal.LeftHand, player.firstPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.FirstPersonIKPassLayer); ik.SetAnimator(AvatarIKGoal.RightHand, player.firstPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.FirstPersonIKPassLayer); BoneTool.CacheTransform(go); if (player.isFlagSelf) { var animationEvent = go.AddComponent <AnimationClipEvent>(); animationEvent.Player = player; player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent.InterruptAnimationEventFunc); } else { go.AddComponent <ThirdPersonAnimationClipEvent>(); } player.firstPersonAnimator.UnityAnimator.Update(0); player.appearanceInterface.Appearance.SetFirstPersonCharacter(go); player.appearanceInterface.FirstPersonAppearance.SetFirstPersonCharacter(go); player.appearanceInterface.Appearance.SetAnimatorP1(player.firstPersonAnimator.UnityAnimator); player.stateInterface.State.SetName(player.RootGo().name); player.characterBoneInterface.CharacterBone.SetFirstPersonCharacter(go); if (!player.hasFpAnimStatus) { player.AddFpAnimStatus(NetworkAnimatorUtil.CreateAnimatorLayers(player.firstPersonAnimator.UnityAnimator), NetworkAnimatorUtil.GetAnimatorParams(player.firstPersonAnimator.UnityAnimator)); } // 禁用非可见状态下的动画更新 if (!player.isFlagSelf) { player.firstPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } else { player.firstPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } }
public void Init(IEntity entity, AssetStatus status) { var go = status.Object.AsGameObject; var player = entity as PlayerEntity; RemoveRagdollOnServerSide(go); player.AddThirdPersonModel(go); go.name = go.name.Replace("(Clone)", ""); go.transform.SetParent(player.RootGo().transform); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; _logger.InfoFormat("P3 loaded: {0}", player.entityKey); BoneTool.CacheTransform(go); if (!player.hasBones) { player.AddBones(null, null, null); } player.bones.Head = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterHeadBoneName); player.bones.Spine = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterSpineName); player.AddThirdPersonAnimator(go.GetComponent <Animator>()); var ik = go.AddComponent <PlayerIK>(); ik.SetAnimator(AvatarIKGoal.LeftHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); ik.SetAnimator(AvatarIKGoal.RightHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); if (player.isFlagSelf) { var animationEvent = go.AddComponent <AnimationClipEvent>(); animationEvent.Player = player; player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent.InterruptAnimationEventFunc); // 设置大厅传入的roleId和avatarId player.appearanceInterface.Appearance.SetRoleModelIdAndInitAvatar(player.playerInfo.RoleModelId, player.playerInfo.AvatarIds); } else { go.AddComponent <ThirdPersonAnimationClipEvent>(); } player.characterControllerInterface.CharacterController.SetCharacterRoot(player.characterContoller.Value.gameObject); player.appearanceInterface.Appearance.SetThirdPersonCharacter(go); player.thirdPersonAnimator.UnityAnimator.Update(0); player.characterBoneInterface.CharacterBone.SetCharacterRoot(player.characterContoller.Value.gameObject); player.characterBoneInterface.CharacterBone.SetThirdPersonCharacter(go); player.characterBoneInterface.CharacterBone.SetStablePelvisRotation(); player.appearanceInterface.Appearance.SetAnimatorP3(player.thirdPersonAnimator.UnityAnimator); player.appearanceInterface.Appearance.PlayerReborn(); player.characterControllerInterface.CharacterController.PlayerReborn(); // 实际应该使用SharedConfig.IsServer,但离线模式中其值为false if (!player.hasNetworkAnimator) { player.AddNetworkAnimator(NetworkAnimatorUtil.CreateAnimatorLayers(player.thirdPersonAnimator.UnityAnimator), NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator)); player.networkAnimator.SetEntityName(player.entityKey.ToString()); } if (SharedConfig.IsServer) { player.AddNetworkAnimatiorServerTime(0); } // 禁用非可见状态下的动画更新,在获取Stable状态之后 if (SharedConfig.IsServer || !player.isFlagSelf) { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } else { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } }
public void OnLoadSucc(PlayerEntity player, UnityObject unityObj) { GameObject go = unityObj; player.AddThirdPersonModel(go); var provider = SingletonManager.Get <HitBoxTransformProviderCache>() .GetProvider(player.thirdPersonModel.Value); HitBoxComponentUtility.InitHitBoxComponent(player.entityKey.Value, player, provider); RemoveRagdollOnServerSide(go, provider.GetHitBoxColliders().Values.ToList()); HandleLoadedModel(player, go); player.AddAsset(unityObj); go.name = go.name.Replace("(Clone)", ""); go.transform.SetParent(player.RootGo().transform); go.transform.localPosition = new Vector3(0, -PlayerEntityUtility.CcSkinWidth, 0); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; _logger.InfoFormat("P3 loaded: {0}", player.entityKey); BoneTool.CacheTransform(go); if (!player.hasBones) { player.AddBones(null, null, null); } player.bones.Head = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterHeadBoneName); player.bones.Spine = BoneMount.FindChildBoneFromCache(go, BoneName.CharacterSpineName); player.AddThirdPersonAnimator(go.GetComponent <Animator>()); var ik = go.AddComponent <PlayerIK>(); ik.SetAnimator(AvatarIKGoal.LeftHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.LeftHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); ik.SetAnimator(AvatarIKGoal.RightHand, player.thirdPersonAnimator.UnityAnimator); ik.SetIKLayer(AvatarIKGoal.RightHand, NetworkAnimatorLayer.ThirdPersonIKPassLayer); if (player.isFlagSelf) { var animationEvent = go.AddComponent <AnimationClipEvent>(); animationEvent.Player = player; player.animatorClip.ClipManager.SetAnimationCleanEventCallback(animationEvent.InterruptAnimationEventFunc); } else { go.AddComponent <ThirdPersonAnimationClipEvent>(); } // 设置大厅传入的roleId和avatarId player.appearanceInterface.Appearance.SetRoleModelIdAndInitAvatar(player.playerInfo.RoleModelId, player.playerInfo.AvatarIds); player.characterControllerInterface.CharacterController.SetCharacterRoot(player.characterContoller.Value.gameObject); player.appearanceInterface.Appearance.SetThirdPersonCharacter(go); player.thirdPersonAnimator.UnityAnimator.Update(0); player.characterControllerInterface.CharacterController.SetThirdModel(player.thirdPersonModel.Value); player.characterBoneInterface.CharacterBone.SetCharacterRoot(player.characterContoller.Value.gameObject); player.characterBoneInterface.CharacterBone.SetThirdPersonCharacter(go); player.characterBoneInterface.CharacterBone.SetStablePelvisRotation(); player.appearanceInterface.Appearance.SetAnimatorP3(player.thirdPersonAnimator.UnityAnimator); player.appearanceInterface.Appearance.PlayerReborn(); player.characterControllerInterface.CharacterController.PlayerReborn(); // 实际应该使用SharedConfig.IsServer,但离线模式中其值为false if (!player.hasNetworkAnimator) { player.AddNetworkAnimator(NetworkAnimatorUtil.CreateAnimatorLayers(player.thirdPersonAnimator.UnityAnimator), NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator)); player.networkAnimator.SetEntityName(player.entityKey.ToString()); } if (!player.hasOverrideNetworkAnimator) { player.AddOverrideNetworkAnimator(); } if (SharedConfig.IsServer) { player.AddNetworkAnimatiorServerTime(0); } // 禁用非可见状态下的动画更新,在获取Stable状态之后 if (SharedConfig.IsServer || !player.isFlagSelf) { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } else { player.thirdPersonAnimator.UnityAnimator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } // _assetManager.LoadAssetAsync(player, AssetConfig.GetCharacterHitboxAssetInfo(player.playerInfo.ModelName), new HitboxLoadResponseHandler().OnLoadSucc); }