public void FixedUpdate() { if (HighLogic.LoadedSceneIsEditor) { int nsym = part.symmetryCounterparts.Count; if (nsym == 0) { massDisplay = PFUtils.formatMass(part.mass); costDisplay = PFUtils.formatCost(part.partInfo.cost + GetModuleCost()); } else if (nsym == 1) { massDisplay = PFUtils.formatMass(part.mass * 2) + " (both)"; costDisplay = PFUtils.formatCost((part.partInfo.cost + GetModuleCost()) * 2) + " (both)"; } else { massDisplay = PFUtils.formatMass(part.mass * (nsym + 1)) + " (all " + (nsym + 1) + ")"; costDisplay = PFUtils.formatCost((part.partInfo.cost + GetModuleCost()) * (nsym + 1)) + " (all " + (nsym + 1) + ")"; } } }
public virtual void resizePart(float scale) { oldSize = size; part.mass = totalMass = ((specificMass.x * scale + specificMass.y) * scale + specificMass.z) * scale + specificMass.w; massDisplay = PFUtils.formatMass(totalMass); costDisplay = PFUtils.formatCost(part.partInfo.cost + GetModuleCost(part.partInfo.cost, ModifierStagingSituation.CURRENT) + part.partInfo.cost); part.breakingForce = specificBreakingForce * Mathf.Pow(scale, 2); part.breakingTorque = specificBreakingTorque * Mathf.Pow(scale, 2); var model = part.FindModelTransform("model"); if (model != null) { model.localScale = Vector3.one * scale; } else { Debug.LogError("[PF]: No 'model' transform found in part!", this); } part.rescaleFactor = scale; scaleNode(part.FindAttachNode("top"), scale, true); scaleNode(part.FindAttachNode("bottom"), scale, true); var nodes = part.FindAttachNodes("interstage"); if (nodes != null) { for (int i = 0; i < nodes.Length; i++) { scaleNode(nodes [i], scale, true); } } }
public virtual void resizePart(float scale) { oldSize = size; part.mass = ((specificMass.x * scale + specificMass.y) * scale + specificMass.z) * scale + specificMass.w; massDisplay = PFUtils.formatMass(part.mass); costDisplay = PFUtils.formatCost(GetModuleCost() + part.partInfo.cost); part.breakingForce = specificBreakingForce * Mathf.Pow(scale, 2); part.breakingTorque = specificBreakingTorque * Mathf.Pow(scale, 2); var model = part.FindModelTransform("model"); if (model != null) { model.localScale = Vector3.one * scale; } else { Debug.LogError("[KzPartResizer] No 'model' transform in the part", this); } scaleNode(part.findAttachNode("top"), scale, true); scaleNode(part.findAttachNode("bottom"), scale, true); }
public override void updateShape() { base.updateShape(); float sth = calcSideThickness(); float br = baseSize * 0.5f - sth; float scale = br * 2; part.mass = totalMass = ((specificMass.x * scale + specificMass.y) * scale + specificMass.z) * scale + specificMass.w; massDisplay = PFUtils.formatMass(totalMass); costDisplay = PFUtils.formatCost(part.partInfo.cost + GetModuleCost(part.partInfo.cost, ModifierStagingSituation.CURRENT)); part.breakingForce = specificBreakingForce * Mathf.Pow(br, 2); part.breakingTorque = specificBreakingTorque * Mathf.Pow(br, 2); var model = part.FindModelTransform("model"); if (model != null) { model.localScale = Vector3.one * scale; } else { Debug.LogError("[PF]: No 'model' transform found in part!", this); } part.rescaleFactor = scale; var node = part.FindAttachNode("top"); node.position = node.originalPosition * scale; if (!justLoaded) { PFUtils.updateAttachedPartPos(node, part); } var topNode = part.FindAttachNode("top"); var bottomNode = part.FindAttachNode("bottom"); float y = (topNode.position.y + bottomNode.position.y) * 0.5f; int sideNodeSize = Mathf.RoundToInt(scale / diameterStepLarge) - 1; if (sideNodeSize < 0) { sideNodeSize = 0; } var nodes = part.FindAttachNodes("connect"); if (nodes != null) { for (int i = 0; i < nodes.Length; i++) { var n = nodes [i]; n.position.y = y; n.size = sideNodeSize; if (!justLoaded) { PFUtils.updateAttachedPartPos(n, part); } } } var topnode2 = part.FindAttachNode(topNodeName); var internodes = part.FindAttachNodes("interstage"); if (internodes != null && topnode2 != null) { var topheight = topNode.position.y; var topnode2height = topnode2.position.y; var inc = (topnode2height - topheight) / (internodes.Length / 2 + 1); for (int i = 0, j = 0; i < internodes.Length; i = i + 2) { var baseHeight = topheight + (j + 1) * inc; j++; node = internodes [i]; node.position.y = baseHeight; node.size = topNode.size; if (!justLoaded) { PFUtils.updateAttachedPartPos(node, part); } node = internodes [i + 1]; node.position.y = baseHeight; node.size = sideNodeSize; if (!justLoaded) { PFUtils.updateAttachedPartPos(node, part); } } } var nnt = part.GetComponent <KzNodeNumberTweaker>(); if (nnt) { nnt.radius = baseSize * 0.5f; } var fbase = part.GetComponent <ProceduralFairingBase>(); if (fbase) { fbase.baseSize = br * 2; fbase.sideThickness = sth; fbase.needShapeUpdate = true; } StartCoroutine(PFUtils.updateDragCubeCoroutine(part, dragAreaScale)); }
public override void updateShape() { base.updateShape(); float sth = calcSideThickness(); float br = baseSize * 0.5f - sth; float scale = br * 2; part.mass = ((specificMass.x * scale + specificMass.y) * scale + specificMass.z) * scale + specificMass.w; massDisplay = PFUtils.formatMass(part.mass); costDisplay = PFUtils.formatCost(part.partInfo.cost + GetModuleCost()); part.breakingForce = specificBreakingForce * Mathf.Pow(br, 2); part.breakingTorque = specificBreakingTorque * Mathf.Pow(br, 2); var model = part.FindModelTransform("model"); if (model != null) { model.localScale = Vector3.one * scale; } else { Debug.LogError("[ProceduralFairingAdapter] No 'model' transform in the part", this); } var node = part.findAttachNode("top"); node.position = node.originalPosition * scale; if (!justLoaded) { PFUtils.updateAttachedPartPos(node, part); } var topNode = part.findAttachNode("top"); var bottomNode = part.findAttachNode("bottom"); float y = (topNode.position.y + bottomNode.position.y) * 0.5f; int sideNodeSize = Mathf.RoundToInt(scale / diameterStepLarge) - 1; if (sideNodeSize < 0) { sideNodeSize = 0; } foreach (var n in part.findAttachNodes("connect")) { n.position.y = y; n.size = sideNodeSize; if (!justLoaded) { PFUtils.updateAttachedPartPos(n, part); } } var nnt = part.GetComponent <KzNodeNumberTweaker>(); if (nnt) { nnt.radius = baseSize * 0.5f; } var fbase = part.GetComponent <ProceduralFairingBase>(); if (fbase) { fbase.baseSize = br * 2; fbase.sideThickness = sth; fbase.updateDelay = 0; } }