本文整理汇总了C#中AvailablePart类的典型用法代码示例。如果您正苦于以下问题:C# AvailablePart类的具体用法?C# AvailablePart怎么用?C# AvailablePart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AvailablePart类属于命名空间,在下文中一共展示了AvailablePart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDescription
public static string GetDescription(AvailablePart part)
{
var sb = new StringBuilder();
sb.AppendLine(part.title);
sb.AppendLine(part.description);
return sb.ToString();
}
示例2: ProcessFactoryPart
public static Blueprint ProcessFactoryPart(AvailablePart part)
{
var resources = new Dictionary<string, WorkshopResource>();
if (PartRecipes.ContainsKey(part.name))
{
var recipe = FactoryRecipes[part.name];
foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
{
if (resources.ContainsKey(workshopResource.Name))
{
resources[workshopResource.Name].Merge(workshopResource);
}
else
{
resources[workshopResource.Name] = workshopResource;
}
}
}
else
{
Debug.LogWarning("[OSE] - No FactoryRecipeFound for " + part.title);
return null;
}
var blueprint = new Blueprint();
blueprint.AddRange(resources.Values);
blueprint.Funds = Mathf.Max(part.cost - (float)blueprint.ResourceCosts(), 0);
return blueprint;
}
示例3: KIS_Item
/// <summary>Creates a new part from save.</summary>
public KIS_Item(AvailablePart availablePart, ConfigNode itemNode, ModuleKISInventory inventory,
float quantity = 1)
{
// Get part node
this.availablePart = availablePart;
partNode = new ConfigNode();
itemNode.GetNode("PART").CopyTo(partNode);
// init config
this.InitConfig(availablePart, inventory, quantity);
// Get mass
if (itemNode.HasValue("resourceMass")) {
resourceMass = float.Parse(itemNode.GetValue("resourceMass"));
} else {
resourceMass = availablePart.partPrefab.GetResourceMass();
}
if (itemNode.HasValue("contentMass")) {
contentMass = float.Parse(itemNode.GetValue("contentMass"));
}
if (itemNode.HasValue("contentCost")) {
contentCost = float.Parse(itemNode.GetValue("contentCost"));
}
if (itemNode.HasValue("inventoryName")) {
inventoryName = itemNode.GetValue("inventoryName");
}
}
示例4: GetParachuteDragFromPart
public static double GetParachuteDragFromPart(AvailablePart parachute)
{
/* foreach (AvailablePart.ModuleInfo mi in parachute.moduleInfos)
{
if (mi.info.Contains("Fully-Deployed Drag"))
{
string[] split = mi.info.Split(new Char[] { ':', '\n' });
for (int i = 0; i < split.Length; i++)
{
if (split[i].Contains("Fully-Deployed Drag"))
{
float drag = 500;
if (!float.TryParse(split[i + 1], out drag))
{
string[] split2 = split[i + 1].Split('>');
if (!float.TryParse(split2[1], out drag))
{
Debug.Log("[SR] Failure trying to read parachute data. Assuming 500 drag.");
drag = 500;
}
}
return drag;
}
}
}
}*/
double area = 0;
if (parachute.partPrefab.Modules.Contains("ModuleParachute"))
{
area = ((ModuleParachute)parachute.partPrefab.Modules["ModuleParachute"]).areaDeployed;
}
return area;
}
示例5: AddAlternator
void AddAlternator(ConfigNode node, AvailablePart aPart)
{
// Get or add module
ModuleReliabilityAlternator rModule = aPart.partPrefab.GetComponent<ModuleReliabilityAlternator>();
if (rModule)
{
Logger.DebugWarning("ModuleReliabilityAlternator already added to \"" + aPart.name + "\"!");
}
else
{
rModule = aPart.partPrefab.AddModule("ModuleReliabilityAlternator") as ModuleReliabilityAlternator;
if (!rModule)
{
Logger.DebugError("Problem adding module to engine!");
return;
}
}
//Configure the base values
ConfigureBaseValues(node, rModule);
if (node.HasValue("idleChanceToFailPerfect")) { rModule.idleChanceToFailPerfect = double.Parse(node.GetValue("idleChanceToFailPerfect")); }
if (node.HasValue("idleChanceToFailTerrible")) { rModule.idleChanceToFailTerrible = double.Parse(node.GetValue("idleChanceToFailTerrible")); }
if (node.HasValue("stressedChanceToFailPerfect")) { rModule.stressedChanceToFailPerfect = double.Parse(node.GetValue("stressedChanceToFailPerfect")); }
if (node.HasValue("stressedChanceToFailTerrible")) { rModule.stressedChanceToFailTerrible = double.Parse(node.GetValue("stressedChanceToFailTerrible")); }
if (node.HasValue("maxGeesPerfect")) { rModule.maxGeesPerfect = double.Parse(node.GetValue("maxGeesPerfect")); }
if (node.HasValue("maxGeesTerrible")) { rModule.maxGeesTerrible = double.Parse(node.GetValue("maxGeesTerrible")); }
}
示例6: DoUnlock
protected void DoUnlock(AvailablePart part)
{
ProtoTechNode ptn = ResearchAndDevelopment.Instance.GetTechState(part.TechRequired);
// The tech may be null - we need to create it
if (ptn == null)
{
ptn = new ProtoTechNode();
ptn.state = RDTech.State.Unavailable;
ptn.techID = part.TechRequired;
ptn.scienceCost = 9999; // ignored
}
if (unlockTech)
{
ptn.state = RDTech.State.Available;
}
if (!HighLogic.CurrentGame.Parameters.Difficulty.BypassEntryPurchaseAfterResearch && !ptn.partsPurchased.Contains(part))
{
ptn.partsPurchased.Add(part);
}
else
{
ptn.partsPurchased = new List<AvailablePart>();
}
ResearchAndDevelopment.Instance.SetTechState(part.TechRequired, ptn);
}
示例7: PartEntryCostHolder
public PartEntryCostHolder(ConfigNode node, AvailablePart part, string Name = "")
{
Load(node);
if(Name != "")
name = Name;
entryCost = part.entryCost;
ap = part;
}
示例8: ProcessPart
public static Blueprint ProcessPart(AvailablePart part)
{
var resources = new Dictionary<string, WorkshopResource>();
if (PartRecipes.ContainsKey(part.name))
{
var recipe = PartRecipes[part.name];
foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
{
if (resources.ContainsKey(workshopResource.Name))
{
resources[workshopResource.Name].Merge(workshopResource);
}
else
{
resources[workshopResource.Name] = workshopResource;
}
}
}
else
{
foreach (var workshopResource in DefaultPartRecipe.Prepare(part.partPrefab.mass))
{
if (resources.ContainsKey(workshopResource.Name))
{
resources[workshopResource.Name].Merge(workshopResource);
}
else
{
resources[workshopResource.Name] = workshopResource;
}
}
}
foreach (PartResource partResource in part.partPrefab.Resources)
{
if (ResourceRecipes.ContainsKey(partResource.resourceName))
{
var definition = PartResourceLibrary.Instance.GetDefinition(partResource.resourceName);
var recipe = ResourceRecipes[partResource.resourceName];
foreach (var workshopResource in recipe.Prepare(partResource.maxAmount * definition.density))
{
if (resources.ContainsKey(workshopResource.Name))
{
resources[workshopResource.Name].Merge(workshopResource);
}
else
{
resources[workshopResource.Name] = workshopResource;
}
}
}
}
var blueprint = new Blueprint();
blueprint.AddRange(resources.Values);
blueprint.Funds = Mathf.Max(0, part.cost - (float)blueprint.ResourceCosts());
return blueprint;
}
示例9: CreatePart
public static Part CreatePart(AvailablePart avPart, Vector3 position, Quaternion rotation, Part flagFromPart)
{
UnityEngine.Object obj = UnityEngine.Object.Instantiate(avPart.partPrefab);
if (!obj)
{
KAS_Shared.DebugError("CreatePart(Crate) Failed to instantiate " + avPart.partPrefab.name);
return null;
}
Part newPart = (Part)obj;
newPart.gameObject.SetActive(true);
newPart.gameObject.name = avPart.name;
newPart.partInfo = avPart;
newPart.highlightRecurse = true;
newPart.SetMirror(Vector3.one);
ShipConstruct newShip = new ShipConstruct();
newShip.Add(newPart);
newShip.SaveShip();
newShip.shipName = avPart.title;
newShip.shipType = 1;
VesselCrewManifest vessCrewManifest = new VesselCrewManifest();
Vessel currentVessel = FlightGlobals.ActiveVessel;
Vessel v = newShip.parts[0].localRoot.gameObject.AddComponent<Vessel>();
v.id = Guid.NewGuid();
v.vesselName = newShip.shipName;
v.Initialize(false);
v.Landed = true;
v.rootPart.flightID = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
v.rootPart.missionID = flagFromPart.missionID;
v.rootPart.flagURL = flagFromPart.flagURL;
//v.rootPart.collider.isTrigger = true;
//v.landedAt = "somewhere";
Staging.beginFlight();
newShip.parts[0].vessel.ResumeStaging();
Staging.GenerateStagingSequence(newShip.parts[0].localRoot);
Staging.RecalculateVesselStaging(newShip.parts[0].vessel);
FlightGlobals.SetActiveVessel(currentVessel);
v.SetPosition(position);
v.SetRotation(rotation);
// Solar panels from containers don't work otherwise
for (int i = 0; i < newPart.Modules.Count; i++)
{
ConfigNode node = new ConfigNode();
node.AddValue("name", newPart.Modules[i].moduleName);
newPart.LoadModule(node, i);
}
return newPart;
}
示例10: Load
public override bool Load(ConfigNode configNode)
{
// Load base class
bool valid = base.Load(configNode);
valid &= ConfigNodeUtil.ParseValue<AvailablePart>(configNode, "part", x => part = x, this);
return valid;
}
示例11: PartContent
private PartContent(AvailablePart avPart, KASModuleGrab grab)
{
part = avPart;
grabModule = grab;
pristine_mass = part.partPrefab.mass;
foreach (var res in part.partPrefab.GetComponents<PartResource>())
{
pristine_mass += (float)(res.amount * res.info.density);
}
}
示例12: EditorItemsFilter
private bool EditorItemsFilter(AvailablePart avPart)
{
if (avPartItems.Contains(avPart))
{
return true;
}
else
{
return false;
}
}
示例13: ItemDescription
public static void ItemDescription(AvailablePart part, string resourceName, double productivity)
{
GUILayout.BeginVertical();
var text = new StringBuilder();
text.AppendLine(part.title);
var density = PartResourceLibrary.Instance.GetDefinition(resourceName).density;
var requiredResources = (part.partPrefab.mass / density) * productivity;
text.AppendLine(" " + requiredResources.ToString("0.00") + " " + resourceName);
GUILayout.Box(text.ToString(), WorkshopStyles.Databox(), GUILayout.Width(250), GUILayout.Height(50));
GUILayout.EndVertical();
}
示例14: fixSader
private void fixSader(AvailablePart availablePart, string brokenShaderName, Shader fixShader)
{
// Debug.Log ("IconFixAddon : part: " + availablePart.name);
foreach (Renderer r in availablePart.iconPrefab.GetComponentsInChildren<Renderer>(true)) {
foreach (Material m in r.materials) {
if (m.shader.name == brokenShaderName) {
Debug.Log ("IconFixAddon: fixing icon of: " + availablePart.name);
m.shader = fixShader;
}
}
}
}
示例15: AddItem
public KISItemWrapper AddItem(AvailablePart aPart, ConfigNode configNode, float quantity = 1, int slot = -1)
{
return
KISItemWrapper.FromObject(_partModule.InvokeMethod("AddItem", new object[] { aPart, configNode, quantity, slot },
new[]
{
typeof (AvailablePart),
typeof (ConfigNode),
typeof (float),
typeof (int)
}));
}