本文整理汇总了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;
}
}
示例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);
}
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例11: OnStart
public override void OnStart(PartModule.StartState state)
{
antimatter = part.Resources[InterstellarResourcesConfiguration.Instance.Antimatter];
if (state == StartState.Editor) return;
this.part.force_activate();
}
示例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;
}
示例13: OnStart
public override void OnStart(PartModule.StartState state)
{
if (state == StartState.Editor) {
return;
}
decay_resource = part.Resources[resourceName];
part.force_activate();
}
示例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;
}
}
示例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"];
}