• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PartResource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PartResource类属于命名空间,在下文中一共展示了PartResource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: ResourceValue

 public ResourceValue(PartResource partResource)
     : this(partResource.resourceName)
 {
     amount = partResource.amount;
     capacity = partResource.maxAmount;
 }
开发者ID:jwvanderbeck,项目名称:KOS_old,代码行数:6,代码来源:ResourceValue.cs


示例11: AddResource

 public void AddResource(PartResource resource)
 {
     amount += resource.amount;
     capacity += resource.maxAmount;
 }
开发者ID:jwvanderbeck,项目名称:KOS_old,代码行数:5,代码来源:ResourceValue.cs


示例12: CommonResource

 public CommonResource(PartResource targetResource, List<PartResource> localResList)
 {
     this.TargetPartResource = targetResource;
     this.LocalPartResources = localResList;
 }
开发者ID:Bear67,项目名称:KSP-KERT,代码行数:5,代码来源:KerbalTransferAddon.cs


示例13: FuelTanksInterface


//.........这里部分代码省略.........
            }
            GUILayout.EndScrollView();

            if (fOxFMax > 0 || fLqFMax > 0 || fMoFMax > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Transfer Rate", LabelInfo);

                GUI.enabled = (fTransferRate != 0.01f);
                if (GUILayout.Button(" x1", GUILayout.Height(18)))
                {
                    fTransferRate = 0.01f;
                    PersistenceUtils.saveStaticPersistence(selectedObject);
                    smessage = "Fuel transfer rate set to x1";
                    ScreenMessages.PostScreenMessage(smessage, 10, smsStyle);
                }
                GUI.enabled = (fTransferRate != 0.04f);
                if (GUILayout.Button(" x4", GUILayout.Height(18)))
                {
                    fTransferRate = 0.04f;
                    PersistenceUtils.saveStaticPersistence(selectedObject);
                    smessage = "Fuel transfer rate set to x4";
                    ScreenMessages.PostScreenMessage(smessage, 10, smsStyle);
                }
                GUI.enabled = (fTransferRate != 0.1f);
                if (GUILayout.Button("x10", GUILayout.Height(18)))
                {
                    fTransferRate = 0.1f;
                    PersistenceUtils.saveStaticPersistence(selectedObject);
                    smessage = "Fuel transfer rate set to x10";
                    ScreenMessages.PostScreenMessage(smessage, 10, smsStyle);
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();

                if (!FlightGlobals.ActiveVessel.isEVA && FlightGlobals.ActiveVessel.Landed)
                {
                    GUILayout.Label(FlightGlobals.ActiveVessel.vesselName + "'s Tanks", LabelInfo);

                    scrollPos3 = GUILayout.BeginScrollView(scrollPos3);
                    foreach (Part fTank in FlightGlobals.ActiveVessel.parts)
                    {
                        foreach (PartResource rResource in fTank.Resources)
                        {
                            if (rResource.resourceName == "LiquidFuel" || rResource.resourceName == "Oxidizer" || rResource.resourceName == "MonoPropellant")
                            {
                                if (SelectedTank == fTank && SelectedResource == rResource)
                                    PartSelected = true;
                                else
                                    PartSelected = false;

                                GUILayout.BeginHorizontal();
                                GUILayout.Box("" + fTank.gameObject.name, GUILayout.Height(18));
                                GUILayout.Box("" + rResource.resourceName, GUILayout.Height(18));
                                GUILayout.EndHorizontal();

                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Fuel", LabelInfo);
                                GUI.enabled = false;
                                GUILayout.TextField("" + rResource.amount.ToString("#0.00"), GUILayout.Height(18));
                                GUI.enabled = true;

                                GUI.enabled = !PartSelected;
                                if (GUILayout.Button(" Select ", GUILayout.Height(18)))
                                {
                                    SelectedResource = rResource;
                                    SelectedTank = fTank;
                                    PersistenceUtils.saveStaticPersistence(selectedObject);
                                }

                                GUI.enabled = PartSelected;
                                if (GUILayout.Button("Deselect", GUILayout.Height(18)))
                                {
                                    SelectedResource = null;
                                    SelectedTank = null;
                                    PersistenceUtils.saveStaticPersistence(selectedObject);
                                }
                                GUI.enabled = true;
                                GUILayout.EndHorizontal();
                            }
                            else
                                continue;
                        }
                    }
                    GUILayout.EndScrollView();

                    GUI.enabled = true;

                    if (SelectedResource != null && SelectedTank != null)
                    {
                        if (bMoFOut || bOxFOut || bLqFOut)
                            doFuelOut(selectedObject);
                        if (bMoFIn || bOxFIn || bLqFIn)
                            doFuelIn(selectedObject);
                    }
                }
            }

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
开发者ID:ThomasKerman,项目名称:Kerbal-Konstructs_DEV,代码行数:101,代码来源:FuelTanksGUI.cs


示例14: Add

		public void Add(PartResource pr) {
			amount += pr.amount;
			maxAmount += pr.maxAmount;
		}
开发者ID:OverloadUT,项目名称:OATBeanCounter,代码行数:4,代码来源:BeanCounter.cs


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PartResourceDefinition类代码示例发布时间:2022-05-24
下一篇:
C# PartModule类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap