public override void OnUpdate() { // Need to do this on update, as the part module gets loaded before the scenario if (fishingData == null && SportsScenario.Instance != null) { fishingData = SportsScenario.Instance.GetFishingData(pcm); fishRecord = fishingData.BiggestFish(vessel.mainBody); fishCount = fishingData.FishCount(vessel.mainBody); } if (vessel.situation != Vessel.Situations.LANDED || !vessel.mainBody.ocean || vessel.altitude > 250) { SetShowing(false); } // Perform the more expensive check else { // Check 5 meters forward for water Vector3 checkPosition = vessel.transform.localPosition + vessel.transform.forward * 5.0f; double latitude = vessel.mainBody.GetLatitude(checkPosition); double longitude = vessel.mainBody.GetLongitude(checkPosition); double height = Util.TerrainHeight(vessel.mainBody, latitude, longitude); int adminLevel = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Administration) * ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.Administration)) + 1; if (height <= 0.0 || adminLevel == 3 && Util.adminPool.Contains(new Vector2((float)latitude, (float)longitude))) { SetShowing(true); // Set the fish type found at the current location Fish.FishType ft = Fish.GetFishType(vessel.mainBody, vessel.latitude, vessel.longitude); fishType = ft.Name(); } else { SetShowing(false); } } }
public static string Name(this Fish.FishType fishType) { switch (fishType) { case Fish.FishType.Coastal: return(coastal); case Fish.FishType.DeepOcean: return(deepOcean); case Fish.FishType.Freshwater: return(freshwater); case Fish.FishType.Kraken: return(kraken); case Fish.FishType.Ocean: return(ocean); case Fish.FishType.Pond: return(pond); } return("Unhandled Fish!"); }