当前位置: 首页>>代码示例>>C#>>正文


C# PartResource类代码示例

本文整理汇总了C#中PartResource的典型用法代码示例。如果您正苦于以下问题:C# PartResource类的具体用法?C# PartResource怎么用?C# PartResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PartResource类属于命名空间,在下文中一共展示了PartResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetState

 private void SetState(PartResource.FlowMode state)
 {
     List<string> blacklist = this.resourceBlacklist.Split(',').ToList();
     List<PartResource> valid = null;
     for (int i = 0; i < base.part.Resources.list.Count; i++)
     {
         PartResource res = base.part.Resources.list[i];
         if (!blacklist.Contains(res.resourceName) && res.info.resourceFlowMode != ResourceFlowMode.NO_FLOW)
         {
             if (this.resourceName == "ALL" || res.resourceName == this.resourceName)
             {
                 res.flowMode = state;
                 return;
             }
             else if (this.resourceName == "ANY")
             {
                 if (valid == null)
                 {
                     valid = new List<PartResource>();
                 }
                 valid.Add(res);
             }
         }
     }
     if (this.resourceName == "ANY" && valid != null)
     {
         Random ran = new Random();
         int roll = ran.Next(0, valid.Count);
         valid[roll].flowMode = state;
     }
 }
开发者ID:KSP-RO,项目名称:TestFlight,代码行数:31,代码来源:TestFlightFailure_ResourcePump.cs

示例2: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            double time_diff = lastActiveTime - Planetarium.GetUniversalTime();

            if (state == StartState.Editor)
                return;

            if (part.Resources.Contains(resourceName))
                decay_resource = part.Resources[resourceName];
            else
            {
                decay_resource = null;
                return;
            }

            resourceDefinitionsContainDecayProduct = PartResourceLibrary.Instance.resourceDefinitions.Contains(decayProduct);
            if (resourceDefinitionsContainDecayProduct)
                density_rat = decay_resource.info.density / PartResourceLibrary.Instance.GetDefinition(decayProduct).density;

            if (decay_resource != null && time_diff > 0)
            {
                double n_0 = decay_resource.amount;
                decay_resource.amount = n_0 * Math.Exp(-decayConstant * time_diff);
                double n_change = n_0 - decay_resource.amount;

                if (resourceDefinitionsContainDecayProduct)
                    ORSHelper.fixedRequestResource(part, decayProduct, -n_change * density_rat);
            }
        }
开发者ID:Kerbas-ad-astra,项目名称:KSPInterstellar,代码行数:29,代码来源:ModuleElementRadioactiveDecay.cs

示例3: Setup

        // ReSharper disable ParameterHidesMember
        public override void Setup(UIPartActionWindow window, Part part, UI_Scene scene, UI_Control control, PartResource resource)
        {
            double amount = resource.amount;
            base.Setup(window, part, scene, control, resource);
            this.resource.amount = amount;

            slider.SetValueChangedDelegate(OnSliderChanged);
        }
开发者ID:kevin-ye,项目名称:KSPAPIExtensions,代码行数:9,代码来源:UIPartActionsExtended.cs

示例4: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor) { return; }
            this.part.force_activate();

            PartResourceList prl = part.Resources;

            foreach (PartResource wanted_resource in prl) {
                if (wanted_resource.resourceName == "IntakeAtm") {
                    intake_atm = wanted_resource;
                }
            }
        }
开发者ID:kevin-ye,项目名称:KSPInterstellar,代码行数:13,代码来源:AtmosphericIntake.cs

示例5: AddResource

        public static PartResource AddResource(this Part part, PartResourceDefinition info, float maxAmount, float amount)
        {
            PartResource resource = new PartResource(part);
            resource.SetInfo(info);
            resource.maxAmount = maxAmount;
            resource.amount = amount;
            resource.flowState = true;
            resource.isTweakable = info.isTweakable;
            resource.isVisible = info.isVisible;
            resource.hideFlow = false;
            resource.flowMode = PartResource.FlowMode.Both;
            part.Resources.dict.Add(info.name.GetHashCode(), resource);

            return resource;
        }
开发者ID:blowfishpro,项目名称:B9PartSwitch,代码行数:15,代码来源:PartExtensions.cs

示例6: OnStart

        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            GameEvents.onVesselChange.Add(new EventData<Vessel>.OnEvent(this.OnVesselChange));

            if (state == StartState.Editor)
            {
                Events["paintEvent"].active = false;
                return;
            }

            _paintResource = PartResourceLibrary.Instance.GetDefinition("SpacePaint");
            _paint = this.part.Resources.Get(_paintResource.id);
            setPaintState();

            if (Global.Debug3) Utils.Log("paint resource id: {0}", _paintResource);
            if (Global.Debug3) Utils.Log("paint: {0}/{1}", _paint.amount, _paint.maxAmount);
        }
开发者ID:panteras1000,项目名称:TheWriteStuff,代码行数:19,代码来源:ASPPainter.cs

示例7: OnStart

        public override void OnStart(PartModule.StartState state) {
            if (state == StartState.Editor) {
                return;
            }
            decay_resource = part.Resources[resourceName];
            part.force_activate();   
            
            if (PartResourceLibrary.Instance.resourceDefinitions.Contains(decayProduct)) {
                density_rat = decay_resource.info.density / PartResourceLibrary.Instance.GetDefinition(decayProduct).density;
            }

			double time_diff = Planetarium.GetUniversalTime() - lastActiveTime;
            if (time_diff > 0) {
				double decay_amount = decayWithProductionRate(time_diff);
				ORSHelper.fixedRequestResource(part, decayProduct, -decay_amount*density_rat);
				decay_resource.amount -= decay_amount;
            }

			lastActiveTime = (float) Planetarium.GetUniversalTime();
        }
开发者ID:Elecner,项目名称:KSPInterstellar,代码行数:20,代码来源:ModuleElementRadioactiveDecay.cs

示例8: OnStart

        /// <summary>
        /// Called when this part is started.
        /// </summary>
        /// <param name="state">The start state.</param>
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);

            foreach (PartResource r in part.Resources)
            {
                if (r.resourceName == "RocketParts")
                {
                    rocketParts = r;
                    break;
                }
            }

            if (!rocketParts)
            {
                Logger.DebugError("Cannot find RocketParts resource on \"" + part.name + "\"!");
            }

            rocketParts.flowMode = PartResource.FlowMode.Both;
            part.fuelCrossFeed = false;
        }
开发者ID:panarchist,项目名称:KerbalMechanics,代码行数:25,代码来源:ModuleRocketPartsContainer.cs

示例9: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            containerStates = SetUpAnimation(ContainerAnimationName, this.part);

            foreach(PartResource pr in part.Resources)  //finds which resource has been specified
            {
                if (pr.resourceName.Equals (ResourceType))
                {
                    animatedResource = pr;
                    break;
                }
            }

            resMax = animatedResource.maxAmount;
            resAmount = animatedResource.amount;
            normalizedRes = resAmount/resMax;
            foreach (var cs in containerStates)
            {
                cs.normalizedTime = (float)normalizedRes;
            }
        }
开发者ID:RichardDastardly,项目名称:BDAnimationModules,代码行数:21,代码来源:AnimatedContainer.cs

示例10: OnStart

        public override void OnStart(PartModule.StartState state) {
            deuterium = part.Resources["Deuterium"];
            he3 = part.Resources["Helium-3"];
            un = part.Resources["EnrichedUranium"];
            base.OnStart(state);
            /*
            lightGameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            lightGameObject.collider.enabled = false;
            lightGameObject.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            lightGameObject.AddComponent<Light>();
            lightGameObject.renderer.material.shader = Shader.Find("Unlit/Transparent");
            lightGameObject.renderer.material.mainTexture = GameDatabase.Instance.GetTexture("Interstellar/explode2", false);
            lightGameObject.renderer.material.color = new Color(Color.white.r, Color.white.g, Color.white.b, 0.9f);
            lightGameObject.renderer.enabled = false;
            light = lightGameObject.light;
            lightGameObject.transform.position = part.transform.position;
            light.type = LightType.Point;
            light.color = new Color(Color.white.r, Color.white.g, 0.87f, 1f);
            light.range = 1f;
            light.intensity = 50.0f;
            light.renderMode = LightRenderMode.ForcePixel;
             
            convert_charged_to_thermal = false;
            Destroy (lightGameObject.collider, 0.25f);
            Destroy(lightGameObject, 0.1f);
            */
            antimatter_rate = resourceRate * GameConstants.antimatter_initiated_antimatter_cons_constant*86400/1000000;
            d_he3_rate = resourceRate * GameConstants.antimatter_initiated_d_he3_cons_constant*86400;
            un_rate = resourceRate * GameConstants.antimatter_initiated_eu_cons_constant*86400;
            upgraded_d_he3_rate = upgradedResourceRate * GameConstants.antimatter_initiated_upgraded_eu_cons_constant;
            upgraded_amat_rate = upgradedResourceRate * GameConstants.antimatter_initiated_antimatter_cons_constant * 86400 / 1000000;


        }
开发者ID:Joeppie,项目名称:KSPInterstellar,代码行数:34,代码来源:FNAmatCatFissionFusionReactor.cs

示例11: OnStart

		public override void OnStart(PartModule.StartState state) 
        {
            antimatter = part.Resources[InterstellarResourcesConfiguration.Instance.Antimatter];

            if (state == StartState.Editor) return;
            this.part.force_activate();
		}
开发者ID:Yitscar,项目名称:KSPInterstellar,代码行数:7,代码来源:AntimatterStorageTank.cs

示例12: OnStart

 public override void OnStart(PartModule.StartState state) {
     uranium_mononitride = part.Resources["UraniumNitride"];
     depleted_fuel = part.Resources["DepletedFuel"];
     base.OnStart(state);
     initial_thermal_power = ThermalPower;
     initial_resource_rate = resourceRate;
 }
开发者ID:bfrobin446,项目名称:KSPInterstellar,代码行数:7,代码来源:FNPFissionReactor.cs

示例13: OnStart

 public override void OnStart(PartModule.StartState state)
 {
     if (state == StartState.Editor) {
         return;
     }
     decay_resource = part.Resources[resourceName];
     part.force_activate();
 }
开发者ID:ripsbusk,项目名称:KSPInterstellar,代码行数:8,代码来源:ModuleElementRadioactiveDecay.cs

示例14: OnStart

 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     resource = part.Resources[resourceName];
     if (isDecoupled)
     {
         Events["jettisonEvent"].active = false;
         Actions["jettisonAction"].active = false;
     }            
 }
开发者ID:SixDasher,项目名称:SSTULabs,代码行数:10,代码来源:SSTUAutoDepletionDecoupler.cs

示例15: OnStart

        //This is a simple module that automatically converts recyclables into machinery.
        //It's primary use is for MKS Lite.
        public override void OnStart(StartState state)
        {
            if (!part.Resources.Contains("Machinery"))
                return;
            if (!part.Resources.Contains("Recyclables"))
                return;
            if (part.FindModulesImplementing<BaseConverter>().Count == 0)
                return;

            _convertResources = true;
            _inRes = part.Resources["Recyclables"];
            _outRes = part.Resources["Machinery"];
        }
开发者ID:BobPalmer,项目名称:MKS,代码行数:15,代码来源:MksAutoRepair.cs


注:本文中的PartResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。