RaiseResourceListChanged() public method

public RaiseResourceListChanged ( ) : void
return void
コード例 #1
0
ファイル: FuelTank.cs プロジェクト: qipa/ModularFuelSystem
        void DeleteTank()
        {
            PartResource partResource = resource;

            // Delete it
            //Debug.LogWarning ("[MFT] Deleting tank from API " + name);
            maxAmountExpression = null;

            part.Resources.list.Remove(partResource);
            PartModule.DestroyImmediate(partResource);
            module.RaiseResourceListChanged();
            //print ("Removed.");

            // Update symmetry counterparts.
            if (HighLogic.LoadedSceneIsEditor && propagate)
            {
                foreach (Part sym in part.symmetryCounterparts)
                {
                    PartResource symResc = sym.Resources[name];
                    sym.Resources.list.Remove(symResc);
                    PartModule.DestroyImmediate(symResc);
                    PartMessageService.Send <PartResourceListChanged> (this, sym);
                }
            }
            //print ("Sym removed");
        }
コード例 #2
0
        void DeleteTank()
        {
            PartResource partResource = resource;

            // Delete it
            //Debug.LogWarning ("[MFT] Deleting tank from API " + name);
            maxAmountExpression = null;
            ModuleFuelTanks.UnmanagedResource unmanagedResource = null;

            if (module.unmanagedResources != null)
            {
                module.unmanagedResources.TryGetValue(partResource.resourceName, out unmanagedResource);
            }

            if (unmanagedResource == null)
            {
                // there are no unmanaged resources of this type so, business as usual
                part.Resources.Remove(partResource);
                part.SimulationResources.Remove(partResource);
            }
            else if (part.Resources.Contains(partResource.resourceName))
            {
                // part has a quantity of this resource which are unmanaged by MFT
                part.Resources[partResource.resourceName].amount    = unmanagedResource.amount;
                part.Resources[partResource.resourceName].maxAmount = unmanagedResource.maxAmount;
            }
            else
            {
                // probably shouldn't GET here since the part should already have this resource and we should always have left the unmanaged portion remaining.
                ConfigNode node = new ConfigNode("RESOURCE");
                node.AddValue("name", unmanagedResource.name);
                node.AddValue("amount", unmanagedResource.amount);
                node.AddValue("maxAmount", unmanagedResource.maxAmount);
                part.AddResource(node);
            }
            module.RaiseResourceListChanged();
            //print ("Removed.");

            // Update symmetry counterparts.
            if (HighLogic.LoadedSceneIsEditor && propagate)
            {
                foreach (Part sym in part.symmetryCounterparts)
                {
                    if (unmanagedResource == null)
                    {
                        PartResource symResc = sym.Resources[name];
                        sym.Resources.Remove(symResc);
                        sym.SimulationResources.Remove(symResc);
                    }
                    else if (part.Resources.Contains(partResource.resourceName))
                    {
                        sym.Resources[partResource.resourceName].amount    = unmanagedResource.amount;
                        sym.Resources[partResource.resourceName].maxAmount = unmanagedResource.maxAmount;
                    }
                    else
                    {
                        // probably shouldn't GET here since the part should already have this resource and we should always have left the unmanaged portion remaining.
                        ConfigNode node = new ConfigNode("RESOURCE");
                        node.AddValue("name", unmanagedResource.name);
                        node.AddValue("amount", unmanagedResource.amount);
                        node.AddValue("maxAmount", unmanagedResource.maxAmount);
                        sym.AddResource(node);
                    }
                    RaiseResourceListChanged(sym);
                }
            }
            //print ("Sym removed");
        }