-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,020 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,3 +328,5 @@ ASALocalRun/ | |
|
||
# MFractors (Xamarin productivity tool) working folder | ||
.mfractor/ | ||
|
||
/static/script.js |
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,212 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net45</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<LangVersion>latest</LangVersion> | ||
<Authors>RedworkDE</Authors> | ||
<Copyright>(c) 2019 RedworDE</Copyright> | ||
<Platforms>AnyCPU</Platforms> | ||
<DefineConstants></DefineConstants> | ||
|
||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<Version>0.1.0</Version> | ||
</PropertyGroup> | ||
|
||
<Choose> | ||
<When Condition="$(DefineConstants.Contains('BepInEx'))"> | ||
<PropertyGroup> | ||
<OutputPath>C:\DerailValley\BepInEx\plugins\$(MSBuildProjectName)</OutputPath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="BepInEx"> | ||
<HintPath>C:\DerailValley\BepInEx\core\BepInEx.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="BepInEx.Harmony"> | ||
<HintPath>C:\DerailValley\BepInEx\core\BepInEx.Harmony.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="0Harmony"> | ||
<HintPath>C:\DerailValley\BepInEx\core\0Harmony.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<None Remove="Info.json" /> | ||
</ItemGroup> | ||
</When> | ||
<When Condition="$(DefineConstants.Contains('UMM'))"> | ||
<PropertyGroup> | ||
<OutputPath>C:\DerailValley\Mods\$(MSBuildProjectName)</OutputPath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="UnityModManager"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityModManager\UnityModManager.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="0Harmony"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityModManager\0Harmony-1.2.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<None Update="Info.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</When> | ||
</Choose> | ||
|
||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="BezierCurves"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\BezierCurves.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="DV.Interaction"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\DV.Interaction.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="DV.TerrainSystem"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\DV.TerrainSystem.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="DV.Utils"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\DV.Utils.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\Newtonsoft.Json.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="Unity.TextMeshPro"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\Unity.TextMeshPro.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.AudioModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.AudioModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.ImageConversionModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.IMGUIModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.PhysicsModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.ScreenCaptureModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.ScreenCaptureModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.StreamingModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.StreamingModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.TerrainModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.TerrainModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.TextRenderingModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UI"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.UI.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UIModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.UIModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UnityWebRequestAudioModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UnityWebRequestModule"> | ||
<HintPath>C:\DerailValley\DerailValley_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Core"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Data"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Drawing"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.IO.Compression.FileSystem"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Numerics"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Runtime.Serialization"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Xml"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Update="System.Xml.Linq"> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> | ||
<Error Text="You must define exactly one of the compilation constants 'BepInEx' and 'UMM'" Condition="!(( $(DefineConstants.Contains('BepInEx')) OR $(DefineConstants.Contains('UMM')) ) AND ( !$(DefineConstants.Contains('BepInEx')) OR !$(DefineConstants.Contains('UMM')) ))" /> | ||
<ItemGroup> | ||
<TsFiles Include="static\**\*.ts" /> | ||
</ItemGroup> | ||
<Exec Command="tsc --lib esnext,dom --strict %(TsFiles.Identity)" /> | ||
<ItemGroup> | ||
<None Remove="static\**\*" /> | ||
<EmbeddedResource Include="static\**\*" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
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,7 @@ | ||
{ | ||
"Id": "DvRemoteRemote", | ||
"DisplayName": "Remote Remote Controller", | ||
"Author": "RedworkDE", | ||
"Version": "0.1.0", | ||
"EntryMethod": "DvRemoteRemote.RemoteControl.Load" | ||
} |
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,18 @@ | ||
namespace DvRemoteRemote | ||
{ | ||
public abstract class Loco<TState, TActions> : RemoteControl.ILocoWrapperBase where TState : BaseLocoState, new() where TActions : BaseLocoActions, new() | ||
{ | ||
void RemoteControl.ILocoWrapperBase.GetState(object state) | ||
{ | ||
GetState((TState) state); | ||
} | ||
|
||
void RemoteControl.ILocoWrapperBase.GetActions(object actions) | ||
{ | ||
GetActions((TActions) actions); | ||
} | ||
|
||
public abstract void GetState(TState state); | ||
public abstract void GetActions(TActions actions); | ||
} | ||
} |
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,67 @@ | ||
using System; | ||
using JetBrains.Annotations; | ||
|
||
namespace DvRemoteRemote | ||
{ | ||
public class LocoBase : Loco<BaseLocoState, BaseLocoActions> | ||
{ | ||
[NotNull] private readonly LocoControllerBase _inner; | ||
|
||
public LocoBase([NotNull] LocoControllerBase inner) | ||
{ | ||
_inner = inner; | ||
} | ||
|
||
public override void GetState([NotNull] BaseLocoState state) | ||
{ | ||
state.Reverser = _inner.reverser; | ||
state.ReverserSymbol = _inner.GetReverserSymbol(); | ||
state.Throttle = (float) Math.Round(_inner.throttle, 2); | ||
state.TargetThrottle = (float) Math.Round(_inner.targetThrottle, 2); | ||
state.Break = (float) Math.Round(_inner.brake, 2); | ||
state.TargetBreak = (float) Math.Round(_inner.targetBrake, 2); | ||
state.Derailed = _inner.IsDerailed(); | ||
state.WheelSlip = _inner.IsWheelslipping(); | ||
state.Speed = (float) Math.Round(_inner.GetSpeedKmH(), 2); | ||
state.CanCouple = _inner.IsCouplerInRange(); | ||
state.MinCouplePos = -_inner.GetNumberOfCarsInRear() - 1; | ||
state.MaxCouplePos = _inner.GetNumberOfCarsInFront() + 1; | ||
state.LocoType = "base"; | ||
} | ||
|
||
public override void GetActions([NotNull] BaseLocoActions actions) | ||
{ | ||
actions.SetThrottle = _inner.SetThrottle; | ||
actions.SetBreak = _inner.SetBrake; | ||
actions.SetReverser = _inner.SetReverser; | ||
actions.Couple = _inner.Couple; | ||
actions.UnCouple = _inner.Uncouple; | ||
} | ||
} | ||
|
||
public class BaseLocoState | ||
{ | ||
public string LocoType { get; set; } | ||
public float Throttle { get; set; } | ||
public float TargetThrottle { get; set; } | ||
public float Break { get; set; } | ||
public float TargetBreak { get; set; } | ||
public float Reverser { get; set; } | ||
public string ReverserSymbol { get; set; } | ||
public bool Derailed { get; set; } | ||
public bool WheelSlip { get; set; } | ||
public float Speed { get; set; } | ||
public int MinCouplePos { get; set; } | ||
public int MaxCouplePos { get; set; } | ||
public bool CanCouple { get; set; } | ||
} | ||
|
||
public class BaseLocoActions | ||
{ | ||
public Action<float> SetThrottle { get; set; } | ||
public Action<float> SetBreak { get; set; } | ||
public Action<float> SetReverser { get; set; } | ||
public Action<int> Couple { get; set; } | ||
public Action<int> UnCouple { get; set; } | ||
} | ||
} |
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,52 @@ | ||
using System; | ||
|
||
namespace DvRemoteRemote | ||
{ | ||
public class LocoShunter : Loco<ShunterLocoState, ShunterLocoActions> | ||
{ | ||
private readonly LocoControllerShunter _inner; | ||
private readonly LocoBase _base; | ||
private readonly ShunterLocoSimulation _sim; | ||
|
||
public LocoShunter(LocoControllerShunter inner) | ||
{ | ||
_inner = inner; | ||
_base = new LocoBase(inner); | ||
_sim = inner.GetComponent<ShunterLocoSimulation>(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void GetState(ShunterLocoState state) | ||
{ | ||
_base.GetState(state); | ||
|
||
state.LocoType = "shunter"; | ||
state.Sander = _inner.GetSandersOn() ? 1 : 0; | ||
state.SanderFlow = _inner.GetSandersFlow() / _sim.sandFlow.max; | ||
state.EngineTemp = _inner.GetEngineTemp(); | ||
state.EngineOn = _inner.EngineOn; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void GetActions(ShunterLocoActions actions) | ||
{ | ||
_base.GetActions(actions); | ||
actions.SetSander = val => _inner.SetSandersOn(val >= 0.5f); | ||
actions.SetEngineOn = on => _inner.EngineOn = on; | ||
} | ||
} | ||
|
||
public class ShunterLocoState : BaseLocoState | ||
{ | ||
public float Sander { get; set; } | ||
public float SanderFlow { get; set; } | ||
public float EngineTemp { get; set; } | ||
public bool EngineOn { get; set; } | ||
} | ||
|
||
public class ShunterLocoActions : BaseLocoActions | ||
{ | ||
public Action<float> SetSander { get; set; } | ||
public Action<bool> SetEngineOn { get; set; } | ||
} | ||
} |
Oops, something went wrong.