mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Code cleanup
• Pretty up some code for consistency • Add documentation to constraint modules • Fix key name for copy position constraint
This commit is contained in:
parent
3077b9b47b
commit
85ab757271
Binary file not shown.
@ -3,6 +3,10 @@ using UnityEngine;
|
|||||||
namespace Restock.Constraints
|
namespace Restock.Constraints
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[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
|
public class CopyPositionConstraint : IConstraint
|
||||||
{
|
{
|
||||||
private readonly string moversName;
|
private readonly string moversName;
|
||||||
@ -16,8 +20,9 @@ namespace Restock.Constraints
|
|||||||
|
|
||||||
public CopyPositionConstraint(ConfigNode node, Part p)
|
public CopyPositionConstraint(ConfigNode node, Part p)
|
||||||
{
|
{
|
||||||
node.TryGetValue("rotatorsName", ref moversName);
|
node.TryGetValue("moversName", ref moversName);
|
||||||
node.TryGetValue("targetName", ref targetName);
|
node.TryGetValue("targetName", ref targetName);
|
||||||
|
node.TryGetValue("isLocal", ref local);
|
||||||
|
|
||||||
mover = p.FindModelTransform(moversName);
|
mover = p.FindModelTransform(moversName);
|
||||||
target = p.FindModelTransform(targetName);
|
target = p.FindModelTransform(targetName);
|
||||||
|
@ -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);
|
||||||
|
@ -3,14 +3,17 @@ using UnityEngine;
|
|||||||
namespace Restock.Constraints
|
namespace Restock.Constraints
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
/**
|
||||||
|
* Points the rotator object at the target object
|
||||||
|
*/
|
||||||
public class LookAtConstraint : IConstraint
|
public class LookAtConstraint : IConstraint
|
||||||
{
|
{
|
||||||
private readonly string rotatorsName;
|
private readonly string rotatorsName;
|
||||||
private readonly string targetName;
|
private readonly string targetName;
|
||||||
|
|
||||||
// Cached components
|
// Cached components
|
||||||
private readonly Transform target;
|
|
||||||
private readonly Transform rotator;
|
private readonly Transform rotator;
|
||||||
|
private readonly Transform target;
|
||||||
|
|
||||||
public LookAtConstraint(ConfigNode node, Part p)
|
public LookAtConstraint(ConfigNode node, Part p)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user