Skip to content

Commit edac690

Browse files
committed
mech: Add default values and icon.
1 parent de67684 commit edac690

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
// ReSharper disable UnusedType.Global
18+
19+
using UnityEngine;
20+
using VisualPinball.Unity.Editor;
21+
22+
namespace VisualPinball.Engine.PinMAME.Editor
23+
{
24+
public class PinMameIcons : IIconLookup
25+
{
26+
public Texture2D Lookup<T>(T mb, IconSize size = IconSize.Large, IconColor color = IconColor.Gray) where T : class
27+
{
28+
return mb switch {
29+
PinMameMechComponent _ => Icons.MechPinMame(size, color),
30+
_ => null
31+
};
32+
}
33+
34+
public void DisableGizmoIcons()
35+
{
36+
Icons.DisableGizmo<PinMameMechComponent>();
37+
}
38+
}
39+
}

VisualPinball.Engine.PinMAME.Unity/Editor/PinMameIcons.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VisualPinball.Engine.PinMAME.Unity/Runtime/PinMameMechComponent.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class PinMameMechComponent : MonoBehaviour, IMechHandler, ISwitchDeviceCo
3434
#region Data
3535

3636
[Tooltip("This defines how the mech is controlled.")]
37-
public PinMameMechType Type;
37+
public PinMameMechType Type = PinMameMechType.OneDirectionalSolenoid;
3838

3939
[Tooltip("The first solenoid handled by the mech.")]
4040
public int Solenoid1;
@@ -57,14 +57,14 @@ public class PinMameMechComponent : MonoBehaviour, IMechHandler, ISwitchDeviceCo
5757
[Unit("ms")]
5858
[Min(0)]
5959
[Tooltip("Amount of time, in milliseconds, that the specified solenoids must be enabled for, to move a single step in the progression from the start to end position. ")]
60-
public int Length;
60+
public int Length = 200;
6161

6262
[Min(0)]
6363
[Tooltip("The total number of steps from the start to the end position.")]
64-
public int Steps;
64+
public int Steps = 200;
6565

6666
[Tooltip("Define your switch marks here.")]
67-
public MechMark[] Marks;
67+
public MechMark[] Marks = {};
6868

6969
[Unit("ms")]
7070
[Min(0)]
@@ -116,7 +116,7 @@ public PinMameMechConfig Config(List<SwitchMapping> switchMappings)
116116
);
117117

118118
foreach (var mark in Marks) {
119-
var switchMapping = switchMappings.FirstOrDefault(sm => sm.Device == this && sm.DeviceItem == mark.SwitchId);
119+
var switchMapping = switchMappings.FirstOrDefault(sm => ReferenceEquals(sm.Device, this) && sm.DeviceItem == mark.SwitchId);
120120
if (switchMapping == null) {
121121
Logger.Error($"Switch \"{mark.Description}\" for mech {name} is not mapped in the switch manager, ignoring.");
122122
continue;
@@ -183,21 +183,4 @@ public void OnAfterDeserialize()
183183

184184
#endregion
185185
}
186-
187-
[Serializable]
188-
public class PinMameMechSwitchMark
189-
{
190-
public string Description;
191-
public int SwitchId;
192-
public PinMameMechSwitchMarkType Type;
193-
194-
public int StepBeginning;
195-
public int StepEnd;
196-
public int StepPulseDuration;
197-
}
198-
199-
public enum PinMameMechSwitchMarkType
200-
{
201-
Switch, PulseSwitch, PulseSwitchNew
202-
}
203186
}

0 commit comments

Comments
 (0)