public bool ValidateHarvestable(HarvestableObjectView resource) { var resourceObject = resource.GetHarvestableObject(); if (!resourceObject.CanLoot(_localPlayerCharacterView) || resourceObject.GetCharges() <= 0 || resourceObject.GetResourceDescriptor().Tier < (int)SelectedMinimumTier) { return(false); } Vector3 position = resource.transform.position; float terrainHeight = _landscape.GetTerrainHeight(position.c(), out RaycastHit hit); if (position.y < terrainHeight - 5) { return(false); } if (_blacklist.ContainsKey(resource)) { return(false); } return(true); }
public static bool CanLoot(this HarvestableObjectView view, LocalPlayerCharacterView localPlayer) => view.GetHarvestableObject().CanLoot(localPlayer);
public static bool RequiresTool(this HarvestableObjectView view) => view.GetHarvestableObject().RequiresTool();
public void HarvestHarvestableObjec(HarvestableObjectView resource) { Vector3 targetCenter = _currentTarget.transform.position; Vector3 playerCenter = _localPlayerCharacterView.transform.position; //Skip if target is inside a kepper pack if (_skipKeeperPacks && (ContainKeepers(_currentTarget.transform.position))) { Core.Log("[Blacklisted - Inside Kepper Pack Range]"); Blacklist(resource, TimeSpan.FromMinutes(5)); _state.Fire(Trigger.DepletedResource); return; } if (HandlePathing(ref _harvestPathingRequest)) { return; } var centerDistance = (targetCenter - playerCenter).magnitude; var minDistance = _currentTarget.GetColliderExtents() + _localPlayerCharacterView.GetColliderExtents() + 1.5f; if (centerDistance >= minDistance) { if (_localPlayerCharacterView.TryFindPath(new ClusterPathfinder(), targetCenter, IsBlockedGathering, out List <Vector3> pathing)) { Core.Log("Path found, begin travel to resource"); Core.lineRenderer.positionCount = pathing.Count; Core.lineRenderer.SetPositions(pathing.ToArray()); _harvestPathingRequest = new ClusterPathingRequest(_localPlayerCharacterView, _currentTarget, pathing); } else { Core.Log("Path not found"); _state.Fire(Trigger.DepletedResource); } return; } if (_localPlayerCharacterView.IsHarvesting()) { Core.LogOnce("Currently harvesting. Wait until done."); return; } if (resource.GetHarvestableObject().GetCharges() <= 0) { Core.Log("resource depleted. Move on"); _state.Fire(Trigger.DepletedResource); return; } Core.Log("[Harvesting] - Interact with resource"); _localPlayerCharacterView.Interact(resource); var harvestableObject2 = resource.GetHarvestableObject(); var resourceType = harvestableObject2.GetResourceType().Value; var tier = (Albion_Direct.Tier)harvestableObject2.GetTier(); var enchantmentLevel = (Albion_Direct.EnchantmentLevel)harvestableObject2.GetRareState(); var info = new GatherInformation(resourceType, tier, enchantmentLevel) { HarvestDate = DateTime.UtcNow }; var position = resource.transform.position.c(); if (_gatheredSpots.ContainsKey(position)) { _gatheredSpots[position] = info; } else { _gatheredSpots.Add(position, info); } }
public void HarvestHarvestableObjec(HarvestableObjectView resource) { Vector3 targetCenter = _currentTarget.transform.position; Vector3 playerCenter = _localPlayerCharacterView.transform.position; //Skip if target is inside a kepper pack if (_skipKeeperPacks && (ContainKeepers(_currentTarget.transform.position))) { Core.Log("[Skipped - Inside Kepper Pack Range]"); Blacklist(resource, TimeSpan.FromHours(24)); _state.Fire(Trigger.DepletedResource); return; } if (HandlePathing(ref _harvestPathingRequest)) { return; } var centerDistance = (targetCenter - playerCenter).magnitude; var minDistance = _currentTarget.GetColliderExtents() + _localPlayerCharacterView.GetColliderExtents() + 1.5f; if (centerDistance >= minDistance) { if (_localPlayerCharacterView.TryFindPath(new ClusterPathfinder(), targetCenter, IsBlockedGathering, out List <Vector3> pathing)) { Core.lineRenderer.positionCount = pathing.Count; Core.lineRenderer.SetPositions(pathing.ToArray()); _harvestPathingRequest = new ClusterPathingRequest(_localPlayerCharacterView, _currentTarget, pathing); } else { if (DateTime.Now > notMovingTimer) { isMovingUpdate(); } else { Core.Log("Harvest not moving check 1. Going to random location"); _localPlayerCharacterView.RequestMove(playerCenter + new Vector3(UnityEngine.Random.Range(-100f, 100f), 0, UnityEngine.Random.Range(-100f, 100f))); } if (!IsMoving) { notMovingTimer = DateTime.Now + TimeSpan.FromSeconds(2); } Core.Log("Path not found"); _state.Fire(Trigger.DepletedResource); } return; } if (_localPlayerCharacterView.IsHarvesting()) { return; } if (resource.GetHarvestableObject().GetCharges() <= 0) { _state.Fire(Trigger.DepletedResource); return; } Core.Log("[Harvesting]"); _localPlayerCharacterView.Interact(resource); if (DateTime.Now > notMovingTimer) { isMovingUpdate(); } else { Core.Log("Harvest not moving check 2. Going to random location"); _localPlayerCharacterView.RequestMove(playerCenter + new Vector3(UnityEngine.Random.Range(-100f, 100f), 0, UnityEngine.Random.Range(-100f, 100f))); } if (!IsMoving) { notMovingTimer = DateTime.Now + TimeSpan.FromSeconds(2); } var harvestableObject2 = resource.GetHarvestableObject(); var resourceType = harvestableObject2.GetResourceType().Value; var tier = (Tier)harvestableObject2.GetTier(); var enchantmentLevel = (EnchantmentLevel)harvestableObject2.GetRareState(); var info = new GatherInformation(resourceType, tier, enchantmentLevel) { HarvestDate = DateTime.UtcNow }; var position = resource.transform.position.c(); if (_gatheredSpots.ContainsKey(position)) { _gatheredSpots[position] = info; } else { _gatheredSpots.Add(position, info); } }