Skip to content

Add new EMAddPointsUnit and EMResetPointsUnit units #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions Editor/Descriptors/EMAddPointsUnitDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Visual Pinball Engine
// Copyright (C) 2022 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// ReSharper disable UnusedType.Global

using Unity.VisualScripting;

namespace VisualPinball.Unity.VisualScripting.Editor
{
[Descriptor(typeof(EMAddPointsUnit))]
public class EMAddPointsUnitDescriptor : UnitDescriptor<EMAddPointsUnit>
{
public EMAddPointsUnitDescriptor(EMAddPointsUnit target) : base(target)
{
}

protected override string DefinedSummary()
{
return "This node takes an incoming point value and pulses values to that can be used to simulate adding points to a score reel. "
+ "\n\nFor example, an incoming point value of 500 will provide 5 pulses of 100. "
+ "\n\nSingle pulse points (1, 10, 100, 1000, 10000) will be blocked if the score motor is running and Block Points is enabled.";
}

protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.Mech(Unity.Editor.IconSize.Large, Unity.Editor.IconColor.Orange));

protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
{
base.DefinedPort(port, desc);

switch (port.key) {
case nameof(EMAddPointsUnit.pointValue):
desc.summary = "The total amount of points to add.";
break;

case nameof(EMAddPointsUnit.blockPoints):
desc.summary = "Block single pulse points when score motor running.";
break;

case nameof(EMAddPointsUnit.positions):
desc.summary = "Score motor positions.";
break;

case nameof(EMAddPointsUnit.duration):
desc.summary = "The amount of time (in ms) the score motor runs.";
break;

case nameof(EMAddPointsUnit.started):
desc.summary = "Triggered when score motor starts.";
break;

case nameof(EMAddPointsUnit.stopped):
desc.summary = "Triggered when score motor finishes.";
break;

case nameof(EMAddPointsUnit.pulse):
desc.summary = "Triggered during each pulse of the score motor.";
break;

case nameof(EMAddPointsUnit.OutputPointValue):
desc.summary = "The current pulses calculated points value that can be used to increment a score value and update a score reel.";
break;
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/Descriptors/EMAddPointsUnitDescriptor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions Editor/Descriptors/EMResetPointsUnitDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Visual Pinball Engine
// Copyright (C) 2022 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// ReSharper disable UnusedType.Global

using Unity.VisualScripting;

namespace VisualPinball.Unity.VisualScripting.Editor
{
[Descriptor(typeof(EMResetPointsUnit))]
public class EMResetPointsUnitDescriptor : UnitDescriptor<EMResetPointsUnit>
{
public EMResetPointsUnitDescriptor(EMResetPointsUnit target) : base(target)
{
}

protected override string DefinedSummary()
{
return "This node takes an incoming point value and pulses values to that can be used to simulate the resetting of a score reel. "
+ "\n\nFor example, an incoming point value of 2041 will provide the following pulses: 3052, 4063, 5074, 6085, 7096, 8007, 9008, 0009, 0000";
}

protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.Mech(Unity.Editor.IconSize.Large, Unity.Editor.IconColor.Orange));

protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
{
base.DefinedPort(port, desc);

switch (port.key) {
case nameof(EMResetPointsUnit.pointValue):
desc.summary = "The starting points value used to seed the reset sequence.";
break;

case nameof(EMResetPointsUnit.duration):
desc.summary = "The amount of time (in ms) the score motor runs.";
break;

case nameof(EMAddPointsUnit.positions):
desc.summary = "Score motor positions.";
break;

case nameof(EMResetPointsUnit.started):
desc.summary = "Triggered when score motor starts.";
break;

case nameof(EMResetPointsUnit.stopped):
desc.summary = "Triggered when score motor finishes.";
break;

case nameof(EMResetPointsUnit.pulse):
desc.summary = "Triggered during each pulse of the score motor.";
break;

case nameof(EMResetPointsUnit.OutputPointValue):
desc.summary = "The current pulses calculated points value that can be used to update a score reel.";
break;
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/Descriptors/EMResetPointsUnitDescriptor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Editor/Widgets/EMAddPointsUnitWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Visual Pinball Engine
// Copyright (C) 2022 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// ReSharper disable UnusedType.Global

using Unity.VisualScripting;

namespace VisualPinball.Unity.VisualScripting.Editor
{
[Widget(typeof(EMAddPointsUnit))]
public sealed class EMAddPointsUnitWidget : GleUnitWidget<EMAddPointsUnit>
{
public EMAddPointsUnitWidget(FlowCanvas canvas, EMAddPointsUnit unit) : base(canvas, unit)
{
}
}
}
11 changes: 11 additions & 0 deletions Editor/Widgets/EMAddPointsUnitWidget.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Editor/Widgets/EMResetPointsUnitWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Visual Pinball Engine
// Copyright (C) 2022 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// ReSharper disable UnusedType.Global

using Unity.VisualScripting;

namespace VisualPinball.Unity.VisualScripting.Editor
{
[Widget(typeof(EMResetPointsUnit))]
public sealed class EMResetPointsUnitWidget : GleUnitWidget<EMResetPointsUnit>
{
public EMResetPointsUnitWidget(FlowCanvas canvas, EMResetPointsUnit unit) : base(canvas, unit)
{
}
}
}
11 changes: 11 additions & 0 deletions Editor/Widgets/EMResetPointsUnitWidget.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Runtime/Gamelogic/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public T Get<T>(string variableId) where T : class
return _variables[variableId].Get<T>();
}

public bool IsDefined(string variableId) => _variables.ContainsKey(variableId);

public StateVariable GetVariable(string variableId) => _variables[variableId];

public object Get(string variableId)
Expand Down
8 changes: 8 additions & 0 deletions Runtime/Nodes/EM.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading