updatePartResourceDisplay() public static method

public static updatePartResourceDisplay ( Part part ) : void
part Part
return void
Exemplo n.º 1
0
        private void updateResourceAmounts(double mult)
        {
            int len = part.Resources.Count;

            for (int i = 0; i < len; i++)
            {
                part.Resources[i].maxAmount *= mult;
            }
            SSTUModInterop.updatePartResourceDisplay(part);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Actually set the resources from this list to the input part; if the current part resources match this list exactly they will be updated in-place,
        /// else all resources from the part will be cleared and the new list of resources added.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="fill"></param>
        public void setResourcesToPart(Part part, float modifier, bool keepExisting)
        {
            removeUnusedResources(part);
            int len = resourceList.Count;

            foreach (ResourceListEntry rle in resourceList.Values)
            {
                rle.applyToPart(part, modifier, keepExisting);
            }
            SSTUModInterop.updatePartResourceDisplay(part);
        }
Exemplo n.º 3
0
        public void setResourcesToPart(Part part, float modifier, bool keepExisting, string[] blacklist)
        {
            removeUnusedResources(part, blacklist);
            int len = resourceList.Count;

            foreach (ResourceListEntry rle in resourceList.Values)
            {
                rle.applyToPart(part, modifier, keepExisting);
            }
            SSTUModInterop.updatePartResourceDisplay(part);
            //GameEvents.onPartResourceListChange.Fire(part);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Actually set the resources from this list to the input part; if the current part resources match this list exactly they will be updated in-place,
        /// else all resources from the part will be cleared and the new list of resources added.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="fill"></param>
        public void setResourcesToPart(Part part)
        {
            int len = part.Resources.Count;

            if (len == resourceList.Count)//potentially the same resources exist as we are trying to setup
            {
                bool foundAll = true;
                foreach (String name in resourceList.Keys)
                {
                    ResourceListEntry entry = resourceList[name];
                    if (part.Resources.Contains(name))//go ahead and set them as found; if not all are found we'll delete them anyway...
                    {
                        PartResource pr = part.Resources[name];
                        pr.maxAmount = entry.max;
                        pr.amount    = entry.fill;
                    }
                    else
                    {
                        foundAll = false;
                        break;
                    }
                }
                if (foundAll)
                {
                    SSTUModInterop.updatePartResourceDisplay(part);
                    return;
                }
            }
            part.Resources.list.Clear();
            PartResource[] resources = part.GetComponents <PartResource>();
            len = resources.Length;
            for (int i = 0; i < len; i++)
            {
                GameObject.Destroy(resources[i]);
            }
            ConfigNode resourceNode;

            foreach (String name in resourceList.Keys)
            {
                ResourceListEntry entry = resourceList[name];
                resourceNode = new ConfigNode("RESOURCE");
                resourceNode.AddValue("name", name);
                resourceNode.AddValue("maxAmount", entry.max);
                resourceNode.AddValue("amount", entry.fill);
                part.AddResource(resourceNode);
            }
            SSTUModInterop.updatePartResourceDisplay(part);
        }
Exemplo n.º 5
0
        private void updatePartResources()
        {
            if (heatSoak)
            {
                return;
            }                        //dont touch resources on heat-soak type setups
            float        scale  = Mathf.Pow(getScale(), resourceScalePower);
            float        amount = baseResourceQuantity * scale * currentShieldTypeData.resourceMult;
            PartResource res    = part.Resources[resourceName];

            if (res == null)
            {
                MonoBehaviour.print("SEVERE ERROR: ModularHeatShield could not set resource, as no resource was found in part for name: " + resourceName);
            }
            else
            {
                res.amount = res.maxAmount = amount;
            }
            SSTUModInterop.updatePartResourceDisplay(part);
        }