Skip to content
Open
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
8 changes: 8 additions & 0 deletions Runtime/Nodes/Nudge.meta

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

65 changes: 65 additions & 0 deletions Runtime/Nodes/Nudge/NudgeUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Visual Pinball Engine
// Copyright (C) 2026 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/>.

using Unity.VisualScripting;
using UnityEngine;

namespace VisualPinball.Unity.VisualScripting
{
[UnitTitle("Nudge")]
[UnitSurtitle("Player")]
[UnitCategory("Pinball")]
public class NudgeUnit : GleUnit
{
[DoNotSerialize]
[PortLabelHidden]
public ControlInput InputTrigger;

[DoNotSerialize]
[PortLabelHidden]
public ControlOutput OutputTrigger;

[DoNotSerialize]
[PortLabel("Angle")]
public ValueInput Angle { get; private set; }

[DoNotSerialize]
[PortLabel("Force")]
public ValueInput Force { get; private set; }

protected override void Definition()
{
InputTrigger = ControlInput(nameof(InputTrigger), Process);
OutputTrigger = ControlOutput(nameof(OutputTrigger));
Angle = ValueInput(nameof(Angle), 0f);
Force = ValueInput(nameof(Force), 2f);
Requirement(Angle, InputTrigger);
Requirement(Force, InputTrigger);
Succession(InputTrigger, OutputTrigger);
}

private ControlOutput Process(Flow flow)
{
if (!AssertPlayer(flow)) {
Debug.LogError("Cannot find Player.");
return OutputTrigger;
}

Player.Nudge(flow.GetValue<float>(Angle), flow.GetValue<float>(Force));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 External Nudge API Coupling

Player is provided by the referenced VisualPinball.Unity assembly, so this new call requires that package version to expose a compatible public Nudge(float, float) overload. If the resolved engine package lacks that exact API or uses a different signature, the Visual Scripting runtime assembly will fail to compile when this node is added.

return OutputTrigger;
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Nodes/Nudge/NudgeUnit.cs.meta

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