本文整理汇总了C#中Part.findAttachNodeByPart方法的典型用法代码示例。如果您正苦于以下问题:C# Part.findAttachNodeByPart方法的具体用法?C# Part.findAttachNodeByPart怎么用?C# Part.findAttachNodeByPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.findAttachNodeByPart方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateNode
public void UpdateNode()
{
//update node
node.size = 0; //force node size to be zero; otherwise the Kraken comes when inflating
node.position = pT.InverseTransformPoint(nT.position);
node.originalPosition = node.position;
//update attached parts
attached_part = node.attachedPart;
if(attached_part != null)
attached_node = attached_part.findAttachNodeByPart(part);
if(!UpdateJoint()) UpdatePartsPos();
}
示例2: ProcessPart
// A method that is called recursively to walk the part tree, and allocate parts to habitable spaces
private void ProcessPart(Part p, CLSSpace currentSpace , bool dockedToParent=false)
{
CLSSpace thisSpace = null;
CLSPart newPart = new CLSPart(p);
//Debug.Log("Processing part: " + p.name + " Navigable:"+newPart.Navigable + " Habitable:" + newPart.Habitable);
// First add this part to the list of all parts for the vessel.
this.listParts.Add(newPart);
// Is the part capable of allowing kerbals to pass? If it is add it to the current space, or if there is no current space, to a new space.
if (newPart.Navigable)
{
thisSpace = currentSpace;
if (null == thisSpace)
{
thisSpace = AddPartToNewSpace(newPart);
}
else
{
thisSpace = AddPartToSpace(newPart, thisSpace);
}
}
// Now loop through each of the part's children, consider if there is a navigable connection between them, and then make a recursive call.
foreach (Part child in p.children)
{
// Get the attachment nodes
AttachNode node = p.findAttachNodeByPart(child);
AttachNode childNode = child.findAttachNodeByPart(p);
bool attachmentIsPassable = false;
bool childAttachmentIsPassable = false;
bool dockingConnection = false;
CLSSpace spaceForChild = thisSpace;
// TODO removed debugging
//Debug.Log("Considering the connection between " + p.partInfo.title + "(" + p.uid + ") and " + child.partInfo.title + "(" + child.uid + ")");
{
// Is the attachment on "this" part passable?
if (null != node)
{
// The attachment is in the form of an AttachNode - use it to work out if the attachment is passable.
attachmentIsPassable = IsNodeNavigable(node, p);
//Debug.Log("the attachment on 'this' part is defined by attachment node " + node.id + " and had been given passable=" + attachmentIsPassable);
}
else
{
// Could it be that we are dealling with a docked connection?
dockingConnection = CheckForDockedPair(p, child);
if (true == dockingConnection)
{
//Debug.Log("The two parts are considered to be docked together.");
// The parts are docked, but we still need to have a think about if the docking port is passable.
attachmentIsPassable = IsDockedDockingPortPassable(p, child);
//Debug.Log("the docked attachment on 'this' part has been given passable=" + attachmentIsPassable);
}
else
{
//Debug.Log("The two parts are NOT considered to be docked together - concluding that this part is suface attached");
// It is not a AttachNode attachment, and it is not a docked connection either. The only other option is that we are dealing with a surface attachment. Does this part allow surfact attachments to be passable?
if (PartHasPassableSurfaceAttachments(p))
{
attachmentIsPassable = true;
//Debug.Log("This part is surface attached and is considered to be passable");
}
}
}
}
// Repeat the above block for the child part.
{
// Is the attachment on "this" part passable?
if (null != childNode)
{
// The attachment is in the form of an AttachNode - use it to work out if the attachment is passable.
childAttachmentIsPassable = IsNodeNavigable(childNode, child);
//Debug.Log("the attachment on the child part is defined by attachment node " + childNode.id + " and had been given passable=" + attachmentIsPassable);
}
else
{
if (true == dockingConnection)
{
//Debug.Log("The two parts are considered to be docked together.");
// The parts are docked, but we still need to have a think about if the docking port is passable.
childAttachmentIsPassable = IsDockedDockingPortPassable(child, p);
//Debug.Log("the docked attachment on the child part has been given passable=" + attachmentIsPassable);
}
else
{
//Debug.Log("The two parts are NOT considered to be docked together - concluding that the child part is suface attached");
// It is not a AttachNode attachment, and it is not a docked connection either. The only other option is that we are dealing with a surface attachment. Does this part allow surfact attachments to be passable?
if (PartHasPassableSurfaceAttachments(child))
{
childAttachmentIsPassable = true;
//Debug.Log("The child part is surface attached and is considered to be passable");
}
}
//.........这里部分代码省略.........
示例3: PartChildAttached
//[PartMessageListener(typeof(PartChildAttached), scenes: GameSceneFilter.AnyEditor)]
public void PartChildAttached(Part child)
{
if (HighLogic.LoadedScene != GameScenes.EDITOR)
return;
Debug.Log ("PartChildAttached");
AttachNode node = child.findAttachNodeByPart(part);
if (shape == null || node == null) //OnUpdate hasn't fired or node not connected yet
{
toAttach.Enqueue(() => PartChildAttached(child));
return;
}
//Debug.Log("PartChildAttached");
//if (node == null)
//{
// Debug.LogError("*ST* unable to find child node for child: " + child.transform);
// //toAttach.Enqueue(() => PartChildAttached(child));
// return;
//}
//else
// Debug.LogError("*ST* found: " + child.transform);
Vector3 position = child.transform.TransformPoint(node.position);
// Handle node offsets
//if (child.attachMode != AttachModes.SRF_ATTACH)
//{
// AttachNode ourNode = part.findAttachNodeByPart(child);
// if (ourNode == null)
// {
// Debug.LogError("*ST* unable to find our node for child: " + child.transform);
// return;
// }
// // ReSharper disable once InconsistentNaming
// Func<Vector3> Offset;
// if (nodeOffsets.TryGetValue(ourNode.id, out Offset))
// position -= Offset();
//}
//Debug.LogWarning("Attaching to parent: " + part + " child: " + child.transform.name);
FreePartAttachment newAttachment = new FreePartAttachment(child, node);
switch (child.attachMode)
{
case AttachModes.SRF_ATTACH:
newAttachment.Coordinates.RadiusMode = ProceduralAbstractShape.ShapeCoordinates.RMode.OFFSET_FROM_SHAPE_RADIUS;
newAttachment.Coordinates.HeightMode = ProceduralAbstractShape.ShapeCoordinates.YMode.RELATIVE_TO_SHAPE;
break;
case AttachModes.STACK:
newAttachment.Coordinates.RadiusMode = ProceduralAbstractShape.ShapeCoordinates.RMode.RELATIVE_TO_SHAPE_RADIUS;
AttachNode ourNode = part.findAttachNodeByPart(child);
if (ourNode == null)
{
Debug.LogError("*ST* unable to find our node for child: " + child.transform);
return;
}
//Debug.Log("NodeID: " + ourNode.id);
if (ourNode.id == "top")
newAttachment.Coordinates.HeightMode = ProceduralAbstractShape.ShapeCoordinates.YMode.OFFSET_FROM_SHAPE_TOP;
else if (ourNode.id == "bottom")
newAttachment.Coordinates.HeightMode = ProceduralAbstractShape.ShapeCoordinates.YMode.OFFSET_FROM_SHAPE_BOTTOM;
else
newAttachment.Coordinates.HeightMode = ProceduralAbstractShape.ShapeCoordinates.YMode.RELATIVE_TO_SHAPE;
break;
default:
Debug.LogError("Unknown AttachMode: " + child.attachMode);
break;
}
shape.GetCylindricCoordinates(transform.InverseTransformPoint(position), newAttachment.Coordinates);
childAttach.AddLast(newAttachment);
//PartAttachment attach = AddPartAttachment(position, new TransformFollower.TransformTransformable(child.transform, node.position));
//attach.child = child;
//childAttachments.AddLast(attach);
//shape.ForceNextUpdate();
}
示例4: PartChildAttached
private void PartChildAttached(Part child)
{
AttachNode node = child.findAttachNodeByPart(part);
if (node == null)
{
Debug.LogError("*ST* unable to find child node for child: " + child.transform);
return;
}
//Debug.LogWarning("Attaching to parent: " + part + " child: " + child.transform.name);
Vector3 worldOffset = child.transform.TransformDirection(node.position);
PartAttachment attach = AddPartAttachment(child.transform.position + worldOffset, new TransformFollower.TransformTransformable(child.transform, node.position));
attach.child = child;
childAttachments.AddLast(attach);
shape.ForceNextUpdate();
}
示例5: NodesBetween
/// <summary>
/// Find the Attachnode that fastens <paramref name="a"/> to <paramref name="b"/> and vice versa.
/// </summary>
/// <param name="a">The source part (often the parent)</param>
/// <param name="b">The target part (often the child)</param>
/// <returns>The AttachNodes between the two parts.</returns>
private static Tuple<AttachNode, AttachNode>? NodesBetween(Part a, Part b)
{
var nodeA = a.findAttachNodeByPart(b);
var nodeB = b.findAttachNodeByPart(a);
if (nodeA == null || nodeB == null)
return null;
return Tuple.Create(nodeA, nodeB);
}
示例6: UpdatePartJoint
//.........这里部分代码省略.........
if (jointList == null)
return;
StringBuilder debugString = new StringBuilder();
bool addAdditionalJointToParent = KJRJointUtils.multiPartAttachNodeReinforcement;
//addAdditionalJointToParent &= !(p.Modules.Contains("LaunchClamp") || (p.parent.Modules.Contains("ModuleDecouple") || p.parent.Modules.Contains("ModuleAnchoredDecoupler")));
addAdditionalJointToParent &= !(p is StrutConnector || p.Modules.Contains("CModuleStrut"));
float partMass = p.mass + p.GetResourceMass();
for (int i = 0; i < jointList.Count; i++)
{
ConfigurableJoint j = jointList[i];
if (j == null)
continue;
String jointType = j.GetType().Name;
Rigidbody connectedBody = j.connectedBody;
Part connectedPart = connectedBody.GetComponent<Part>() ?? p.parent;
float parentMass = connectedPart.mass + connectedPart.GetResourceMass();
if (partMass < KJRJointUtils.massForAdjustment || parentMass < KJRJointUtils.massForAdjustment)
{
if (KJRJointUtils.debug)
{
Debug.Log("KJR: Part mass too low, skipping: " + p.partInfo.name + " (" + p.flightID + ")");
}
continue;
}
// Check attachment nodes for better orientation data
AttachNode attach = p.findAttachNodeByPart(p.parent);
AttachNode p_attach = p.parent.findAttachNodeByPart(p);
AttachNode node = attach ?? p_attach;
if (node == null)
{
// Check if it's a pair of coupled docking ports
var dock1 = p.Modules["ModuleDockingNode"] as ModuleDockingNode;
var dock2 = p.parent.Modules["ModuleDockingNode"] as ModuleDockingNode;
//Debug.Log(dock1 + " " + (dock1 ? ""+dock1.dockedPartUId : "?") + " " + dock2 + " " + (dock2 ? ""+dock2.dockedPartUId : "?"));
if (dock1 && dock2 && (dock1.dockedPartUId == p.parent.flightID || dock2.dockedPartUId == p.flightID))
{
attach = p.findAttachNode(dock1.referenceAttachNode);
p_attach = p.parent.findAttachNode(dock2.referenceAttachNode);
node = attach ?? p_attach;
}
}
// If still no node and apparently surface attached, use the normal one if it's there
if (node == null && p.attachMode == AttachModes.SRF_ATTACH)
node = attach = p.srfAttachNode;
if (KJRJointUtils.debug)
{
debugString.AppendLine("Original joint from " + p.partInfo.title + " to " + p.parent.partInfo.title);
debugString.AppendLine(" " + p.partInfo.name + " (" + p.flightID + ") -> " + p.parent.partInfo.name + " (" + p.parent.flightID + ")");
debugString.AppendLine("");
debugString.AppendLine(p.partInfo.title + " Inertia Tensor: " + p.rigidbody.inertiaTensor + " " + p.parent.partInfo.name + " Inertia Tensor: " + connectedBody.inertiaTensor);
debugString.AppendLine("");
示例7: AddChildPartAttachment
private void AddChildPartAttachment(Part child)
{
AttachNode node = child.findAttachNodeByPart(part);
if (node == null)
{
Debug.LogError("*ST* unable to find child node for child: " + child.transform);
return;
}
Vector3 worldOffset = child.transform.TransformDirection(node.position);
PartAttachment attach = AddPartAttachment(child.transform.position + worldOffset, new TransformFollower.TransformTransformable(child.transform, node.position));
attach.child = child;
childAttachments.AddLast(attach);
//Debug.LogWarning("*ST* Attaching child childAttachment: " + child.transform.name + " from child node " + node.id + " Offset=" + part.transform.InverseTransformDirection(child.transform.position + worldOffset));
}
示例8: UpdatePartJoint
private void UpdatePartJoint(Part p)
{
if (!JointUtils.JointAdjustmentValid(p) || p.rb == null)
return;
if (p.attachJoint.Joint is ConfigurableJoint &&
p.attachMethod == AttachNodeMethod.LOCKED_JOINT)
{
if (JointUtils.debug)
{
Debug.Log("KJR: Already processed part before: " + p.partInfo.name + " (" + p.uid + ") -> " +
p.parent.partInfo.name + " (" + p.parent.uid + ")");
}
return;
}
if (p is StrutConnector)
{
StrutConnector s = p as StrutConnector;
JointDrive strutDrive = s.strutJoint.Joint.angularXDrive;
strutDrive.positionSpring = JointUtils.decouplerAndClampJointStrength;
strutDrive.maximumForce = JointUtils.decouplerAndClampJointStrength;
s.strutJoint.Joint.xDrive = s.strutJoint.Joint.yDrive = s.strutJoint.Joint.zDrive = s.strutJoint.Joint.angularXDrive = s.strutJoint.Joint.angularYZDrive = strutDrive;
float scalingFactor = (s.jointTarget.mass + s.jointTarget.GetResourceMass() + s.jointRoot.mass + s.jointRoot.GetResourceMass()) * 0.01f;
s.strutJoint.SetBreakingForces(s.strutJoint.Joint.breakForce * scalingFactor, s.strutJoint.Joint.breakTorque * scalingFactor);
p.attachMethod = AttachNodeMethod.LOCKED_JOINT;
return;
}
StringBuilder debugString = new StringBuilder();
String jointType = p.attachJoint.Joint.GetType().Name;
Rigidbody connectedBody = p.attachJoint.Joint.connectedBody;
Part connectedPart = connectedBody.GetComponent<Part>() ?? p.parent;
float partMass = p.mass + p.GetResourceMass();
float parentMass = connectedPart.mass + connectedPart.GetResourceMass();
if (partMass < JointUtils.massForAdjustment || parentMass < JointUtils.massForAdjustment)
{
if (JointUtils.debug)
{
Debug.Log("KJR: Part mass too low, skipping: " + p.partInfo.name + " (" + p.uid + ")");
}
return;
}
// Check attachment nodes for better orientation data
AttachNode attach = p.findAttachNodeByPart(p.parent);
AttachNode p_attach = p.parent.findAttachNodeByPart(p);
AttachNode node = attach ?? p_attach;
if (node == null)
{
// Check if it's a pair of coupled docking ports
var dock1 = p.Modules["ModuleDockingNode"] as ModuleDockingNode;
var dock2 = p.parent.Modules["ModuleDockingNode"] as ModuleDockingNode;
//Debug.Log(dock1 + " " + (dock1 ? ""+dock1.dockedPartUId : "?") + " " + dock2 + " " + (dock2 ? ""+dock2.dockedPartUId : "?"));
if (dock1 && dock2 && (dock1.dockedPartUId == p.parent.flightID || dock2.dockedPartUId == p.flightID))
{
attach = p.findAttachNode(dock1.referenceAttachNode);
p_attach = p.parent.findAttachNode(dock2.referenceAttachNode);
node = attach ?? p_attach;
}
}
// If still no node and apparently surface attached, use the normal one if it's there
if (node == null && p.attachMode == AttachModes.SRF_ATTACH)
node = attach = p.srfAttachNode;
if (JointUtils.debug)
{
debugString.AppendLine("Original joint from " + p.partInfo.title + " to " + p.parent.partInfo.title);
debugString.AppendLine(" " + p.partInfo.name + " (" + p.uid + ") -> " + p.parent.partInfo.name + " (" + p.parent.uid + ")");
debugString.AppendLine("");
debugString.AppendLine(p.partInfo.title + " Inertia Tensor: " + p.rigidbody.inertiaTensor + " " + p.parent.partInfo.name + " Inertia Tensor: " + connectedBody.inertiaTensor);
debugString.AppendLine("");
debugString.AppendLine("Std. Joint Parameters");
debugString.AppendLine("Connected Body: " + p.attachJoint.Joint.connectedBody);
debugString.AppendLine("Attach mode: " + p.attachMode + " (was " + jointType + ")");
if (attach != null)
debugString.AppendLine("Attach node: " + attach.id + " - " + attach.nodeType + " " + attach.size);
if (p_attach != null)
debugString.AppendLine("Parent node: " + p_attach.id + " - " + p_attach.nodeType + " " + p_attach.size);
debugString.AppendLine("Anchor: " + p.attachJoint.Joint.anchor);
debugString.AppendLine("Axis: " + p.attachJoint.Joint.axis);
debugString.AppendLine("Sec Axis: " + p.attachJoint.Joint.secondaryAxis);
debugString.AppendLine("Break Force: " + p.attachJoint.Joint.breakForce);
debugString.AppendLine("Break Torque: " + p.attachJoint.Joint.breakTorque);
debugString.AppendLine("");
//.........这里部分代码省略.........