|
| Cassowary () |
| Creates a new Cassowary solver. More...
|
|
void | AddConstraint (string constraintExpression, float strength=CassowaryStrength.Required) |
| Adds a constraint to the system.
You cannot multiply or divide variables and expressions with each other.
Doing so will result in a error when attempting to add the constraint.
(You can, of course, multiply or divide by constants).
More...
|
|
float | GetValue (string varName) |
| Gets the value for the specified variable. More...
|
|
void | Reset () |
| Clear out this solver, removing all state, constraints and suggestions. More...
|
|
void | SuggestValue (string varName, float value, float strength=CassowaryStrength.Strong) |
| Suggests a value to the solver. More...
|
|
void | Dispose () |
|
Represents a Cassowary engine structure.
A Cassowary is a type of solver. NWN uses them internally to resize the newer GUI window.
Examples
using NLog;
namespace NWN.Anvil.Samples
{
[ServiceBinding(typeof(CassowaryExamples))]
public class CassowaryExamples
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public CassowaryExamples()
{
cTest.AddConstraint("middle == (left + right) / 2");
cTest.AddConstraint("right == left + 10");
cTest.AddConstraint("right <= 100");
cTest.AddConstraint("left >= 0");
Log.Info($"Solution 1: Left: {cTest.GetValue("left")}, Middle: {cTest.GetValue("middle")}, Right: {cTest.GetValue("right")}");
cTest.SuggestValue("middle", 45f);
Log.Info($"Solution 2: Left: {cTest.GetValue("left")}, Middle: {cTest.GetValue("middle")}, Right: {cTest.GetValue("right")}");
}
}
}