// Warnings about being out of storage only happen if they persist beyond a certain // time. Rather than changing the OreExtractor state, or trying to transpile out the // case in MissionManager, we instead hook OreExtractor.UpdateState and lock the issue // time to zero if we're out of storage. This has the effect of meaning the extractor // reports storage problems when looked at, but doesn't trigger a mission warning otherwise. public static void Postfix(ref OreExtractor __instance) { if (__instance.meState == OreExtractor.eState.eOutOfStorage) { __instance.mrIssueTime = 0; } }
public void Complete() { #warning band-aid fix to stop InitializeStartingData from being called twice Game.Current.IsNewGame = false; //todo: move player out of the way //actually, we _should_ only be able to complete construction when the player //is outside the zone looking in, so maybe not Transform newT = (Transform)GameObject.Instantiate(ModulePrefab, this.transform.position, this.transform.rotation); //link ore extractor to deposit if (!String.IsNullOrEmpty(Data.DepositInstanceID)) { OreExtractor drill = newT.GetComponent <OreExtractor>(); if (drill != null) { drill.InitializeDeposit(Data.DepositInstanceID); } } newT.GetComponent <IBuildable>().InitializeStartingData(); if (ZoneThatPlayerIsStandingIn == this) { ZoneThatPlayerIsStandingIn = null; GuiBridge.Instance.HideConstruction(); } Game.Current.Score.ModulesBuilt++; //copy the requirements by adding them to a dictionary Dictionary <Matter, float> matterToVolumeMap = Construction.BuildData[Data.ModuleTypeUnderConstruction].Requirements.ToDictionary(x => x.Type, y => y.AmountByVolume); //copy the resource list by toArray it ResourceComponent[] components = ResourceList.ToArray(); //go backwards through the components for (int i = components.Length - 1; i > -1; i--) { ResourceComponent component = components[i]; float volumeToPull = 0f; //if the component is used in the requirements if (matterToVolumeMap.TryGetValue(component.Data.Container.MatterType, out volumeToPull) && volumeToPull > 0f) { //decrease the matterToVolumeMap by as much pull as possible matterToVolumeMap[component.Data.Container.MatterType] -= component.Data.Container.Pull(volumeToPull); //then if the crate is spent if (component.Data.Container.CurrentAmount <= 0f) { //delete it Destroy(component.gameObject); } //if the requirement is met if (matterToVolumeMap[component.Data.Container.MatterType] <= 0f) { //remove the requirement (to stop the next component from depleting any) matterToVolumeMap.Remove(component.Data.Container.MatterType); } } } if (matterToVolumeMap.Keys.Count > 0) { Debug.LogError("Construction zone built something but had requirements left over!"); } this.ResourceList = null; Destroy(this.gameObject); }