Code cleanup

• Pretty up some code for consistency
• Add documentation to constraint modules
• Fix key name for copy position constraint
pull/822/head
Andrew Cassidy 4 years ago
parent 3077b9b47b
commit 85ab757271
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

@ -3,6 +3,10 @@ using UnityEngine;
namespace Restock.Constraints
{
[System.Serializable]
/**
* Copies the position of the target object to the mover object.
* If `IsLocal` is true, uses local position instead of global position.
*/
public class CopyPositionConstraint : IConstraint
{
private readonly string moversName;
@ -16,8 +20,9 @@ namespace Restock.Constraints
public CopyPositionConstraint(ConfigNode node, Part p)
{
node.TryGetValue("rotatorsName", ref moversName);
node.TryGetValue("moversName", ref moversName);
node.TryGetValue("targetName", ref targetName);
node.TryGetValue("isLocal", ref local);
mover = p.FindModelTransform(moversName);
target = p.FindModelTransform(targetName);

@ -3,6 +3,10 @@ using UnityEngine;
namespace Restock.Constraints
{
[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
{
private readonly string rotatorsName;
@ -11,13 +15,14 @@ namespace Restock.Constraints
private readonly bool local = false;
// Cached components
private readonly Transform target;
private readonly Transform rotator;
private readonly Transform target;
public CopyRotationConstraint(ConfigNode node, Part p)
{
node.TryGetValue("rotatorsName", ref rotatorsName);
node.TryGetValue("targetName", ref targetName);
node.TryGetValue("isLocal", ref local);
rotator = p.FindModelTransform(rotatorsName);
target = p.FindModelTransform(targetName);

@ -3,14 +3,17 @@ using UnityEngine;
namespace Restock.Constraints
{
[System.Serializable]
/**
* Points the rotator object at the target object
*/
public class LookAtConstraint : IConstraint
{
private readonly string rotatorsName;
private readonly string targetName;
// Cached components
private readonly Transform target;
private readonly Transform rotator;
private readonly Transform target;
public LookAtConstraint(ConfigNode node, Part p)
{

Loading…
Cancel
Save