SSTUTools.SSTUResourceList.setResource C# (CSharp) Method

setResource() public method

Blindly set the quanity of a resource. Adds new resource if not present, removes resource if present and max==0.
public setResource ( string name, float fill, float max ) : void
name string
fill float
max float
return void
        public void setResource(string name, float fill, float max)
        {
            if (max == 0) { removeResource(name); return; }
            if (fill > max) { fill = max; }
            if (resourceList.ContainsKey(name))
            {
                ResourceListEntry entry = resourceList[name];
                entry.fill = fill;
                entry.max = max;
            }
            else
            {
                ResourceListEntry entry = new ResourceListEntry(name, fill, max);
                resourceList.Add(entry.name, entry);
            }
        }