|
|
@ -3,6 +3,10 @@ using UnityEngine;
|
|
|
|
namespace Restock.Constraints
|
|
|
|
namespace Restock.Constraints
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[System.Serializable]
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Copies the rotation of the target object to the rotator object.
|
|
|
|
|
|
|
|
* If `IsLocal` is true, uses local rotation instead of global rotation.
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class CopyRotationConstraint : IConstraint
|
|
|
|
public class CopyRotationConstraint : IConstraint
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly string rotatorsName;
|
|
|
|
private readonly string rotatorsName;
|
|
|
@ -11,13 +15,14 @@ namespace Restock.Constraints
|
|
|
|
private readonly bool local = false;
|
|
|
|
private readonly bool local = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Cached components
|
|
|
|
// Cached components
|
|
|
|
private readonly Transform target;
|
|
|
|
|
|
|
|
private readonly Transform rotator;
|
|
|
|
private readonly Transform rotator;
|
|
|
|
|
|
|
|
private readonly Transform target;
|
|
|
|
|
|
|
|
|
|
|
|
public CopyRotationConstraint(ConfigNode node, Part p)
|
|
|
|
public CopyRotationConstraint(ConfigNode node, Part p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node.TryGetValue("rotatorsName", ref rotatorsName);
|
|
|
|
node.TryGetValue("rotatorsName", ref rotatorsName);
|
|
|
|
node.TryGetValue("targetName", ref targetName);
|
|
|
|
node.TryGetValue("targetName", ref targetName);
|
|
|
|
|
|
|
|
node.TryGetValue("isLocal", ref local);
|
|
|
|
|
|
|
|
|
|
|
|
rotator = p.FindModelTransform(rotatorsName);
|
|
|
|
rotator = p.FindModelTransform(rotatorsName);
|
|
|
|
target = p.FindModelTransform(targetName);
|
|
|
|
target = p.FindModelTransform(targetName);
|
|
|
|