public static void MineVegetable(VegeMined packet) { PlanetData planet = GameMain.galaxy?.PlanetById(packet.PlanetID); if (planet == null) { return; } if (packet.isVegetable) // Trees, rocks, leaves, etc { VegeData vData = (VegeData)planet.factory?.GetVegeData(packet.MiningID); VegeProto vProto = LDB.veges.Select((int)vData.protoId); if (vProto != null && planet.id == GameMain.localPlanet?.id) { VFEffectEmitter.Emit(vProto.MiningEffect, vData.pos, vData.rot); VFAudio.Create(vProto.MiningAudio, null, vData.pos, true); } planet.factory?.RemoveVegeWithComponents(vData.id); } else // veins { VeinData vData = (VeinData)planet.factory?.GetVeinData(packet.MiningID); VeinProto vProto = LDB.veins.Select((int)vData.type); if (vProto != null) { if (planet.factory?.veinPool[packet.MiningID].amount > 0) { VeinData[] vPool = planet.factory?.veinPool; PlanetData.VeinGroup[] vGroups = planet.factory?.planet.veinGroups; long[] vAmounts = planet.veinAmounts; vPool[packet.MiningID].amount -= 1; vGroups[(int)vData.groupIndex].amount -= 1; vAmounts[(int)vData.type] -= 1; if (planet.id == GameMain.localPlanet?.id) { VFEffectEmitter.Emit(vProto.MiningEffect, vData.pos, Maths.SphericalRotation(vData.pos, 0f)); VFAudio.Create(vProto.MiningAudio, null, vData.pos, true); } } else { PlanetData.VeinGroup[] vGroups = planet.factory?.planet.veinGroups; vGroups[vData.groupIndex].count -= 1; if (planet.id == GameMain.localPlanet?.id) { VFEffectEmitter.Emit(vProto.MiningEffect, vData.pos, Maths.SphericalRotation(vData.pos, 0f)); VFAudio.Create(vProto.MiningAudio, null, vData.pos, true); } planet.factory?.RemoveVeinWithComponents(vData.id); } } } }
public override void ProcessPacket(VegeMinedPacket packet, NebulaConnection conn) { if (GameMain.galaxy.PlanetById(packet.PlanetId)?.factory != null && GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.vegePool != null) { using (Multiplayer.Session.Planets.IsIncomingRequest.On()) { PlanetFactory factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory; if (packet.Amount == 0 && factory != null) { if (packet.IsVein) { VeinData veinData = factory.GetVeinData(packet.VegeId); VeinProto veinProto = LDB.veins.Select((int)veinData.type); factory.RemoveVeinWithComponents(packet.VegeId); if (veinProto != null) { VFEffectEmitter.Emit(veinProto.MiningEffect, veinData.pos, Maths.SphericalRotation(veinData.pos, 0f)); VFAudio.Create(veinProto.MiningAudio, null, veinData.pos, true, 0, -1, -1L); } } else { VegeData vegeData = factory.GetVegeData(packet.VegeId); VegeProto vegeProto = LDB.veges.Select(vegeData.protoId); factory.RemoveVegeWithComponents(packet.VegeId); if (vegeProto != null) { VFEffectEmitter.Emit(vegeProto.MiningEffect, vegeData.pos, Maths.SphericalRotation(vegeData.pos, 0f)); VFAudio.Create(vegeProto.MiningAudio, null, vegeData.pos, true, 0, -1, -1L); } } } else if (factory != null) { VeinData veinData = factory.GetVeinData(packet.VegeId); PlanetData.VeinGroup[] veinGroups = factory.planet.veinGroups; short groupIndex = veinData.groupIndex; // must be a vein/oil patch (i think the game treats them same now as oil patches can run out too) factory.veinPool[packet.VegeId].amount = packet.Amount; factory.planet.veinAmounts[(int)veinData.type] -= 1L; veinGroups[groupIndex].amount = veinGroups[groupIndex].amount - 1L; } else { Log.Warn("Received VegeMinedPacket but could not do as i was told :C"); } } } }
private static bool OnStarDataSet( StarData ____star, Text ___nameText, Text ___typeText, RectTransform ___paramGroup, Text ___massValueText, Text ___spectrValueText, Text ___radiusValueText, Text ___luminoValueText, Text ___temperatureValueText, Text ___ageValueText, Sprite ___unknownResIcon, GameObject ___trslBg, GameObject ___imgBg, UIResAmountEntry ___tipEntry, UIResAmountEntry ___entryPrafab, ref UIStarDetail __instance ) { for (int index = 0; index < __instance.entries.Count; ++index) { UIResAmountEntry entry = __instance.entries[index]; entry.SetEmpty(); __instance.pool.Add(entry); } __instance.entries.Clear(); if (__instance.star == null) { return(false); } double magnitude = (__instance.star.uPosition - GameMain.mainPlayer.uPosition).magnitude; bool _observed = GameMain.history.universeObserveLevel >= (__instance.star != GameMain.localStar ? (magnitude >= 14400000.0 ? 4 : 3) : 2); ___nameText.text = __instance.star.displayName; ___typeText.text = (__instance.star.typeString); ___massValueText.text = (__instance.star.mass.ToString("0.000") + " M "); ___spectrValueText.text = (__instance.star.spectr.ToString()); ___radiusValueText.text = (__instance.star.radius.ToString("0.00") + " R "); ___luminoValueText.text = (((double)__instance.star.dysonLumino).ToString("0.000") + " L "); ___temperatureValueText.text = (__instance.star.temperature.ToString("#,##0") + " K"); if (Localization.isKMG) { ___ageValueText.text = ((__instance.star.age * __instance.star.lifetime).ToString("#,##0 ") + "百万亿年".Translate()); } else { ___ageValueText.text = (((float)(__instance.star.age * (double)__instance.star.lifetime * 0.00999999977648258)).ToString("#,##0.00 ") + "百万亿年".Translate()); } int num = 0; for (int type = 1; type < 15; ++type) { int id = type; VeinProto veinProto = LDB.veins.Select(id); ItemProto itemProto = LDB.items.Select(veinProto.MiningItem); if (_observed || type < 7) { bool flag = (!__instance.star.loaded ? __instance.star.GetResourceSpots(type) > 0 : __instance.star.GetResourceAmount(type) > 0L) || type < 7; if (veinProto != null && itemProto != null && flag) { UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);; __instance.entries.Add(entry); entry.SetInfo(num, itemProto.name, veinProto.iconSprite, veinProto.description, type >= 7, false, type != 7 ? " " : " /s"); entry.refId = id; ++num; } } } if (_observed) { for (int index = 0; index < __instance.star.planetCount; ++index) { int waterItemId = __instance.star.planets[index].waterItemId; "无".Translate(); if (waterItemId > 0) { ItemProto itemProto = LDB.items.Select(waterItemId); if (itemProto != null) { Sprite iconSprite = itemProto.iconSprite; string name = itemProto.name; UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);; __instance.entries.Add(entry); entry.SetInfo(num, name, iconSprite, itemProto.description, itemProto != null && waterItemId != 1000, false, string.Empty); entry.valueString = "海洋".Translate(); ++num; } } } } //* Dictionary <int, float> ressources = new Dictionary <int, float>(); for (int index1 = 0; index1 < __instance.star.planetCount; ++index1) { PlanetData planet = __instance.star.planets[index1]; if (planet.type == EPlanetType.Gas && planet.gasItems != null) { for (var i = 0; i < planet.gasItems.Length; i++) { if (ressources.ContainsKey(planet.gasItems[i])) { ressources[planet.gasItems[i]] += planet.gasSpeeds[i]; } else { ressources[planet.gasItems[i]] = planet.gasSpeeds[i]; } } } } foreach (var keyValuePair in ressources) { ItemProto itemProto = LDB.items.Select(keyValuePair.Key); UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent); __instance.entries.Add(entry); if (_observed) { entry.SetInfo(num, itemProto.name, itemProto.iconSprite, itemProto.description, false, false, " /s"); if (__instance.star.loaded) { StringBuilderUtility.WritePositiveFloat(entry.sb, 0, 7, keyValuePair.Value); entry.DisplayStringBuilder(); } else { entry.valueString = "探测到信号".Translate(); } } else { entry.SetInfo(num, "未知".Translate(), ___unknownResIcon, string.Empty, false, false, " /s"); entry.valueString = "未知".Translate(); } entry.SetObserved(_observed); ++num; } if (!_observed) { UIResAmountEntry entry = Object.Instantiate(___entryPrafab, ___entryPrafab.transform.parent);;; __instance.entries.Add(entry); entry.SetInfo(num, string.Empty, null, string.Empty, false, false, string.Empty); ___tipEntry = entry; int num1 = ____star != GameMain.localStar ? (magnitude >= 14400000.0 ? 4 : 3) : 2; bool flag = GameMain.history.universeObserveLevel >= num1; ___tipEntry.valueString = flag ? string.Empty : "宇宙探索等级".Translate() + num1.ToString(); ++num; } __instance.SetResCount(num); __instance.RefreshDynamicProperties(); return(false); }