Skip to content

Commit af253fd

Browse files
committed
gle: Add access to switch, coil and lamp statuses.
1 parent 1172f2c commit af253fd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Runtime/Gamelogic/VisualScriptingGamelogicEngine.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ public class VisualScriptingGamelogicEngine : MonoBehaviour, IGamelogicEngine
5252
public event EventHandler<CoilEventArgs> OnCoilChanged;
5353
public event EventHandler<SwitchEventArgs2> OnSwitchChanged;
5454

55+
[NonSerialized] private Player _player;
56+
5557
public void OnInit(Player player, TableApi tableApi, BallManager ballManager)
5658
{
59+
_player = player;
5760
EventBus.Trigger(VisualScriptingEventNames.PlayerStartedEvent, EventArgs.Empty);
5861
}
5962

@@ -77,5 +80,20 @@ public void SetLamp(string id, Color color)
7780
{
7881
OnLampColorChanged?.Invoke(this, new LampColorEventArgs(id, color));
7982
}
83+
84+
public float GetLamp(string id)
85+
{
86+
return _player.LampStatuses.ContainsKey(id) ? _player.LampStatuses[id] : 0;
87+
}
88+
89+
public bool GetSwitch(string id)
90+
{
91+
return _player.SwitchStatuses.ContainsKey(id) && _player.SwitchStatuses[id].IsSwitchEnabled;
92+
}
93+
94+
public bool GetCoil(string id)
95+
{
96+
return _player.CoilStatuses.ContainsKey(id) && _player.CoilStatuses[id];
97+
}
8098
}
8199
}

0 commit comments

Comments
 (0)