diff --git a/MoreParts/Managers/ColonyManager.cs b/MoreParts/Managers/ColonyManager.cs index efb4fb7..b4f594e 100644 --- a/MoreParts/Managers/ColonyManager.cs +++ b/MoreParts/Managers/ColonyManager.cs @@ -17,13 +17,10 @@ namespace MorePartsMod.Managers { class ColonyManager : MonoBehaviour { - // public public static ColonyManager Main; public Player_Local Player; - public List Colonies { get; private set; } - //private private SFS.UI.ModGUI.Button _createColonyButton; private ColonyGUI _ui; private bool _extractFlow; @@ -83,7 +80,7 @@ public bool CheckAndReduceMaterials(float constructionRequired, float electronic { if (resourceGroup.ResourceAmount < electronicRequired) { - MsgDrawer.main.Log("Insufficient Electronic Components"); + MsgDrawer.main.Log("Insufficient electronic components"); return false; } electronic = resourceGroup; @@ -93,7 +90,7 @@ public bool CheckAndReduceMaterials(float constructionRequired, float electronic { if (resourceGroup.ResourceAmount < constructionRequired) { - MsgDrawer.main.Log("Insufficient Construction MAterial"); + MsgDrawer.main.Log("Insufficient construction material"); return false; } construction = resourceGroup; @@ -154,7 +151,7 @@ private ColonyComponent GetNearestColony() private void ExtractResources() { - MsgDrawer.main.Log("Extracting resource from the colony to the rocket"); + MsgDrawer.main.Log("Extracting resources"); ColonyComponent colony = GetNearestColony(); @@ -178,7 +175,7 @@ private void ExtractResources() private void InsertResources() { - MsgDrawer.main.Log("Inserting resource from the rocket to the colony"); + MsgDrawer.main.Log("Storing resources in colony's refinery"); ColonyComponent colony = GetNearestColony(); @@ -300,8 +297,21 @@ private void CheckPlayerVelocity() return; } + ColonyComponent nearest = GetNearestColony(); + if (nearest != null) + { + // Change button to VIEW MODE + _createColonyButton.Text = "View Colony Information"; + _createColonyButton.OnClick = OpenColony; + } + else + { + // Change button to CREATE MODE + _createColonyButton.Text = "Create Colony"; + _createColonyButton.OnClick = CreateColony; + } - this._createColonyButton.gameObject.SetActive(true); + _createColonyButton.gameObject.SetActive(true); } private void CreateColony() @@ -311,7 +321,7 @@ private void CreateColony() if (!this.CheckColonyDistance(planet.codeName, playerLocation.position.Value)) { - MsgDrawer.main.Log("Too close to another colony"); + MsgDrawer.main.Log("Already inside another colony"); return; } diff --git a/MoreParts/Managers/ResourcesManager.cs b/MoreParts/Managers/ResourcesManager.cs index 617a89e..26f7639 100644 --- a/MoreParts/Managers/ResourcesManager.cs +++ b/MoreParts/Managers/ResourcesManager.cs @@ -155,7 +155,7 @@ public void DrawInMap() { if (deposit.Active && deposit.Discovered) { - MapUtils.DrawLandmarkInPlanet(this.CurrentPlanet, deposit.AngleDegree, deposit.Location, "Resource Deposit", Color.red); + MapUtils.DrawLandmarkInPlanet(this.CurrentPlanet, deposit.AngleDegree, deposit.Location, deposit.GetDepositSizeName(), Color.red); } } diff --git a/MoreParts/MorePartsMod.csproj b/MoreParts/MorePartsMod.csproj index 11b22c1..3602070 100644 --- a/MoreParts/MorePartsMod.csproj +++ b/MoreParts/MorePartsMod.csproj @@ -1,163 +1,163 @@  - - - - Debug - AnyCPU - {BA241F55-D6BB-4E78-956A-28F3204FEC8D} - Library - Properties - MorePartsMod - MorePartsMod - v4.8 - 512 - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - ..\Dependencies\0Harmony.dll - False - - - ..\Dependencies\Assembly-CSharp.dll - False - - - False - ..\Dependencies\Newtonsoft.Json.dll - False - - - ..\Dependencies\UniTask.dll - False - - - ..\Dependencies\UnityEngine.dll - False - - - ..\Dependencies\UnityEngine.AnimationModule.dll - False - - - ..\Dependencies\UnityEngine.AssetBundleModule.dll - False - - - ..\Dependencies\UnityEngine.CoreModule.dll - False - - - ..\Dependencies\UnityEngine.IMGUIModule.dll - False - - - ..\Dependencies\UnityEngine.InputLegacyModule.dll - False - - - ..\Dependencies\UnityEngine.InputModule.dll - False - - - ..\Dependencies\UnityEngine.Physics2DModule.dll - False - - - ..\Dependencies\UnityEngine.PhysicsModule.dll - False - - - ..\Dependencies\UnityEngine.TextCoreFontEngineModule.dll - False - - - ..\Dependencies\UnityEngine.TextCoreTextEngineModule.dll - False - - - ..\Dependencies\UnityEngine.TextRenderingModule.dll - False - - - ..\Dependencies\UnityEngine.UI.dll - False - - - - - + + + + Debug + AnyCPU + {BA241F55-D6BB-4E78-956A-28F3204FEC8D} + Library + Properties + MorePartsMod + MorePartsMod + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + ..\Dependencies\0Harmony.dll + False + + + ..\Dependencies\Assembly-CSharp.dll + False + + + False + ..\Dependencies\Newtonsoft.Json.dll + False + + + ..\Dependencies\UniTask.dll + False + + + ..\Dependencies\UnityEngine.dll + False + + + ..\Dependencies\UnityEngine.AnimationModule.dll + False + + + ..\Dependencies\UnityEngine.AssetBundleModule.dll + False + + + ..\Dependencies\UnityEngine.CoreModule.dll + False + + + ..\Dependencies\UnityEngine.IMGUIModule.dll + False + + + ..\Dependencies\UnityEngine.InputLegacyModule.dll + False + + + ..\Dependencies\UnityEngine.InputModule.dll + False + + + ..\Dependencies\UnityEngine.Physics2DModule.dll + False + + + ..\Dependencies\UnityEngine.PhysicsModule.dll + False + + + ..\Dependencies\UnityEngine.TextCoreFontEngineModule.dll + False + + + ..\Dependencies\UnityEngine.TextCoreTextEngineModule.dll + False + + + ..\Dependencies\UnityEngine.TextRenderingModule.dll + False + + + ..\Dependencies\UnityEngine.UI.dll + False + + + + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - - - - + + + + - - + + - - - - - - - - - - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MoreParts/Parts/BallonModule.cs b/MoreParts/Parts/BallonModule.cs index d45090d..f4b5b7d 100644 --- a/MoreParts/Parts/BallonModule.cs +++ b/MoreParts/Parts/BallonModule.cs @@ -1,5 +1,4 @@ - -using SFS.Parts; +using SFS.Parts; using SFS.Parts.Modules; using SFS.UI; using SFS.Variables; @@ -83,7 +82,7 @@ public void Deploy(UsePartData data) { if (!this.Location.planet.HasAtmospherePhysics || this.Location.Height > this.Location.planet.AtmosphereHeightPhysics * 0.9) { - MsgDrawer.main.Log("Not atmosphere"); + MsgDrawer.main.Log("Cannot deploy in a vaccum"); flag = false; } else @@ -97,7 +96,7 @@ public void Deploy(UsePartData data) } else if (this.TargetState.Value == 1f && this.State.Value == 1f) { - MsgDrawer.main.Log("Cut"); + MsgDrawer.main.Log("Balloon cut"); this.TargetState.Value = 2f; this.State.Value = 2f; flag = true; diff --git a/MoreParts/Parts/ExcavatorModule.cs b/MoreParts/Parts/ExcavatorModule.cs index 3877b37..83e735b 100644 --- a/MoreParts/Parts/ExcavatorModule.cs +++ b/MoreParts/Parts/ExcavatorModule.cs @@ -74,7 +74,7 @@ private void Update() this._material_container = this.GetMaterialContainer(); if (this._material_container == null) { - MsgDrawer.main.Log("You need a Material Container"); + MsgDrawer.main.Log("Material container needed for storage"); this.TargetState.Value = 0; return; } @@ -85,22 +85,22 @@ private void Update() if (deposit == null || !deposit.Active) { - MsgDrawer.main.Log("There is not Resource Deposit"); + MsgDrawer.main.Log("Resource deposit not found"); this.TargetState.Value = 0; return; } double countToExtract = _extractionCount * WorldTime.main.timewarpSpeed; - bool thereAreMore = deposit.takeRsources(countToExtract); + bool thereAreMore = deposit.takeResources(countToExtract); if (!thereAreMore) { - MsgDrawer.main.Log("Resource Deposit Exhausted!"); + MsgDrawer.main.Log("Resource deposit exhausted"); } this._material_container.AddResource(countToExtract); this.ExcavatorObject.eulerAngles = new Vector3(0f, 0f, this.ExcavatorObject.eulerAngles.z + 4); if (this._material_container.resourcePercent.Value == 1f) { - MsgDrawer.main.Log("Container Full"); + MsgDrawer.main.Log("Material container full"); this.TargetState.Value = 0; } } diff --git a/MoreParts/Parts/HingeModule.cs b/MoreParts/Parts/HingeModule.cs index 6874adc..8a849b8 100644 --- a/MoreParts/Parts/HingeModule.cs +++ b/MoreParts/Parts/HingeModule.cs @@ -178,26 +178,23 @@ private bool getTopPartGroup(Part[] toSearch) { if (this._topGroup.ExistInGroup(part)) { - // already exist in the group - - continue; + continue; // Already exists in the group } List nextJoints = this.Rocket.jointsGroup.GetConnectedJoints(part); if (!this._topGroup.ExistInBaseGroup(part)) { - // it's not part of the base part if (nextJoints.Any(item => item.GetOtherPart(part) == this.Part)) { // it's connected to hinge part - return false; // there is a loop + return false; } } else { isBaseGroup = true; } - // add in the group to prevent loops + // Add to group to prevent loop this._topGroup.AddPartToGroup(part); thereIsLoop = this.getTopPartGroup(this.getPartFromPartJoint(nextJoints, part, isBaseGroup)); if (!thereIsLoop) diff --git a/MoreParts/Parts/ScannerModule.cs b/MoreParts/Parts/ScannerModule.cs index f81ee94..c7fc14a 100644 --- a/MoreParts/Parts/ScannerModule.cs +++ b/MoreParts/Parts/ScannerModule.cs @@ -34,31 +34,35 @@ private void Start() private void Update() { - if (GameManager.main == null || !this.Active.Value || this.Location == null || this.Location.planet == null || this.Rocket.location == null) + if (GameManager.main == null || + !this.Active.Value || + this.Location == null || + this.Location.planet == null || + this.Rocket.location == null) { return; } if (this.Location.planet.IsInsideAtmosphere(this.Location.position)) { - this.Toggle("You can't use in the atmosphere", false); + this.Toggle("GeoEye cannot be used while in the atmosphere", false); return; } - double max_altitud = this.Location.planet.data.basics.timewarpHeight + 50000; + double max_altitude = this.Location.planet.data.basics.timewarpHeight + 50000; if (Base.worldBase.settings.difficulty.difficulty == SFS.WorldBase.Difficulty.DifficultyType.Realistic) { - max_altitud += 100000; + max_altitude += 100000; } - if (this.Location.Height > max_altitud) + if (this.Location.Height > max_altitude) { - this.Toggle("Max use altitude " + max_altitud / 1000 + "km", false); + this.Toggle("Max use altitude " + max_altitude / 1000 + "km", false); return; } if (ResourcesManger.Main.AnalyzePlanet(this.Rocket.location)) { - MsgDrawer.main.Log("Found Resource Deposit"); + MsgDrawer.main.Log("Found a resource deposit"); } } @@ -94,11 +98,11 @@ public void OnPartUsed(UsePartData data) { if (this.Active.Value) { - this.Toggle("GeoEye turn OFF", false); + this.Toggle("GeoEye turned off", false); } else { - this.Toggle("GeoEye turn ON", true); + this.Toggle("GeoEye turned off", true); } this.CheckOutOfFuel(); data.successfullyUsedPart = true; diff --git a/MoreParts/Parts/TelecommunicationDishModule.cs b/MoreParts/Parts/TelecommunicationDishModule.cs index 219b81d..00ff6f3 100644 --- a/MoreParts/Parts/TelecommunicationDishModule.cs +++ b/MoreParts/Parts/TelecommunicationDishModule.cs @@ -155,7 +155,7 @@ private void DoDisconnection() if (this._notifyDisconnection) { AntennaComponent.main.ShowTelecommunicationLines = false; - MsgDrawer.main.Log("No Connection"); + MsgDrawer.main.Log("No connection to Space Centre"); this._notifyDisconnection = false; this._notifyConnection = true; this._time = _ping; @@ -184,7 +184,7 @@ public void _toggle() if (this.IsOn.Value) { AntennaComponent.main.RemoveNode(this); - MsgDrawer.main.Log("Telecommunication Dish Off"); + MsgDrawer.main.Log("Telecommunication dish off"); this.Node = null; this._notifyDisconnection = true; this.DoDisconnection(); @@ -195,7 +195,7 @@ public void _toggle() else { this.Node = AntennaComponent.main.AddNode(this); - MsgDrawer.main.Log("Telecommunication Dish On"); + MsgDrawer.main.Log("Telecommunication dish on"); this._notifyDisconnection = true; this._notifyConnection = true; this.FlowRate.Value = 0.1f; diff --git a/MoreParts/Patches/BuildManagerPatcher.cs b/MoreParts/Patches/BuildManagerPatcher.cs index 36d9d42..8ba7654 100644 --- a/MoreParts/Patches/BuildManagerPatcher.cs +++ b/MoreParts/Patches/BuildManagerPatcher.cs @@ -25,7 +25,7 @@ public static void Postfix() _ui = holder.AddComponent(); Builder.AttachToCanvas(holder, Builder.SceneToAttach.CurrentScene); - SFS.UI.ModGUI.Button button = Builder.CreateButton(ui.transform, 120, 40, -90,-95, () => ScreenManager.main.OpenScreen(() => _ui), "Colonies"); + SFS.UI.ModGUI.Button button = Builder.CreateButton(ui.transform, 120, 40, -90,-95, () => ScreenManager.main.OpenScreen(() => _ui), "Select Launch Site"); button.rectTransform.anchorMin = Vector2.one; button.rectTransform.anchorMax = Vector2.one; } @@ -81,7 +81,7 @@ private static void ShowMenu(string text, string option) MenuGenerator.ShowChoices(() => text, array); } - private static bool IsSpeacialResource(string resourceName) + private static bool IsSpecialResource(string resourceName) { if (resourceName == MorePartsTypes.ROCKET_MATERIAL) { diff --git a/MoreParts/UI/BuildingColonyGUI.cs b/MoreParts/UI/BuildingColonyGUI.cs index e83ceb0..ccfc393 100644 --- a/MoreParts/UI/BuildingColonyGUI.cs +++ b/MoreParts/UI/BuildingColonyGUI.cs @@ -2,7 +2,11 @@ using SFS.Input; using SFS.UI.ModGUI; using MorePartsMod; +using MorePartsMod.UI; using UnityEngine; +using SFS.UI; +using SFS.Builds; + namespace MorePartsMod.UI { @@ -19,7 +23,7 @@ public override void OnClose() public override void OnOpen() { - this._holder = Builder.CreateWindow(this.transform, 2, 500, 700, 0, 350, titleText: "Colonies"); + this._holder = Builder.CreateWindow(this.transform, 2, 500, 700, 0, 500, titleText: "Launch From Colony"); this._holder.CreateLayoutGroup(Type.Vertical).spacing = 20f; this._holder.CreateLayoutGroup(Type.Vertical).DisableChildControl(); this._holder.CreateLayoutGroup(Type.Vertical).childAlignment = TextAnchor.UpperCenter; @@ -36,16 +40,33 @@ public override void ProcessInput() private void generateUI() { + Builder.CreateButton(this._holder.ChildrenHolder, 480, 60, 50, 0, () => this.TryLaunchFromColony(null), "[Default] Space Center"); + foreach (ColonyData colony in MorePartsPack.Main.ColoniesInfo) { - if (!colony.IsBuildingActive(MorePartsTypes.LAUNCH_PAD_BUILDING) || !colony.IsBuildingActive(MorePartsTypes.VAB_BUILDING)) - { - continue; - } - Builder.CreateButton(this._holder.ChildrenHolder, 480, 60, 0, 0, () => this.SetSpawnPoint(colony), colony.name); + Builder.CreateButton(this._holder.ChildrenHolder, 480, 60, 0, 0, () => this.TryLaunchFromColony(colony), colony.name); + } + } + private void TryLaunchFromColony(ColonyData colony) + { + if (colony == null || + (colony.IsBuildingActive(MorePartsTypes.LAUNCH_PAD_BUILDING) && colony.IsBuildingActive(MorePartsTypes.VAB_BUILDING))) + { + SetSpawnPoint(colony); } - Builder.CreateButton(this._holder.ChildrenHolder, 480, 60, 40, 0, () => this.SetSpawnPoint(null), "Space Center"); + else + { + ShowMenu(colony + "Does not contain a VAB or launchpad", "Ok"); + } + } + private static void ShowMenu(string text, string option) + { + SizeSyncerBuilder.Carrier sizeSync; + ButtonBuilder[] array = new ButtonBuilder[1]; + new SizeSyncerBuilder(out sizeSync).HorizontalMode(SizeMode.MaxChildSize); + array[0] = ButtonBuilder.CreateButton(sizeSync, () => option, null, CloseMode.Stack); + MenuGenerator.ShowChoices(() => text, array); } private void SetSpawnPoint(ColonyData spawnPoint) diff --git a/MoreParts/UI/ColonyGUI.cs b/MoreParts/UI/ColonyGUI.cs index d918fa6..d2c3e10 100644 --- a/MoreParts/UI/ColonyGUI.cs +++ b/MoreParts/UI/ColonyGUI.cs @@ -64,7 +64,6 @@ private void onChangeColonyName(string value) private void generateUI() { - Builder.CreateLabel(this._holder.ChildrenHolder, 480, 35, 0, 0, "Information"); Builder.CreateTextInput(this._holder.ChildrenHolder, 480, 50, 0, 0, this._colony.Data.name, this.onChangeColonyName); foreach (string key in this._colony.Data.resources.Keys) { @@ -105,7 +104,7 @@ private void generateResource(string resourcesType, int toGenerate = 100) { if (!this._colony.Data.resources.ContainsKey(MorePartsTypes.MATERIAL)) { - MsgDrawer.main.Log("There are not material in the colony"); + MsgDrawer.main.Log("There are no materials in this colony"); return; } diff --git a/MoreParts/World/PlanetResourceData.cs b/MoreParts/World/PlanetResourceData.cs index d4288d2..f2a09fc 100644 --- a/MoreParts/World/PlanetResourceData.cs +++ b/MoreParts/World/PlanetResourceData.cs @@ -10,12 +10,12 @@ public class PlanetResourceData [NonSerialized] private Planet _planet; - public List ResourceDeposits; + public List ResourceDeposits; public PlanetResourceData(Planet planet) { this._planet = planet; - this.ResourceDeposits = new List(); + this.ResourceDeposits = new List(); } public PlanetResourceData() { } @@ -26,9 +26,9 @@ public Planet GetPlanet() } public void Initialize() - { + {W System.Random rnd = new System.Random(); - int currentAngle = rnd.Next(0,10); + int currentAngle = rnd.Next(4,8); // More appropriate range // create x deposits for (short index = 0; index < 9; index++) { @@ -48,6 +48,7 @@ public void Initialize() public class ReourceDeposit { + public double Amount; public bool Active; public Double2 Location; @@ -67,11 +68,23 @@ public ReourceDeposit(float amount, Double2 location, int size, float angleDegre public ReourceDeposit() {} + public string GetDepositSizeName() + { + if (Size < 1500) + return "Small Resource Deposit"; + + if (Size < 2500) + return "Medium Resource Deposit"; + + return "Large Resource Deposit"; + } + + /** * reduce resources in this deposit * True if there are more resources */ - public bool takeRsources(double quantity) + public bool takeResources(double quantity) { this.Amount -= quantity; if(this.Amount < 0)