コード例 #1
0
        /// <summary>
        /// If BackgroundProcessing Mod is installed do nothing.
        /// Otherwise as long as time isn't paused we generate ElectricCharge for all cached vessels.
        /// </summary>
        public void FixedUpdate()
        {
            if (BackgroundProcessingInstalled)
            {
                if (!loggedBackgroundProcessing)
                {
                    Utilities.Log("BackgroundProcessing Mod installed. BackgroundResources not producing unloaded vessel resources.\nIt is recommended you remove BackgroundProcessing mod.");
                    loggedBackgroundProcessing = true;
                }
                return;
            }

            if (FlightGlobals.fetch != null && !gamePaused)
            {
                //***ENABLE THIS WHEN WE WANT THIS MOD TO GO STAND ALONE

                /*
                 * if (HighLogic.LoadedSceneIsGame && UnloadedResources.Instance.bgrSettings.backgroundresources)
                 * {
                 *  UpdateInterestedVessels();
                 * }*/
                //Generate EC
                Dictionary <ProtoVessel, InterestedVessel> .Enumerator vslenumerator = InterestedVessels.GetDictEnumerator();
                while (vslenumerator.MoveNext())
                {
                    if (vslenumerator.Current.Value.ModuleHandlers.Count > 0)
                    {
                        UpdateResourceCacheOverflows(vslenumerator.Current.Value);
                        ProcessInterestedModules(vslenumerator.Current.Value);
                    }
                }
                vslenumerator.Dispose();
            }
        }
コード例 #2
0
        /// <summary>
        /// If BackgroundProcessing Mod is installed do nothing.
        /// Otherwise as long as time isn't paused we generate ElectricCharge for all cached vessels.
        /// </summary>
        public void FixedUpdate()
        {
            if (BackgroundProcessingInstalled)
            {
                if (!loggedBackgroundProcessing)
                {
                    Utilities.Log("BackgroundProcessing Mod installed. BackgroundResources not producing unloaded vessel resources.\nIt is recommended you remove BackgroundProcessing mod.");
                    loggedBackgroundProcessing = true;
                }
                return;
            }

            if (FlightGlobals.fetch != null && !gamePaused)
            {
                //Generate EC
                Dictionary <ProtoVessel, InterestedVessel> .Enumerator vslenumerator = InterestedVessels.GetDictEnumerator();
                while (vslenumerator.MoveNext())
                {
                    if (vslenumerator.Current.Value.ModuleHandlers.Count > 0)
                    {
                        UpdateResourceCacheOverflows(vslenumerator.Current.Value);
                        ProcessInterestedModules(vslenumerator.Current.Value);
                    }
                }
                vslenumerator.Dispose();
            }
        }
コード例 #3
0
        private void Update()
        {
            if (!transferButton && !hoverHighlight)
            {
                return;
            }

            var enumerator = currentCrew.GetDictEnumerator();

            while (enumerator.MoveNext())
            {
                KerbalTrait k = enumerator.Current.Value;

                if (k == null)
                {
                    continue;
                }

                if (k.Portrait.hoverArea.Hover)
                {
                    if (extendedTooltips)
                    {
                        k.Portrait.tooltip.descriptionString = k.CachedTooltip + extraTooltip(k);
                    }

                    if (transferButton)
                    {
                        Vessel v = k.Crew.InPart.vessel;

                        if (v.GetCrewCapacity() > v.GetCrewCount())
                        {
                            if (!k.TransferButton.gameObject.activeSelf)
                            {
                                k.TransferButton.gameObject.SetActive(true);
                            }
                        }
                        else if (k.TransferButton.gameObject.activeSelf)
                        {
                            k.TransferButton.gameObject.SetActive(false);
                        }
                    }

                    k.setHighlight(hoverHighlight);
                }
                else
                {
                    k.setHighlight(false);
                }
            }
        }
コード例 #4
0
        public override void UpdateWaypoints(bool focused)
        {
            if (!useWaypoints)
            {
                return;
            }

            var enumerator = wps.GetDictEnumerator();

            while (enumerator.MoveNext())
            {
                var pair = enumerator.Current;

                Vessel v = pair.Key;

                if (v == null)
                {
                    continue;
                }

                Waypoint wp = pair.Value;

                if (wp == null)
                {
                    wp     = setupNewWaypoint(v);
                    wps[v] = wp;
                }

                Orbit o;

                if (v.loaded)
                {
                    o = v.orbit;
                }
                else
                {
                    o = v.protoVessel.orbitSnapShot.Load();
                }

                wp.celestialName = TargetBody.GetName();
                wp.isOnSurface   = false;
                wp.orbitPosition = o.getPositionAtUT(Planetarium.GetUniversalTime());
            }
        }
コード例 #5
0
            public static CacheResource Load(ConfigNode node, ProtoVessel protoVessel)
            {
                string resName = "";

                node.TryGetValue("resourceName", ref resName);
                double amt    = 0;
                double maxamt = 0;

                node.TryGetValue("amount", ref amt);
                node.TryGetValue("maxAmount", ref maxamt);
                DictionaryValueList <string, ProtoPartResourceSnapshot> protoresSnapshots = new DictionaryValueList <string, ProtoPartResourceSnapshot>();

                ConfigNode[] protoresourcesnapNodes = node.GetNodes("RESOURCE");
                for (int rsI = 0; rsI < protoresourcesnapNodes.Length; rsI++)
                {
                    string keyField = protoresourcesnapNodes[rsI].GetValue("craftID");
                    ProtoPartResourceSnapshot protoresSnap       = new ProtoPartResourceSnapshot(protoresourcesnapNodes[rsI]);
                    ProtoPartResourceSnapshot protoVesselResSnap = GetMatchingResourceSnapShot(keyField, protoresSnap, protoVessel);
                    if (protoVesselResSnap != null)
                    {
                        protoresSnapshots.Add(keyField, protoVesselResSnap);
                    }
                }
                if (protoresSnapshots.Count > 0)
                {
                    Dictionary <string, ProtoPartResourceSnapshot> .Enumerator ppRSenumerator = protoresSnapshots.GetDictEnumerator();
                    ppRSenumerator.MoveNext();
                    string        resourceKey      = "";
                    uint          craftID          = CacheResource.RetrieveKey(ppRSenumerator.Current.Key, out resourceKey);
                    CacheResource newCacheResource = new CacheResource(craftID, ppRSenumerator.Current.Value, resName, amt, maxamt);
                    while (ppRSenumerator.MoveNext())
                    {
                        newCacheResource.protoPartResourceSnapshot.Add(ppRSenumerator.Current.Key, ppRSenumerator.Current.Value);
                    }
                    ppRSenumerator.Dispose();
                    return(newCacheResource);
                }
                return(null);
            }
コード例 #6
0
            public ConfigNode Save(ConfigNode Savenode)
            {
                ConfigNode node = Savenode.AddNode("CACHERESOURCE");

                node.AddValue("resourceName", resourceName);
                node.AddValue("amount", amount);
                node.AddValue("maxAmount", maxAmount);
                Dictionary <string, ProtoPartResourceSnapshot> .Enumerator ppRSenumerator = protoPartResourceSnapshot.GetDictEnumerator();
                while (ppRSenumerator.MoveNext())
                {
                    ConfigNode resourceNode = node.AddNode("RESOURCE");
                    resourceNode.AddValue("craftID", ppRSenumerator.Current.Key);
                    ppRSenumerator.Current.Value.Save(resourceNode);
                }
                ppRSenumerator.Dispose();
                return(node);
            }