-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
315 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
CCL.Importer/Proxies/Controllers/PoweredControllerReplacer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using CCL.Types.Proxies.Controllers; | ||
using DV.Simulation.Cars; | ||
|
||
namespace CCL.Importer.Proxies.Controllers | ||
{ | ||
[ProxyMap(typeof(CabLightsControllerProxy), typeof(CabLightsController))] | ||
public class PoweredControllerReplacer : ProxyReplacer | ||
{ | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
CCL.Importer/Proxies/Controls/OverridableControlReplacer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using AutoMapper; | ||
using CCL.Types.Proxies.Controls; | ||
using DV.HUD; | ||
using DV.Simulation.Cars; | ||
using DV.Simulation.Controllers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using UnityEngine; | ||
|
||
namespace CCL.Importer.Proxies.Controls | ||
{ | ||
[Export(typeof(IProxyReplacer))] | ||
public class OverridableControlReplacer : Profile, IProxyReplacer | ||
{ | ||
public OverridableControlReplacer() | ||
{ | ||
foreach (var targetType in _controlToImplMap.Values) | ||
{ | ||
CreateMap(typeof(OverridableControlProxy), targetType); | ||
} | ||
} | ||
|
||
public void CacheAndReplaceProxies(GameObject prefab) | ||
{ | ||
foreach (var overridableProxy in prefab.GetComponentsInChildren<OverridableControlProxy>(true)) | ||
{ | ||
if (_controlToImplMap.TryGetValue(overridableProxy.ControlType, out Type targetType)) | ||
{ | ||
prefab.StoreComponentsInChildrenInCache(typeof(OverridableControlProxy), targetType, _ => true); | ||
} | ||
} | ||
} | ||
|
||
public void MapProxies(GameObject prefab) | ||
{ | ||
foreach (var overridableProxy in prefab.GetComponentsInChildren<OverridableControlProxy>(true)) | ||
{ | ||
if (_controlToImplMap.TryGetValue(overridableProxy.ControlType, out Type targetType)) | ||
{ | ||
prefab.ConvertFromCache(typeof(OverridableControlProxy), targetType, _ => true); | ||
} | ||
} | ||
} | ||
|
||
public void ReplaceProxiesUncached(GameObject prefab) | ||
{ | ||
|
||
} | ||
|
||
private static readonly Dictionary<OverridableControlType, Type> _controlToImplMap = new() | ||
{ | ||
{ OverridableControlType.Throttle, typeof(ThrottleControl) }, | ||
{ OverridableControlType.TrainBrake, typeof(BrakeControl) }, | ||
{ OverridableControlType.Reverser, typeof(ReverserControl) }, | ||
{ OverridableControlType.IndBrake, typeof(IndependentBrakeControl) }, | ||
{ OverridableControlType.Handbrake, typeof(HandbrakeControl) }, | ||
{ OverridableControlType.Sander, typeof(SanderControl) }, | ||
{ OverridableControlType.Horn, typeof(HornControl) }, | ||
{ OverridableControlType.HeadlightsFront, typeof(HeadlightsControlFront) }, | ||
{ OverridableControlType.HeadlightsRear, typeof(HeadlightsControlRear) }, | ||
{ OverridableControlType.DynamicBrake, typeof(DynamicBrakeControl) }, | ||
{ OverridableControlType.FuelCutoff, typeof(PowerOffControl) }, | ||
}; | ||
} | ||
|
||
[ProxyMap(typeof(InteriorControlsManagerProxy), typeof(InteriorControlsManager))] | ||
[ProxyMap(typeof(BaseControlsOverriderProxy), typeof(BaseControlsOverrider))] | ||
public class InteriorControlReplacer : ProxyReplacer | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using UnityEngine; | ||
|
||
namespace CCL.Types.Proxies.Controllers | ||
{ | ||
public class CabLightsControllerProxy : PoweredControlHandlerBase | ||
{ | ||
public Material lightsLit; | ||
|
||
public Material lightsUnlit; | ||
|
||
[Tooltip("Light components will be enabled/disabled based on threshold")] | ||
public GameObject[] lights; | ||
[Tooltip("Renderers will have material changed between lightsLit/lightsUnlit")] | ||
public Renderer[] lightRenderers; | ||
|
||
public float lightsOnControlThreshold = 0.5f; | ||
|
||
public float damagedThresholdPercentage = 0.8f; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
CCL.Types/Proxies/Controllers/PoweredControlHandlerBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using CCL.Types.Proxies.Ports; | ||
|
||
namespace CCL.Types.Proxies.Controllers | ||
{ | ||
public abstract class PoweredControlHandlerBase | ||
{ | ||
[PortId(DVPortValueType.CONTROL, false)] | ||
public string controlId; | ||
|
||
[FuseId] | ||
public string powerFuseId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using CCL.Types.Json; | ||
using CCL.Types.Proxies.Ports; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace CCL.Types.Proxies.Controls | ||
{ | ||
public class BaseControlsOverriderProxy : MonoBehaviour, ICustomSerialized | ||
{ | ||
[Serializable] | ||
public class PortSetter | ||
{ | ||
[PortId(null, null)] | ||
public string portId; | ||
|
||
public float value; | ||
|
||
public PortSetter(string portId, float value) | ||
{ | ||
this.portId = portId; | ||
this.value = value; | ||
} | ||
} | ||
|
||
public bool propagateNeutralStateToFront; | ||
public bool propagateNeutralStateToRear; | ||
|
||
public PortSetter[] neutralStateSetters; | ||
[SerializeField] | ||
[HideInInspector] | ||
private string _neutralStateSettersJson; | ||
|
||
public void OnValidate() | ||
{ | ||
_neutralStateSettersJson = JSONObject.ToJson(neutralStateSetters); | ||
} | ||
|
||
public void AfterImport() | ||
{ | ||
neutralStateSetters = JSONObject.FromJson<PortSetter[]>(_neutralStateSettersJson); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CCL.Types.Proxies.Controls | ||
{ | ||
public enum OverridableControlType | ||
{ | ||
None, | ||
Throttle = DVControlType.Throttle, | ||
TrainBrake = DVControlType.TrainBrake, | ||
Reverser = DVControlType.Reverser, | ||
IndBrake = DVControlType.IndBrake, | ||
Handbrake = DVControlType.Handbrake, | ||
Sander = DVControlType.Sander, | ||
Horn = DVControlType.Horn, | ||
HeadlightsFront = DVControlType.HeadlightsFront, | ||
HeadlightsRear = DVControlType.HeadlightsRear, | ||
DynamicBrake = DVControlType.DynamicBrake, | ||
FuelCutoff = DVControlType.FuelCutoff, | ||
} | ||
|
||
public enum DVControlType | ||
{ | ||
None, | ||
Throttle, | ||
TrainBrake, | ||
Reverser, | ||
IndBrake, | ||
Handbrake, | ||
Sander, | ||
Horn, | ||
HeadlightsFront, | ||
HeadlightsRear, | ||
StarterFuse, | ||
ElectricsFuse, | ||
TractionMotorFuse, | ||
StarterControl, | ||
DynamicBrake, | ||
CabLight, | ||
Wipers, | ||
FuelCutoff, | ||
ReleaseCyl, | ||
IndHeadlightsTypeFront, | ||
IndHeadlights1Front, | ||
IndHeadlights2Front, | ||
IndHeadlightsTypeRear, | ||
IndHeadlights1Rear, | ||
IndHeadlights2Rear, | ||
IndWipers1, | ||
IndWipers2, | ||
IndCabLight, | ||
IndDashLight, | ||
GearboxA, | ||
GearboxB, | ||
CylCock, | ||
Injector, | ||
Firedoor, | ||
Blower, | ||
Damper, | ||
Blowdown, | ||
CoalDump, | ||
Dynamo, | ||
AirPump, | ||
Lubricator, | ||
Bell | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
CCL.Types/Proxies/Controls/InteriorControlsManagerProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace CCL.Types.Proxies.Controls | ||
{ | ||
public class InteriorControlsManagerProxy : MonoBehaviour | ||
{ | ||
public bool electricsFuseAffectsIndicators = true; | ||
|
||
public List<DVControlType> reverseDirectionList = new List<DVControlType>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using CCL.Types.Proxies.Ports; | ||
using UnityEngine; | ||
|
||
namespace CCL.Types.Proxies.Controls | ||
{ | ||
public class OverridableControlProxy : MonoBehaviour | ||
{ | ||
[PortId(DVPortType.EXTERNAL_IN, DVPortValueType.CONTROL, true)] | ||
public string portId; | ||
|
||
public OverridableControlType ControlType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using CCL.Types.Proxies.Ports; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
|
||
namespace CCL.Types.Proxies.Indicators | ||
{ | ||
public abstract class IndicatorBrakeReaderProxy : MonoBehaviour | ||
{ | ||
[FuseId] | ||
public string fuseId; | ||
} | ||
|
||
public class IndicatorBrakeCylinderReaderProxy : IndicatorBrakeReaderProxy { } | ||
|
||
public class IndicatorBrakePipeReaderProxy : IndicatorBrakeReaderProxy { } | ||
|
||
public class IndicatorBrakeReservoirReaderProxy : IndicatorBrakeReaderProxy { } | ||
} |