private bool CanAction(PlayerActor player, EventType eventType, int searchAreaID) { int registerId = this.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = Singleton <Game> .Instance.Environment.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count >= Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount || player.PlayerData.ItemList.Count >= player.PlayerData.InventorySlotMax) { return(false); } StuffItem itemInfo = player.PlayerData.EquipedSearchItem(searchAreaID); return(this.CanSearch(eventType, itemInfo)); }
protected override void OnCompletedStateTask() { AgentActor agent = this.Agent; int desireKey = Desire.GetDesireKey(Desire.Type.Hunt); agent.SetDesire(desireKey, 0.0f); Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo; if (!searchActionLockTable.TryGetValue(agent.CurrentPoint.RegisterID, out searchActionInfo)) { searchActionInfo = new AIProject.SaveData.Environment.SearchActionInfo(); } ++searchActionInfo.Count; searchActionLockTable[agent.CurrentPoint.RegisterID] = searchActionInfo; ActionPoint currentPoint = this.Agent.CurrentPoint; Dictionary <int, ItemTableElement> itemTableInArea = Singleton <Resources> .Instance.GameInfo.GetItemTableInArea(currentPoint.IDList.IsNullOrEmpty <int>()?currentPoint.ID : currentPoint.IDList.GetElement <int>(0)); if (itemTableInArea != null) { ; } Actor.SearchInfo searchInfo = agent.RandomAddItem(itemTableInArea, false); if (!searchInfo.IsSuccess) { return; } foreach (Actor.ItemSearchInfo itemSearchInfo in searchInfo.ItemList) { StuffItem stuffItem = new StuffItem(itemSearchInfo.categoryID, itemSearchInfo.id, itemSearchInfo.count); agent.AgentData.ItemList.AddItem(stuffItem); StuffItemInfo info = Singleton <Resources> .Instance.GameInfo.GetItem(itemSearchInfo.categoryID, itemSearchInfo.id); MapUIContainer.AddItemLog((Actor)agent, info, itemSearchInfo.count, false); } }
private static void CreateList( AgentActor agent, List <ActionPoint> source, List <ActionPoint> destination, EventType eventType, bool isFollow, bool isRain) { int chunkId = agent.ChunkID; Dictionary <int, bool> toRelease = DictionaryPool <int, bool> .Get(); int searchCount = Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount; float meshSampleDistance = Singleton <Resources> .Instance.LocomotionProfile.ActionPointNavMeshSampleDistance; foreach (ActionPoint actionPoint1 in source) { if (!Object.op_Equality((Object)actionPoint1, (Object)null) && !Object.op_Equality((Object)actionPoint1.OwnerArea, (Object)null) && (actionPoint1.IsNeutralCommand && !actionPoint1.IsReserved(agent))) { List <ActionPoint> connectedActionPoints = actionPoint1.ConnectedActionPoints; if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>()) { bool flag = false; foreach (ActionPoint actionPoint2 in connectedActionPoints) { if (!Object.op_Equality((Object)actionPoint2, (Object)null) && (!actionPoint2.IsNeutralCommand || actionPoint2.IsReserved(agent))) { flag = true; break; } } if (flag) { continue; } } if (!isRain || actionPoint1.AreaType == MapArea.AreaType.Indoor) { MapArea ownerArea = actionPoint1.OwnerArea; bool flag1; if (!toRelease.TryGetValue(ownerArea.AreaID, out flag1)) { toRelease[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID); } if (flag1 && (!isFollow ? actionPoint1.AgentEventType : actionPoint1.AgentDateEventType).Contains(eventType)) { switch (eventType) { case EventType.Eat: StuffItem carryingItem = agent.AgentData.CarryingItem; AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems; bool flag2 = false; foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems) { if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID) { flag2 = true; break; } } ActionPointInfo outInfo; if (flag2) { PoseKeyPair eatDeskId1 = agentProfile.PoseIDTable.EatDeskID; PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID; if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) || actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo)) { break; } continue; } PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID; if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out outInfo)) { break; } continue; case EventType.Search: SearchActionPoint searchActionPoint = actionPoint1 as SearchActionPoint; if (Object.op_Inequality((Object)searchActionPoint, (Object)null)) { int registerId = searchActionPoint.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count < searchCount) { int tableId = searchActionPoint.TableID; StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId); if (agent.SearchAreaID == 0) { if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } break; } if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } break; } continue; } break; case EventType.Warp: WarpPoint warpPoint = actionPoint1 as WarpPoint; Dictionary <int, List <WarpPoint> > dictionary; List <WarpPoint> warpPointList; if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(ownerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2)) { continue; } break; } if (SetDesiredRandomAction._navMeshPath == null) { SetDesiredRandomAction._navMeshPath = new NavMeshPath(); } NavMeshHit navMeshHit; if (agent.NavMeshAgent.CalculatePath(actionPoint1.LocatedPosition, SetDesiredRandomAction._navMeshPath) && SetDesiredRandomAction._navMeshPath.get_status() == null && NavMesh.SamplePosition(actionPoint1.LocatedPosition, ref navMeshHit, meshSampleDistance, agent.NavMeshAgent.get_areaMask())) { destination.Add(actionPoint1); } } } } } DictionaryPool <int, bool> .Release(toRelease); }
private static void CreateList( AgentActor agent, List <ActionPoint> source, List <ActionPoint> destination, EventType eventType, bool isRain) { int searchCount = Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount; float meshSampleDistance = Singleton <Resources> .Instance.LocomotionProfile.ActionPointNavMeshSampleDistance; Dictionary <int, bool> toRelease = DictionaryPool <int, bool> .Get(); foreach (ActionPoint actionPoint1 in source) { if (!Object.op_Equality((Object)actionPoint1, (Object)null) && !Object.op_Equality((Object)actionPoint1.OwnerArea, (Object)null) && (actionPoint1.IsNeutralCommand && !actionPoint1.IsReserved(agent))) { List <ActionPoint> connectedActionPoints = actionPoint1.ConnectedActionPoints; if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>()) { bool flag = false; foreach (ActionPoint actionPoint2 in connectedActionPoints) { if (!Object.op_Equality((Object)actionPoint2, (Object)null) && (!actionPoint2.IsNeutralCommand || actionPoint2.IsReserved(agent))) { flag = true; break; } } if (flag) { continue; } } if (!isRain || actionPoint1.AreaType == MapArea.AreaType.Indoor) { MapArea ownerArea = actionPoint1.OwnerArea; bool flag; if (!toRelease.TryGetValue(ownerArea.AreaID, out flag)) { toRelease[ownerArea.AreaID] = flag = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID); } if (flag && actionPoint1.PlayerDateEventType[(int)Singleton <Manager.Map> .Instance.Player.ChaControl.sex].Contains(eventType)) { if (eventType == EventType.Search) { SearchActionPoint searchActionPoint = actionPoint1 as SearchActionPoint; if (Object.op_Inequality((Object)searchActionPoint, (Object)null)) { int registerId = searchActionPoint.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count < searchCount) { int tableId = searchActionPoint.TableID; StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId); if (agent.SearchAreaID == 0) { if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } } else if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } } else { continue; } } } if (SetDesiredPDateAction._navMeshPath == null) { SetDesiredPDateAction._navMeshPath = new NavMeshPath(); } NavMeshHit navMeshHit; if (agent.NavMeshAgent.CalculatePath(actionPoint1.LocatedPosition, SetDesiredPDateAction._navMeshPath) && SetDesiredPDateAction._navMeshPath.get_status() == null && NavMesh.SamplePosition(actionPoint1.LocatedPosition, ref navMeshHit, meshSampleDistance, agent.NavMeshAgent.get_areaMask())) { destination.Add(actionPoint1); } } } } } DictionaryPool <int, bool> .Release(toRelease); }
private void Elapsed(PlayerActor player) { ActionPoint currentPoint = player.CurrentPoint; System.Type type = ((object)currentPoint).GetType(); if (Singleton <Game> .IsInstance() && ((object)player.CurrentPoint).GetType() == typeof(SearchActionPoint)) { Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = Singleton <Game> .Instance.Environment.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo; if (!searchActionLockTable.TryGetValue(player.CurrentPoint.RegisterID, out searchActionInfo)) { searchActionInfo = new AIProject.SaveData.Environment.SearchActionInfo(); } ++searchActionInfo.Count; searchActionLockTable[player.CurrentPoint.RegisterID] = searchActionInfo; } Dictionary <int, ItemTableElement> itemTableInArea = Singleton <Resources> .Instance.GameInfo.GetItemTableInArea(currentPoint.IDList.IsNullOrEmpty <int>()?currentPoint.ID : currentPoint.IDList.GetElement <int>(0)); if (itemTableInArea != null) { ; } Actor.SearchInfo searchInfo = player.RandomAddItem(itemTableInArea, true); if (type == typeof(OnceSearchActionPoint)) { OnceSearchActionPoint searchActionPoint = currentPoint as OnceSearchActionPoint; if (searchActionPoint.HaveMapItems) { Manager.Map.FadeStart(-1f); } searchActionPoint.SetAvailable(false); } else if (type == typeof(DropSearchActionPoint)) { DropSearchActionPoint searchActionPoint = currentPoint as DropSearchActionPoint; if (searchActionPoint.HaveMapItems) { Manager.Map.FadeStart(-1f); } searchActionPoint.SetCoolTime(); } if (searchInfo.IsSuccess) { foreach (Actor.ItemSearchInfo itemSearchInfo in searchInfo.ItemList) { StuffItem stuffItem = new StuffItem(itemSearchInfo.categoryID, itemSearchInfo.id, itemSearchInfo.count); player.PlayerData.ItemList.AddItem(stuffItem); MapUIContainer.AddSystemItemLog(Singleton <Resources> .Instance.GameInfo.GetItem(itemSearchInfo.categoryID, itemSearchInfo.id), itemSearchInfo.count, true); } player.Controller.ChangeState("Normal"); } else { MapUIContainer.AddNotify(MapUIContainer.ItemGetEmptyText); player.Controller.ChangeState("Normal"); } AgentActor agentPartner = player.AgentPartner; if (Object.op_Equality((Object)agentPartner.CurrentPoint, (Object)null)) { agentPartner.BehaviorResources.ChangeMode(Desire.ActionType.Ovation); } else { if (!player.OldEnabledHoldingHand) { return; } ((Behaviour)player.HandsHolder).set_enabled(true); player.OldEnabledHoldingHand = false; } }
private void Elapsed(PlayerActor player) { ActionPoint currentPoint = player.CurrentPoint; System.Type type = ((object)currentPoint).GetType(); if (Singleton <Game> .IsInstance() && type == typeof(SearchActionPoint)) { Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = Singleton <Game> .Instance.Environment.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo; if (!searchActionLockTable.TryGetValue(currentPoint.RegisterID, out searchActionInfo)) { searchActionInfo = new AIProject.SaveData.Environment.SearchActionInfo(); } ++searchActionInfo.Count; searchActionLockTable[currentPoint.RegisterID] = searchActionInfo; } Actor.SearchInfo searchInfo = new Actor.SearchInfo() { IsSuccess = false }; if (currentPoint is SearchActionPoint) { SearchActionPoint searchActionPoint = currentPoint as SearchActionPoint; Dictionary <int, ItemTableElement> itemTableInArea = Singleton <Resources> .Instance.GameInfo.GetItemTableInArea(searchActionPoint.IDList.IsNullOrEmpty <int>()?searchActionPoint.ID : searchActionPoint.IDList.GetElement <int>(0)); searchInfo = player.RandomAddItem(itemTableInArea, true); } else if (currentPoint is TutorialSearchActionPoint) { searchInfo = (currentPoint as TutorialSearchActionPoint).GetSearchInfo(); } if (type == typeof(OnceSearchActionPoint)) { OnceSearchActionPoint searchActionPoint = currentPoint as OnceSearchActionPoint; if (searchActionPoint.HaveMapItems) { Manager.Map.FadeStart(-1f); } searchActionPoint.SetAvailable(false); } else if (type == typeof(DropSearchActionPoint)) { DropSearchActionPoint searchActionPoint = currentPoint as DropSearchActionPoint; if (searchActionPoint.HaveMapItems) { Manager.Map.FadeStart(-1f); } searchActionPoint.SetCoolTime(); } if (searchInfo.IsSuccess) { foreach (Actor.ItemSearchInfo itemSearchInfo in searchInfo.ItemList) { StuffItem stuffItem = new StuffItem(itemSearchInfo.categoryID, itemSearchInfo.id, itemSearchInfo.count); if (player.PlayerData.ItemList.Count < player.PlayerData.InventorySlotMax) { player.PlayerData.ItemList.AddItem(stuffItem, stuffItem.Count, player.PlayerData.InventorySlotMax); } MapUIContainer.AddSystemItemLog(Singleton <Resources> .Instance.GameInfo.GetItem(itemSearchInfo.categoryID, itemSearchInfo.id), itemSearchInfo.count, true); } player.Controller.ChangeState("Normal"); } else { MapUIContainer.AddNotify(MapUIContainer.ItemGetEmptyText); player.Controller.ChangeState("Normal"); } }
private static bool CheckNeutral( AgentActor agent, ActionPoint pt, Dictionary <int, bool> availableArea, int searchCount, int chunkID, EventType eventType, bool isFollow, bool isRain, float sampleDistance) { if (Object.op_Equality((Object)pt, (Object)null) || Object.op_Equality((Object)pt.OwnerArea, (Object)null) || (!pt.IsNeutralCommand || pt.IsReserved(agent))) { return(false); } List <ActionPoint> connectedActionPoints = pt.ConnectedActionPoints; if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>()) { foreach (ActionPoint actionPoint in connectedActionPoints) { if (!Object.op_Equality((Object)actionPoint, (Object)null) && (!actionPoint.IsNeutralCommand || actionPoint.IsReserved(agent))) { return(false); } } } if (isRain && pt.AreaType != MapArea.AreaType.Indoor) { return(false); } MapArea ownerArea = pt.OwnerArea; if (ownerArea.ChunkID == chunkID) { return(false); } bool flag1; if (!availableArea.TryGetValue(ownerArea.AreaID, out flag1)) { availableArea[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID); } if (!flag1 || !(!isFollow ? pt.AgentEventType : pt.AgentDateEventType).Contains(eventType)) { return(false); } switch (eventType) { case EventType.Eat: StuffItem carryingItem = agent.AgentData.CarryingItem; AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems; bool flag2 = false; foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems) { if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID) { flag2 = true; break; } } if (flag2) { PoseKeyPair eatDeskId1 = agentProfile.PoseIDTable.EatDeskID; PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID; ActionPointInfo outInfo; if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) && !pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo)) { return(false); } break; } PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID; if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out ActionPointInfo _)) { return(false); } break; case EventType.Search: SearchActionPoint searchActionPoint = pt as SearchActionPoint; if (Object.op_Inequality((Object)searchActionPoint, (Object)null)) { int registerId = searchActionPoint.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count >= searchCount) { return(false); } int tableId = searchActionPoint.TableID; StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId); if (agent.SearchAreaID == 0) { if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { return(false); } break; } if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { return(false); } break; } break; case EventType.Warp: WarpPoint warpPoint = pt as WarpPoint; Dictionary <int, List <WarpPoint> > dictionary; List <WarpPoint> warpPointList; if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(ownerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2)) { return(false); } break; } if (SetDesiredActionOtherChunk._navMeshPath == null) { SetDesiredActionOtherChunk._navMeshPath = new NavMeshPath(); } NavMeshHit navMeshHit; return(agent.NavMeshAgent.CalculatePath(pt.LocatedPosition, SetDesiredActionOtherChunk._navMeshPath) && SetDesiredActionOtherChunk._navMeshPath.get_status() == null && NavMesh.SamplePosition(pt.LocatedPosition, ref navMeshHit, sampleDistance, agent.NavMeshAgent.get_areaMask())); }