Skip to content

Commit

Permalink
Add serialized subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkehrwald authored and freezy committed Sep 8, 2024
1 parent fab4bc0 commit 40b0629
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 15 deletions.
10 changes: 5 additions & 5 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineCoil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class GamelogicEngineCoil : IGamelogicEngineDeviceItem
/// </summary>
public bool IsUnused;

private string _description;
private string _id;
private string _deviceHint;
private string _deviceItemHint;
private int _numMatches = 1;
protected string _description;
protected string _id;
protected string _deviceHint;
protected string _deviceItemHint;
protected int _numMatches = 1;

public GamelogicEngineCoil(string id)
{
Expand Down
10 changes: 5 additions & 5 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineLamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public class GamelogicEngineLamp : IGamelogicEngineDeviceItem

public int NumMatches { get => _numMatches; set => _numMatches = value; }

private string _description;
private string _id;
private string _deviceHint;
private string _deviceItemHint;
private int _numMatches = 1;
protected string _description;
protected string _id;
protected string _deviceHint;
protected string _deviceItemHint;
protected int _numMatches = 1;

public GamelogicEngineLamp(string id)
{
Expand Down
10 changes: 5 additions & 5 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class GamelogicEngineSwitch : IGamelogicEngineDeviceItem
public int NumMatches { get => _numMatches; set => _numMatches = value; }
public SwitchConstantHint ConstantHint = SwitchConstantHint.None;

private string _description;
private string _id;
private string _deviceHint;
private string _deviceItemHint;
private int _numMatches = 1;
protected string _description;
protected string _id;
protected string _deviceHint;
protected string _deviceItemHint;
protected int _numMatches = 1;

public GamelogicEngineSwitch(string id)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Visual Pinball Engine
// Copyright (C) 2023 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 InconsistentNaming

using System;
using UnityEngine;
using VisualPinball.Engine.Game.Engines;

namespace VisualPinball.Unity
{
[Serializable]
public class SerializedGamelogicEngineCoil : GamelogicEngineCoil, ISerializationCallbackReceiver
{
public SerializedGamelogicEngineCoil(string id) : base(id) { }
public SerializedGamelogicEngineCoil(int id) : base(id) { }

[SerializeField] private string _serializedDescription;
[SerializeField] private string _serializedId;
[SerializeField] private string _serializedDeviceHint;
[SerializeField] private string _serializedDeviceItemHint;
[SerializeField] private int _serializedNumMatches = 1;

public void OnBeforeSerialize()
{
_serializedDescription = _description;
_serializedId = _id;
_serializedDeviceHint = _deviceHint;
_serializedDeviceItemHint = _deviceItemHint;
_serializedNumMatches = _numMatches;
}

public void OnAfterDeserialize()
{
_description = _serializedDescription;
_id = _serializedId;
_deviceHint = _serializedDeviceHint;
_deviceItemHint = _serializedDeviceItemHint;
_numMatches = _serializedNumMatches;
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Visual Pinball Engine
// Copyright (C) 2023 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 InconsistentNaming

using System;
using UnityEngine;
using VisualPinball.Engine.Game.Engines;

namespace VisualPinball.Unity
{
[Serializable]
public class SerializedGamelogicEngineLamp : GamelogicEngineLamp, ISerializationCallbackReceiver
{
public SerializedGamelogicEngineLamp(string id) : base(id) { }
public SerializedGamelogicEngineLamp(int id) : base(id) { }

[SerializeField] private string _serializedDescription;
[SerializeField] private string _serializedId;
[SerializeField] private string _serializedDeviceHint;
[SerializeField] private string _serializedDeviceItemHint;
[SerializeField] private int _serializedNumMatches = 1;

public void OnBeforeSerialize()
{
_serializedDescription = _description;
_serializedId = _id;
_serializedDeviceHint = _deviceHint;
_serializedDeviceItemHint = _deviceItemHint;
_serializedNumMatches = _numMatches;
}

public void OnAfterDeserialize()
{
_description = _serializedDescription;
_id = _serializedId;
_deviceHint = _serializedDeviceHint;
_deviceItemHint = _serializedDeviceItemHint;
_numMatches = _serializedNumMatches;
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Visual Pinball Engine
// Copyright (C) 2023 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 InconsistentNaming

using System;
using UnityEngine;
using VisualPinball.Engine.Game.Engines;

namespace VisualPinball.Unity
{
[Serializable]
public class SerializedGamelogicEngineSwitch : GamelogicEngineSwitch, ISerializationCallbackReceiver
{
public SerializedGamelogicEngineSwitch(string id) : base(id) { }
public SerializedGamelogicEngineSwitch(int id) : base(id) { }

[SerializeField] private string _serializedDescription;
[SerializeField] private string _serializedId;
[SerializeField] private string _serializedDeviceHint;
[SerializeField] private string _serializedDeviceItemHint;
[SerializeField] private int _serializedNumMatches = 1;

public void OnBeforeSerialize()
{
_serializedDescription = _description;
_serializedId = _id;
_serializedDeviceHint = _deviceHint;
_serializedDeviceItemHint = _deviceItemHint;
_serializedNumMatches = _numMatches;
}

public void OnAfterDeserialize()
{
_description = _serializedDescription;
_id = _serializedId;
_deviceHint = _serializedDeviceHint;
_deviceItemHint = _serializedDeviceItemHint;
_numMatches = _serializedNumMatches;
}
}
}

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

0 comments on commit 40b0629

Please sign in to comment.