Skip to content

Commit 792e51c

Browse files
committed
style: Fix formatting
1 parent 62d9533 commit 792e51c

File tree

6 files changed

+372
-277
lines changed

6 files changed

+372
-277
lines changed
Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,65 @@
1-
using Unity.VisualScripting;
1+
// Visual Pinball Engine
2+
// Copyright (C) 2021 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
using Unity.VisualScripting;
218

319
namespace VisualPinball.Unity.VisualScripting
420
{
5-
[UnitTitle("On Lamp Event")]
6-
[UnitCategory("Events\\Visual Pinball")]
7-
public sealed class LampEventUnit : EventUnit<LampEventArgs>
8-
{
9-
[DoNotSerialize]
10-
[PortLabelHidden]
11-
public ValueInput id { get; private set; }
12-
13-
[DoNotSerialize]
14-
[PortLabelHidden]
15-
public ValueOutput value { get; private set; }
16-
17-
[DoNotSerialize]
18-
[PortLabelHidden]
19-
public ValueOutput enabled { get; private set; }
20-
21-
protected override bool register => true;
22-
23-
public override EventHook GetHook(GraphReference reference)
24-
{
25-
return new EventHook(EventNames.LampEvent);
26-
}
27-
28-
protected override void Definition()
29-
{
30-
base.Definition();
31-
32-
id = ValueInput(nameof(id), string.Empty);
33-
34-
value = ValueOutput<int>(nameof(value));
35-
enabled = ValueOutput<bool>(nameof(enabled));
36-
}
37-
38-
protected override void AssignArguments(Flow flow, LampEventArgs args)
39-
{
40-
flow.SetValue(value, args.Value);
41-
flow.SetValue(enabled, args.Value > 0);
42-
}
43-
44-
protected override bool ShouldTrigger(Flow flow, LampEventArgs args)
45-
{
46-
return args.Id == flow.GetValue<string>(id);
47-
}
48-
}
49-
}
21+
[UnitTitle("On Lamp Event")]
22+
[UnitCategory("Events\\Visual Pinball")]
23+
public sealed class LampEventUnit : EventUnit<LampEventArgs>
24+
{
25+
[DoNotSerialize]
26+
[PortLabelHidden]
27+
public ValueInput id { get; private set; }
28+
29+
[DoNotSerialize]
30+
[PortLabelHidden]
31+
public ValueOutput value { get; private set; }
32+
33+
[DoNotSerialize]
34+
[PortLabelHidden]
35+
public ValueOutput enabled { get; private set; }
36+
37+
protected override bool register => true;
38+
39+
public override EventHook GetHook(GraphReference reference)
40+
{
41+
return new EventHook(EventNames.LampEvent);
42+
}
43+
44+
protected override void Definition()
45+
{
46+
base.Definition();
47+
48+
id = ValueInput(nameof(id), string.Empty);
49+
50+
value = ValueOutput<int>(nameof(value));
51+
enabled = ValueOutput<bool>(nameof(enabled));
52+
}
53+
54+
protected override void AssignArguments(Flow flow, LampEventArgs args)
55+
{
56+
flow.SetValue(value, args.Value);
57+
flow.SetValue(enabled, args.Value > 0);
58+
}
59+
60+
protected override bool ShouldTrigger(Flow flow, LampEventArgs args)
61+
{
62+
return args.Id == flow.GetValue<string>(id);
63+
}
64+
}
65+
}
Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
using System;
1+
// Visual Pinball Engine
2+
// Copyright (C) 2021 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
using System;
218
using Unity.VisualScripting;
319

420
namespace VisualPinball.Unity.VisualScripting
521
{
6-
[UnitTitle("On Player Started Event")]
7-
[UnitCategory("Events\\Visual Pinball")]
8-
public sealed class PlayerStartedEventUnit : EventUnit<EventArgs>
9-
{
10-
protected override bool register => true;
22+
[UnitTitle("On Player Started Event")]
23+
[UnitCategory("Events\\Visual Pinball")]
24+
public sealed class PlayerStartedEventUnit : EventUnit<EventArgs>
25+
{
26+
protected override bool register => true;
1127

12-
public override EventHook GetHook(GraphReference reference)
13-
{
14-
return new EventHook(EventNames.PlayerStartedEvent);
15-
}
28+
public override EventHook GetHook(GraphReference reference)
29+
{
30+
return new EventHook(EventNames.PlayerStartedEvent);
31+
}
1632

17-
protected override void Definition()
18-
{
19-
base.Definition();
20-
}
21-
}
33+
protected override void Definition()
34+
{
35+
base.Definition();
36+
}
37+
}
2238
}
Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,67 @@
1-
using Unity.VisualScripting;
1+
// Visual Pinball Engine
2+
// Copyright (C) 2021 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
using Unity.VisualScripting;
218

319
namespace VisualPinball.Unity.VisualScripting
420
{
5-
[UnitTitle("Get Lamp Value")]
6-
[UnitCategory("Visual Pinball")]
7-
public class GetLampValueUnit : Unit
8-
{
9-
[DoNotSerialize]
10-
[PortLabelHidden]
11-
public ValueInput id { get; private set; }
12-
13-
[DoNotSerialize]
14-
[PortLabelHidden]
15-
public ValueOutput value { get; private set; }
16-
17-
[DoNotSerialize]
18-
[PortLabelHidden]
19-
public ValueOutput enabled { get; private set; }
20-
21-
private Player _player;
22-
23-
protected override void Definition()
24-
{
25-
id = ValueInput(nameof(id), string.Empty);
26-
27-
value = ValueOutput(nameof(value), GetValue);
28-
enabled = ValueOutput(nameof(enabled), GetEnabled);
29-
}
30-
31-
private float GetValue(Flow flow)
32-
{
33-
if (_player == null) {
34-
_player = UnityEngine.Object.FindObjectOfType<Player>();
35-
}
36-
37-
var key = flow.GetValue<string>(id);
38-
return _player.LampStatuses.ContainsKey(key) ? _player.LampStatuses[key] : 0;
39-
}
40-
41-
private bool GetEnabled(Flow flow)
42-
{
43-
if (_player == null) {
44-
_player = UnityEngine.Object.FindObjectOfType<Player>();
45-
}
46-
47-
var key = flow.GetValue<string>(id);
48-
return _player.LampStatuses.ContainsKey(key) ? (_player.LampStatuses[key] > 0) : false;
49-
}
50-
}
51-
}
21+
[UnitTitle("Get Lamp Value")]
22+
[UnitCategory("Visual Pinball")]
23+
public class GetLampValueUnit : Unit
24+
{
25+
[DoNotSerialize]
26+
[PortLabelHidden]
27+
public ValueInput id { get; private set; }
28+
29+
[DoNotSerialize]
30+
[PortLabelHidden]
31+
public ValueOutput value { get; private set; }
32+
33+
[DoNotSerialize]
34+
[PortLabelHidden]
35+
public ValueOutput enabled { get; private set; }
36+
37+
private Player _player;
38+
39+
protected override void Definition()
40+
{
41+
id = ValueInput(nameof(id), string.Empty);
42+
43+
value = ValueOutput(nameof(value), GetValue);
44+
enabled = ValueOutput(nameof(enabled), GetEnabled);
45+
}
46+
47+
private float GetValue(Flow flow)
48+
{
49+
if (_player == null) {
50+
_player = UnityEngine.Object.FindObjectOfType<Player>();
51+
}
52+
53+
var key = flow.GetValue<string>(id);
54+
return _player.LampStatuses.ContainsKey(key) ? _player.LampStatuses[key] : 0;
55+
}
56+
57+
private bool GetEnabled(Flow flow)
58+
{
59+
if (_player == null) {
60+
_player = flow.stack.self.GetComponentInParent<Player>();
61+
}
62+
63+
var key = flow.GetValue<string>(id);
64+
return _player.LampStatuses.ContainsKey(key) && (_player.LampStatuses[key] > 0);
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)