public void OnTreeCutDown(SkEntity skEntity, GlobalTreeInfo treeInfo) { if (null != onTreeCutDown) { onTreeCutDown(skEntity, treeInfo); } }
public static List <GlobalTreeInfo> Picking(IntVector3 position, bool includeTrees) { if (s_Instance == null) { return(picklist); } ClearTreeinfo(); ipos.x = position.x; ipos.y = position.y; ipos.z = position.z; List <TreeInfo> list_currcell = s_Instance.TreesAtPos(ipos); for (int i = 0; i < list_currcell.Count; ++i) { TreeInfo _ti = list_currcell[i]; if (HasCollider(_ti.m_protoTypeIdx) && !includeTrees) { continue; } GlobalTreeInfo gti = GetGlobalTreeInfo(); gti._terrainIndex = -1; gti._treeInfo = _ti; picklist.Add(gti); } return(picklist); }
public bool UpdateOPTreeInfo() { if (null == m_Axe || m_Axe.durability <= PETools.PEMath.Epsilon) { return(false); } mFindTreeInfo = null; GlobalTreeInfo gTreeinfo = PETools.PEUtil.RayCastTree(PeCamera.mouseRay.origin - 0.5f * PeCamera.mouseRay.direction, PeCamera.mouseRay.direction, 100f); GlobalTreeInfo playerTree = PETools.PEUtil.RayCastTree(trans.existent.position + Vector3.up, trans.existent.forward, FellDis); if (null == gTreeinfo || null == playerTree || gTreeinfo._treeInfo != playerTree._treeInfo) { return(false); } if (gTreeinfo != null) { NaturalRes resFind = NaturalResAsset.NaturalRes.GetTerrainResData(gTreeinfo._treeInfo.m_protoTypeIdx + 1000); if (null != resFind) { if (resFind.m_type == 9) { mFindTreeInfo = gTreeinfo; } } } return(null != mFindTreeInfo); }
void Reset(Tree sender) { if (entity.NpcCmpt != null) { entity.NpcCmpt.GatherprotoTypeIdx = -99; entity.NpcCmpt.RmoveTalkInfo(ENpcTalkType.Follower_Gather); glassInfo = null; } }
public static List <GlobalTreeInfo> Picking(Vector3 position, Vector3 direction, bool includeTrees = false, float distance = 1.5f, float angle = 45f) { if (s_Instance == null) { return(picklist); } ClearTreeinfo(); distance = Mathf.Clamp(distance, 0.1f, 2f); int ix = Mathf.FloorToInt(position.x); int iy = Mathf.FloorToInt(position.y); int iz = Mathf.FloorToInt(position.z); TreeInfo tmpTi; for (int x = ix - 2; x <= ix + 2; ++x) { for (int y = iy - 2; y <= iy + 2; ++y) { for (int z = iz - 2; z <= iz + 2; ++z) { int idx = LSubTerrUtils.WorldPosToIndex(new Vector3(x + .5F, 0, z + .5F)); if (Node(idx) != null) { temp.x = x % LSubTerrConstant.Size; temp.y = y; temp.z = z % LSubTerrConstant.Size; tmpTi = Node(idx).GetTreeInfoListAtPos(temp); while (tmpTi != null) { TreeInfo ti = tmpTi; tmpTi = tmpTi.Next; if (HasCollider(ti.m_protoTypeIdx) && !includeTrees) { continue; } Vector3 treepos = LSubTerrUtils.TreeTerrainPosToWorldPos(x >> LSubTerrConstant.SizeShift, z >> LSubTerrConstant.SizeShift, ti.m_pos); Vector3 diff = treepos - position; diff.y = 0; if (diff.magnitude > distance) { continue; } direction.y = 0; if (Vector3.Angle(diff, direction) < angle) { GlobalTreeInfo gti = GetGlobalTreeInfo(); gti._terrainIndex = idx; gti._treeInfo = ti; picklist.Add(gti); } } } } } } return(picklist); }
public override void EndImmediately() { motionMgr.SetMaskState(PEActionMask.Gather, false); if (null != anim) { anim.SetTrigger("ResetFullBody"); anim.ResetTrigger("Gather"); } mOpTreeInfo = mFindTreeInfo = null; }
bool DetectionTreeIndex(GlobalTreeInfo _treeInfo, PeEntity _entity) { for (int i = 0; i < NpcMaster.mFollowers.Length; i++) { if (NpcMaster.mFollowers[i] != null && NpcMaster.mFollowers[i].GatherprotoTypeIdx == _treeInfo._treeInfo.m_protoTypeIdx) { return(false); } } _entity.NpcCmpt.GatherprotoTypeIdx = _treeInfo._treeInfo.m_protoTypeIdx; return(true); }
public static void DeleteTree(GameObject nearTreeGo) { if (s_Instance == null) { return; } GlobalTreeInfo treeInfo = null; if (s_Instance.m_mapTempTreeInfos.TryGetValue(nearTreeGo, out treeInfo)) { DeleteTree(treeInfo); } }
public static List <GlobalTreeInfo> Picking(Vector3 position, Vector3 direction, bool includeTrees = false, float distance = 1.5f, float angle = 45f) { if (s_Instance == null) { return(picklist); } ClearTreeinfo(); distance = Mathf.Clamp(distance, 0.1f, 2f); ipos.x = Mathf.FloorToInt(position.x); ipos.y = Mathf.FloorToInt(position.y); ipos.z = Mathf.FloorToInt(position.z); for (int x = ipos.x - 2; x <= ipos.x + 2; ++x) { for (int y = ipos.y - 2; y <= ipos.y + 2; ++y) { for (int z = ipos.z - 2; z <= ipos.z + 2; ++z) { temp.x = x; temp.y = y; temp.z = z; List <TreeInfo> list_currcell = s_Instance.TreesAtPos(temp); for (int i = 0; i < list_currcell.Count; ++i) { TreeInfo _ti = list_currcell[i]; if (HasCollider(_ti.m_protoTypeIdx) && !includeTrees) { continue; } Vector3 diff = _ti.m_pos - position; diff.y = 0; if (diff.magnitude > distance) { continue; } direction.y = 0; if (Vector3.Angle(diff, direction) < angle) { GlobalTreeInfo gti = GetGlobalTreeInfo(); gti._terrainIndex = -1; gti._treeInfo = _ti; picklist.Add(gti); } } } } } return(picklist); }
static GlobalTreeInfo GetGlobalTreeInfo() { GlobalTreeInfo gti; if (globalTreeInfos.Count > 0) { gti = globalTreeInfos.Pop(); } else { gti = new GlobalTreeInfo(-1, null); } return(gti); }
public static GlobalTreeInfo TryGetTreeInfo(GameObject tree) { if (s_Instance == null) { return(null); } GlobalTreeInfo treeInfo = null; if (s_Instance.m_mapTempTreeInfos.TryGetValue(tree, out treeInfo)) { return(treeInfo); } return(null); }
void RemoveTrees() { Vector3 dir = m_LinkPos1 - m_LinkPos2; Vector3 normalDir = dir.normalized; RaycastHit[] hitTreeCols = Physics.RaycastAll(m_LinkPos2, normalDir, dir.magnitude, 1 << Pathea.Layer.NearTreePhysics, QueryTriggerInteraction.Ignore); for (int i = 0; i < hitTreeCols.Length; ++i) { GlobalTreeInfo gTreeinfo = PETools.PEUtil.GetTreeinfo(hitTreeCols[i].collider); if (null != gTreeinfo) { DigTerrainManager.RemoveTree(gTreeinfo); } } }
BehaveResult Init(Tree sender) { if (!GetData <Data>(sender, ref m_Data)) { return(BehaveResult.Failure); } if (!IsNpc || !IsNpcFollower || !Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Failure); } if (Random.value > m_Data.Probability) { return(BehaveResult.Failure); } GetGlobalTreeInfoForGather(); if (mGlobalTreeInfos == null || mGlobalTreeInfos.Count <= 0) { return(BehaveResult.Failure); } glassInfo = mGlobalTreeInfos[Random.Range(0, mGlobalTreeInfos.Count)]; if (glassInfo == null) { return(BehaveResult.Failure); } if (!DetectionTreeIndex(glassInfo, entity)) { return(BehaveResult.Failure); } m_Data.Gather = SetGlobalGatherInfo(glassInfo); if (m_Data.Gather == null && !m_Data.Gather.CanDoAction(null)) { return(BehaveResult.Failure); } reached = false; entity.NpcCmpt.AddTalkInfo(ENpcTalkType.Follower_Gather, ENpcSpeakType.TopHead, true); return(BehaveResult.Running); }
public static List <GlobalTreeInfo> Picking(IntVector3 position, bool includeTrees) { if (s_Instance == null) { return(picklist); } ClearTreeinfo(); int x = position.x; int y = position.y; int z = position.z; int idx = LSubTerrUtils.WorldPosToIndex(new Vector3(x + .5F, 0, z + .5F)); TreeInfo tmpTi; if (Node(idx) != null) { int rx = x % LSubTerrConstant.Size; int ry = y; int rz = z % LSubTerrConstant.Size; tmpTi = Node(idx).GetTreeInfoListAtPos(new IntVector3(rx, ry, rz)); while (tmpTi != null) { TreeInfo ti = tmpTi; tmpTi = tmpTi.Next; if (HasCollider(ti.m_protoTypeIdx) && !includeTrees) { continue; } GlobalTreeInfo gti = GetGlobalTreeInfo(); gti._terrainIndex = idx; gti._treeInfo = ti; picklist.Add(gti); } } return(picklist); }
public GroundItemTarget(Vector3 pos, GlobalTreeInfo item) { mPos = pos; mGroundItem = item; mMaxHp = m_Hp *= item._treeInfo.m_widthScale * item._treeInfo.m_widthScale; }
public override void PreDoAction() { base.PreDoAction(); mOpTreeInfo = mFindTreeInfo; }
public override void PreDoAction() { base.PreDoAction(); motionMgr.SetMaskState(PEActionMask.Gather, true); mOpTreeInfo = mFindTreeInfo; }
//Vector3 mayCenter; Vector3 GetStandPos(GlobalTreeInfo _GlobaltreeInfo, PeEntity player, PeEntity Npc) { if (_GlobaltreeInfo._treeInfo == null) { return(Vector3.zero); } if (_GlobaltreeInfo.HasCreatPickPos) { Vector3 cutPos; if (_GlobaltreeInfo.AddCutter(Npc.Id, out cutPos)) { return(cutPos); } return(Vector3.zero); } else { GameObject obj = null; if (null != RSubTerrainMgr.Instance) { if (RSubTerrainMgr.HasCollider(_GlobaltreeInfo._treeInfo.m_protoTypeIdx)) { obj = RSubTerrainMgr.Instance.GlobalPrototypeColliders[_GlobaltreeInfo._treeInfo.m_protoTypeIdx]; } } else if (null != LSubTerrainMgr.Instance) { if (LSubTerrainMgr.HasCollider(_GlobaltreeInfo._treeInfo.m_protoTypeIdx)) { obj = LSubTerrainMgr.Instance.GlobalPrototypeColliders[_GlobaltreeInfo._treeInfo.m_protoTypeIdx]; } } if (obj == null) { return(Vector3.zero); } CapsuleCollider collider = obj.GetComponent <CapsuleCollider>(); if (collider == null) { return(Vector3.zero); } Vector3 loacl = new Vector3(_GlobaltreeInfo._treeInfo.m_widthScale, _GlobaltreeInfo._treeInfo.m_heightScale, _GlobaltreeInfo._treeInfo.m_widthScale); Vector3 c = new Vector3(collider.center.x * loacl.x, collider.center.y * loacl.y, collider.center.z * loacl.z); _GlobaltreeInfo.TreeCapCenterPos = new Vector3(_GlobaltreeInfo.WorldPos.x + c.x, _GlobaltreeInfo.WorldPos.y, _GlobaltreeInfo.WorldPos.z + c.z); Vector3 direction = (player.peTrans.position - _GlobaltreeInfo.TreeCapCenterPos).normalized; if (_GlobaltreeInfo.CreatCutPos(_GlobaltreeInfo.TreeCapCenterPos, direction, collider.radius)) { Vector3 cutPos; if (_GlobaltreeInfo.AddCutter(Npc.Id, out cutPos)) { return(cutPos); } return(Vector3.zero); } return(Vector3.zero); } }
void OnCollisionEnter(Collision colInfo) { GameObject go = colInfo.collider.gameObject; if (go.layer == Layer.TreeStatic) { // Proceed one each time /* * ContactPoint point = colInfo.contacts[0]; * Vector3 vPt = point.point; * int x = Mathf.CeilToInt(vPt.x); * int y = Mathf.CeilToInt(vPt.y); * int z = Mathf.CeilToInt(vPt.z); * for(int dx = 0; dx < 2; dx++) { * for(int dy = 0; dx < 2; dx++) { * for(int dx = 0; dx < 2; dx++) { * } * } * } */ } else if (go.layer == Layer.NearTreePhysics) { if (Pathea.PeGameMgr.IsStory || Pathea.PeGameMgr.IsAdventure) { PeEntity entity = GetComponentInParent <PeEntity>(); if (Pathea.PeGameMgr.IsStory) { if (entity != null) { if (entity.Field == MovementField.Sky && entity.commonCmpt.entityProto.proto == EEntityProto.Monster) { if (entity.maxRadius < MinCmpt(colInfo.collider.bounds.extents) * 2f) { return; } } else if (entity.carrier) { if (colInfo.relativeVelocity.magnitude * entity.carrier.rigidbody.mass < MinCmpt(colInfo.collider.bounds.extents) * PEVCConfig.instance.treeHardness) { return; } } GlobalTreeInfo tree = LSubTerrainMgr.TryGetTreeInfo(go); if (tree != null) { LSubTerrainMgr.DeleteTree(go); LSubTerrainMgr.RefreshAllLayerTerrains(); SkEntitySubTerrain.Instance.SetTreeHp(tree.WorldPos, 0); StroyManager.Instance.TreeCutDown(entity.position, tree._treeInfo, tree.WorldPos); } } } else // Pathea.PeGameMgr.IsAdventure { if (entity != null) { if (entity.Field == MovementField.Sky && entity.commonCmpt.entityProto.proto == EEntityProto.Monster) { if (entity.maxRadius < MinCmpt(colInfo.collider.bounds.extents) * 2f) { return; } } else if (entity.carrier) { if (colInfo.relativeVelocity.magnitude * entity.carrier.rigidbody.mass < MinCmpt(colInfo.collider.bounds.extents) * PEVCConfig.instance.treeHardness) { return; } } TreeInfo tree = RSubTerrainMgr.TryGetTreeInfo(go); if (tree != null) { RSubTerrainMgr.DeleteTree(go); RSubTerrainMgr.RefreshAllLayerTerrains(); SkEntitySubTerrain.Instance.SetTreeHp(tree.m_pos, 0); StroyManager.Instance.TreeCutDown(entity.position, tree, tree.m_pos); } } } } } //50吨以15米/秒速度撞击的伤害缩放为1 50 * 15 * 15 = 11250 else if (go.layer == Layer.AIPlayer || go.layer == Layer.Player) { PeEntity target = go.GetComponentInParent <PeEntity>(); if (target != null && m_Entity != null && m_Entity.carrier != null && colInfo.relativeVelocity.sqrMagnitude > 2.0f * 2.0f) { NetCmpt net = m_Entity.GetComponent <NetCmpt>(); if (net == null || net.IsController) { float scale = 1.0f / 11250.0f; float mass = m_Entity.carrier.creationController.creationData.m_Attribute.m_Weight * 0.001f; float speed = colInfo.relativeVelocity.sqrMagnitude; float damageScale = Mathf.Clamp(mass * speed * scale, 0.0f, 2.0f); //Debug.LogError("Mass:" + mass + " Speed:" + speed + " Scale:" + damageScale); if (m_RigidBody == null || m_RigidBody.velocity.sqrMagnitude < 5.0f * 5.0f || damageScale < 0.01) { damageScale = 0.0f; } else { PECapsuleHitResult hitResult = new PECapsuleHitResult(); hitResult.selfTrans = transform; hitResult.hitTrans = go.transform; hitResult.hitPos = colInfo.contacts[0].point; hitResult.hitDir = -colInfo.contacts[0].normal; hitResult.damageScale = damageScale; m_Entity.skEntity.CollisionCheck(hitResult); //if(go.layer == Layer.Player && target.NpcCmpt != null && speed > 10.0f*10.0f) //{ // if(target.biologyViewCmpt != null) // { // RagdollHitInfo hitInfo = new RagdollHitInfo(); // hitInfo.hitTransform = target.biologyViewCmpt.monoRagdollCtrlr.ragdollRootBone; // hitInfo.hitPoint = colInfo.contacts[0].point; // hitInfo.hitNormal = colInfo.contacts[0].normal; // hitInfo.hitForce = colInfo.impulse; // target.biologyViewCmpt.ActivateRagdoll(hitInfo); // } //} } } } } //50吨以15米/秒速度撞击的伤害缩放为1 50 * 15 * 15 = 11250 if (go.layer == Layer.VFVoxelTerrain || go.layer == Layer.TreeStatic //|| go.layer == Layer.NearTreePhysics || go.layer == Layer.Building || go.layer == Layer.SceneStatic || go.layer == Layer.Unwalkable || go.layer == Layer.GIEProductLayer) { bool isWheel = false; if (go.layer == Layer.VFVoxelTerrain) { for (int i = 0; i < colInfo.contacts.Length; i++) { if (colInfo.contacts[i].thisCollider.gameObject.GetComponentInParent <VCPVehicleWheel>() != null) { isWheel = true; } } } if (!isWheel && m_Entity != null && m_Entity.carrier != null && colInfo.relativeVelocity.sqrMagnitude > 2.0f * 2.0f) { NetCmpt net = m_Entity.GetComponent <NetCmpt>(); if (net == null || net.IsController) { float scale = 1.0f / 11250.0f; float mass = m_Entity.carrier.creationController.creationData.m_Attribute.m_Weight * 0.001f; float speed = colInfo.relativeVelocity.sqrMagnitude; float damageScale = Mathf.Clamp(mass * speed * scale, 0.0f, 2.0f); Vector3 v = m_RigidBody.velocity; float curSpeed = Mathf.Sqrt(v.x * v.x + v.z * v.z) * 3.6f; //Debug.LogError("Mass:" + mass + " Speed:" + speed + " Scale:" + damageScale); if (curSpeed < 45f || damageScale < 0.01) { damageScale = 0.0f; } else { SkillSystem.SkEntity.MountBuff(m_Entity.skEntity, 30200174, new List <int> { 0 }, new List <float>() { damageScale }); //PECapsuleHitResult hitResult = new PECapsuleHitResult(); //hitResult.selfTrans = transform; //hitResult.hitTrans = go.transform; //hitResult.hitPos = colInfo.contacts[0].point; //hitResult.hitDir = -colInfo.contacts[0].normal; //hitResult.damageScale = damageScale; //m_Entity.skEntity.CollisionCheck(hitResult); //Debug.LogError(go.name + " --> " + colInfo.relativeVelocity.magnitude); } } } } }
BehaveResult Init(Tree sender) { // if (!GetData<Data>(sender, ref m_Data)) // return BehaveResult.Failure; if (!IsNpc || !IsNpcFollower) { return(BehaveResult.Failure); } if (!Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Failure); } if (!IsNpcFollowerCut) { return(BehaveResult.Failure); } if (entity.NpcCmpt.EqSelect.SetSelectObjsTool(entity, ItemAsset.EeqSelect.tool)) { ItemAsset.SelectItem.EquipByObj(entity, entity.NpcCmpt.EqSelect.GetBetterToolObj()); } //energy if (entity.NpcCmpt.EqSelect.SetSelectObjsEnergy(entity, ItemAsset.EeqSelect.energy)) { ItemAsset.SelectItem.EquipByObj(entity, entity.NpcCmpt.EqSelect.GetBetterEnergyObj()); } if (entity.motionEquipment == null || entity.motionEquipment.axe == null) { EndFollowerCut(); return(BehaveResult.Failure); } if (entity.motionEquipment.axe is PEChainSaw) { if (GetAttribute(AttribType.Energy) < PETools.PEMath.Epsilon) { EndFollowerCut(); return(BehaveResult.Failure); } } treeInfo = NpcMaster.peEntity.aliveEntity.treeInfo; if (treeInfo == null) { EndFollowerCut(); return(BehaveResult.Failure); } m_Data.mActionFell = SetGlobalTreeInfo(treeInfo); if (m_Data.mActionFell == null || !m_Data.mActionFell.CanDoAction(null)) { EndFollowerCut(); return(BehaveResult.Failure); } cutPos = GetStandPos(treeInfo, NpcMaster.peEntity, entity); if (cutPos == Vector3.zero) { EndFollowerCut(); return(BehaveResult.Failure); } m_Data.mStartCutTime = Time.time; m_Data.HasActive = false; entity.NpcCmpt.AddTalkInfo(ENpcTalkType.Follower_cut, ENpcSpeakType.TopHead, true); return(BehaveResult.Running); }
public static void DeleteTree(GlobalTreeInfo treeinfo) { if (s_Instance == null || treeinfo == null) { return; } // Delete it in Mgr's m_map32Trees int tmpKey = LSubTerrUtils.TreeWorldPosTo32Key(treeinfo.WorldPos); List <TreeInfo> tmpTis; if (s_Instance.m_map32Trees.TryGetValue(tmpKey, out tmpTis)) { tmpTis.Remove(treeinfo._treeInfo); if (tmpTis.Count == 0) { s_Instance.m_map32Trees.Remove(tmpKey); } } // Delete it in Mgr's m_mapExistTempTrees and m_mapTempTreeInfos List <GameObject> existGos; if (s_Instance.m_mapExistTempTrees.TryGetValue(tmpKey, out existGos)) { GameObject gameobject_to_delete = null; GlobalTreeInfo gti; foreach (GameObject go in existGos) { if (s_Instance.m_mapTempTreeInfos.TryGetValue(go, out gti)) { if (gti._treeInfo == treeinfo._treeInfo) { // Found it! gameobject_to_delete = go; if (OnTreeColliderDestroy != null) { OnTreeColliderDestroy(gameobject_to_delete); } GameObject.Destroy(go); s_Instance.m_mapTempTreeInfos.Remove(go); } } else { Debug.LogError("Can not find the GameObject key in m_mapTempTreeInfos when delete tree"); } } if (gameobject_to_delete != null) { existGos.Remove(gameobject_to_delete); } } // Delete it in Node's m_mapTrees and m_listTrees TreeInfo secondFoot = null; // For two feet trees if (Node(treeinfo._terrainIndex) != null) { secondFoot = Node(treeinfo._terrainIndex).DeleteTreeInfo(treeinfo._treeInfo); } else { Debug.LogError("Can not find the subterrain node when delete tree"); } // Delete it in layers foreach (LSubTerrCreator creator in s_Instance.LayerCreators) { if (creator.m_allTreesInLayer.TryGetValue(treeinfo._terrainIndex, out tmpTis)) { tmpTis.Remove(treeinfo._treeInfo); } else { Debug.LogError("Can not find the key in layer's m_allTreesInLayer when delete tree"); } } LSubTerrSL.AddDeletedTree(treeinfo._terrainIndex, treeinfo._treeInfo); // Delete 2nd foot ?? Is this really necessary?? if (secondFoot != null) { GlobalTreeInfo gti_2ndfoot = new GlobalTreeInfo(treeinfo._terrainIndex, secondFoot); DeleteTree(gti_2ndfoot); } }
protected void RPC_SKFellTree(uLink.BitStream stream, uLink.NetworkMessageInfo info) { /*int typeIndex = */ stream.Read <int> (); Vector3 pos = stream.Read <Vector3> (); /*float maxHP = */ stream.Read <float> (); float hp = stream.Read <float> (); TreeInfo tree = null; // = RSubTerrainMgr.TreesAtPosF(pos); if (null != LSubTerrainMgr.Instance) { int x = Mathf.FloorToInt(pos.x); int y = Mathf.FloorToInt(pos.y); int z = Mathf.FloorToInt(pos.z); List <GlobalTreeInfo> tree_list = LSubTerrainMgr.Picking(new IntVector3(x, y, z), true); if (tree_list.Count > 0) { foreach (var iter in tree_list) { if (hp <= 0) { PeEntity entity = EntityMgr.Instance.Get(Id); SkEntity skEntity = null == entity ? null : entity.skEntity; SkEntitySubTerrain.Instance.OnTreeCutDown(skEntity, iter); DigTerrainManager.RemoveTree(iter); if (IsOwner) { SkEntitySubTerrain.Instance.SetTreeHp(iter.WorldPos, hp); } } else { if (IsOwner) { SkEntitySubTerrain.Instance.SetTreeHp(iter.WorldPos, hp); } } } } } else if (null != RSubTerrainMgr.Instance) { RSubTerrSL.AddDeletedTree(pos); tree = RSubTerrainMgr.TreesAtPosF(pos); if (null != tree) { GlobalTreeInfo gTree = new GlobalTreeInfo(-1, tree); if (hp <= 0) { PeEntity entity = EntityMgr.Instance.Get(Id); SkEntity skEntity = null == entity ? null : entity.skEntity; SkEntitySubTerrain.Instance.OnTreeCutDown(skEntity, gTree); DigTerrainManager.RemoveTree(gTree); if (IsOwner) { SkEntitySubTerrain.Instance.SetTreeHp(gTree.WorldPos, hp); } } else { if (IsOwner) { SkEntitySubTerrain.Instance.SetTreeHp(gTree.WorldPos, hp); } } } } }
public bool UpdateOPTreeInfo() { mFindTreeInfo = null; if (null == trans) { return(false); } if (Vector3.Distance(trans.position, trans.position) > GatherMaxDis) { return(false); } List <GlobalTreeInfo> grassInfoList; if (null != LSubTerrainMgr.Instance) { grassInfoList = LSubTerrainMgr.Picking(trans.position, Vector3.forward, false, GatherMaxDis, 360f); } else if (null != RSubTerrainMgr.Instance) { grassInfoList = RSubTerrainMgr.Picking(trans.position, Vector3.forward, false, GatherMaxDis, 360f); } else { return(false); } for (int i = 0; i < grassInfoList.Count; i++) { NaturalRes resFind = NaturalResAsset.NaturalRes.GetTerrainResData(grassInfoList[i]._treeInfo.m_protoTypeIdx + 1000); if (null != resFind) { if (resFind.m_type == 10) { if (!PeCamera.cursorLocked) { if (null != LSubTerrainMgr.Instance) { Vector3 pos = grassInfoList[i].WorldPos; Bounds bound = new Bounds(); bound.SetMinMax(pos + grassInfoList[i]._treeInfo.m_heightScale * LSubTerrainMgr.Instance.GlobalPrototypeBounds[grassInfoList[i]._treeInfo.m_protoTypeIdx].min, pos + grassInfoList[i]._treeInfo.m_heightScale * LSubTerrainMgr.Instance.GlobalPrototypeBounds[grassInfoList[i]._treeInfo.m_protoTypeIdx].max); if (!bound.IntersectRay(PeCamera.mouseRay)) { continue; } } else if (null != RSubTerrainMgr.Instance) { Vector3 pos = grassInfoList[i]._treeInfo.m_pos; Bounds bound = new Bounds(); bound.SetMinMax(pos + grassInfoList[i]._treeInfo.m_heightScale * RSubTerrainMgr.Instance.GlobalPrototypeBounds[grassInfoList[i]._treeInfo.m_protoTypeIdx].min, pos + grassInfoList[i]._treeInfo.m_heightScale * RSubTerrainMgr.Instance.GlobalPrototypeBounds[grassInfoList[i]._treeInfo.m_protoTypeIdx].max); if (!bound.IntersectRay(PeCamera.mouseRay)) { continue; } } } mFindTreeInfo = grassInfoList[i]; break; } } } return(null != mFindTreeInfo); }