forked from antonpup/Aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request antonpup#2072 from Wibble199/feature/more-evaluata…
…bles Add boolean change and T flip-flop evaluatable
- Loading branch information
Showing
5 changed files
with
127 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_FlipFlop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Aurora.Profiles; | ||
using Aurora.Utils; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Media; | ||
|
||
namespace Aurora.Settings.Overrides.Logic.Boolean { | ||
|
||
/// <summary> | ||
/// A simple memory gate that can be used for storing a boolean state. | ||
/// While the given input is true, the state of the flip-flop is toggled. | ||
/// </summary> | ||
[Evaluatable("Flip-flop (Toggle)", category: EvaluatableCategory.Logic)] | ||
public class Boolean_FlipFlopT : Evaluatable<bool> { | ||
|
||
private bool state = false; | ||
|
||
public Evaluatable<bool> Toggle { get; set; } | ||
|
||
public Boolean_FlipFlopT() : this(EvaluatableDefaults.Get<bool>()) { } | ||
public Boolean_FlipFlopT(Evaluatable<bool> toggle) => Toggle = toggle; | ||
|
||
protected override bool Execute(IGameState gameState) { | ||
if (Toggle.Evaluate(gameState)) | ||
state = !state; | ||
return state; | ||
} | ||
|
||
public override Visual GetControl() => new StackPanel() | ||
.WithChild(new TextBlock { Text = "Flip-Flop (Toggle)", FontWeight = FontWeights.Bold }) | ||
.WithChild(new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 4, 0, 4) } | ||
.WithChild(new Label { Content = "Toggle" }) | ||
.WithChild(new Control_EvaluatablePresenter { EvalType = typeof(bool) } | ||
.WithBinding(Control_EvaluatablePresenter.ExpressionProperty, new Binding(nameof(Toggle)) { Source = this, Mode = BindingMode.TwoWay }))); | ||
|
||
public override Evaluatable<bool> Clone() => new Boolean_FlipFlopT(Toggle.Clone()); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// A simple memory gate that can be used for storing a boolean state. | ||
/// When 'Set' is true, the gate will start outputting true until 'Reset' becomes true. | ||
/// </summary> | ||
[Evaluatable("Flip-flop (Set-Reset)", category: EvaluatableCategory.Logic)] | ||
public class Boolean_FlipFlopSR : Evaluatable<bool> { | ||
|
||
private bool state = false; | ||
|
||
public Evaluatable<bool> Set { get; set; } | ||
public Evaluatable<bool> Reset { get; set; } | ||
|
||
public Boolean_FlipFlopSR() : this(EvaluatableDefaults.Get<bool>(),EvaluatableDefaults.Get<bool>()) { } | ||
public Boolean_FlipFlopSR(Evaluatable<bool> set, Evaluatable<bool> reset) { Set = set; Reset = reset; } | ||
|
||
protected override bool Execute(IGameState gameState) { | ||
if (Reset.Evaluate(gameState)) | ||
state = false; | ||
if (Set.Evaluate(gameState)) | ||
state = true; | ||
return state; | ||
} | ||
|
||
public override Visual GetControl() => new StackPanel() | ||
.WithChild(new TextBlock { Text = "Flip-Flop (Set-Reset)", FontWeight = FontWeights.Bold }) | ||
.WithChild(new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 4, 0, 4) } | ||
.WithChild(new Label { Content = "Set" }) | ||
.WithChild(new Control_EvaluatablePresenter { EvalType = typeof(bool) } | ||
.WithBinding(Control_EvaluatablePresenter.ExpressionProperty, new Binding(nameof(Set)) { Source = this, Mode = BindingMode.TwoWay }))) | ||
.WithChild(new StackPanel { Orientation = Orientation.Horizontal } | ||
.WithChild(new Label { Content = "Reset" }) | ||
.WithChild(new Control_EvaluatablePresenter { EvalType = typeof(bool) } | ||
.WithBinding(Control_EvaluatablePresenter.ExpressionProperty, new Binding(nameof(Reset)) { Source = this, Mode = BindingMode.TwoWay }))); | ||
|
||
public override Evaluatable<bool> Clone() => new Boolean_FlipFlopSR(Set.Clone(), Reset.Clone()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_Latch.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters