mirror of
https://github.com/simtactics/SimAINet.git
synced 2025-10-15 16:03:39 -04:00
Initial source commit
This commit is contained in:
commit
5620d11d95
11 changed files with 690 additions and 0 deletions
20
src/SimAntics.Tests/SimAntics.Tests.csproj
Normal file
20
src/SimAntics.Tests/SimAntics.Tests.csproj
Normal file
|
@ -0,0 +1,20 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SimAntics\SimAntics.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
13
src/SimAntics.Tests/UnitTest1.cs
Normal file
13
src/SimAntics.Tests/UnitTest1.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace SimAntics.Tests
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
22
src/SimAntics.sln
Normal file
22
src/SimAntics.sln
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimAntics", "SimAntics\SimAntics.csproj", "{6B758449-9D5A-456A-A733-31B7841E538A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimAntics.Tests", "SimAntics.Tests\SimAntics.Tests.csproj", "{4B7461A4-982A-4D89-92E3-E4D4A3EC85FB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6B758449-9D5A-456A-A733-31B7841E538A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B758449-9D5A-456A-A733-31B7841E538A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B758449-9D5A-456A-A733-31B7841E538A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B758449-9D5A-456A-A733-31B7841E538A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B7461A4-982A-4D89-92E3-E4D4A3EC85FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B7461A4-982A-4D89-92E3-E4D4A3EC85FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B7461A4-982A-4D89-92E3-E4D4A3EC85FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B7461A4-982A-4D89-92E3-E4D4A3EC85FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
19
src/SimAntics/Engine/VMInstruction.cs
Normal file
19
src/SimAntics/Engine/VMInstruction.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace SimAntics.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Compatibility class
|
||||
/// </summary>
|
||||
public class VMThread : VMInstruction { }
|
||||
|
||||
/// <summary>
|
||||
/// Handles instruction sets
|
||||
/// </summary>
|
||||
public class VMInstruction
|
||||
{
|
||||
public static int MAX_USER_ACTIONS = 20;
|
||||
|
||||
public VMContext Context;
|
||||
|
||||
public bool IsCheck;
|
||||
}
|
||||
}
|
11
src/SimAntics/IVM.cs
Normal file
11
src/SimAntics/IVM.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace SimAntics
|
||||
{
|
||||
public interface IVM
|
||||
{
|
||||
void Init();
|
||||
void Reset();
|
||||
void Update();
|
||||
void Tick();
|
||||
void InternalTick(uint tickId);
|
||||
}
|
||||
}
|
7
src/SimAntics/SimAntics.csproj
Normal file
7
src/SimAntics/SimAntics.csproj
Normal file
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
41
src/SimAntics/VM.cs
Normal file
41
src/SimAntics/VM.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
|
||||
namespace SimAntics
|
||||
{
|
||||
/// <summary>
|
||||
/// VM is an abstract class that contains the
|
||||
/// </summary>
|
||||
public abstract class VM : IVM
|
||||
{
|
||||
public bool IsTS1 { get; set; }
|
||||
public bool Ready { get; set; }
|
||||
public bool BHAVDirty { get; set; }
|
||||
|
||||
public delegate void VMRefreshHandler();
|
||||
public delegate void VMLotSwitchHandler(uint lotId);
|
||||
|
||||
public void Init()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InternalTick(uint tickId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
43
src/SimAntics/VMClock.cs
Normal file
43
src/SimAntics/VMClock.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
|
||||
namespace SimAntics
|
||||
{
|
||||
public class VMClock
|
||||
{
|
||||
public long Ticks { get; set; }
|
||||
public int MinuteFractions { get; set; }
|
||||
public int TicksPerMinute { get; set; }
|
||||
public int Minutes { get; set; }
|
||||
public int Hours { get; set; }
|
||||
|
||||
public int DayOfMonth = 1;
|
||||
public int Month = 6;
|
||||
public int Year = 1997;
|
||||
|
||||
public int FirePercent { get; set; }
|
||||
public long UTCStart = DateTime.UtcNow.Ticks;
|
||||
|
||||
public int TimeOfDay => (Hours >= 6 && Hours < 18) ? 0 : 1;
|
||||
public int Seconds => MinuteFractions * 60 / TicksPerMinute;
|
||||
|
||||
public DateTime UTCNow => (new DateTime(UTCStart)).AddSeconds(Ticks / 30.0);
|
||||
|
||||
public VMClock() {}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (FirePercent < 2000) FirePercent++;
|
||||
if (++MinuteFractions < TicksPerMinute) return;
|
||||
MinuteFractions = 0;
|
||||
if (++Minutes < 60) return;
|
||||
Minutes = 0;
|
||||
if (++DayOfMonth <= 30) return;
|
||||
DayOfMonth = 1;
|
||||
if (++Month <= 12) return;
|
||||
Month = 1;
|
||||
Year++;
|
||||
|
||||
Ticks++;
|
||||
}
|
||||
}
|
||||
}
|
8
src/SimAntics/VMContext.cs
Normal file
8
src/SimAntics/VMContext.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace SimAntics
|
||||
{
|
||||
public class VMContext
|
||||
{
|
||||
public static bool useWorld = true;
|
||||
public VM Vm;
|
||||
}
|
||||
}
|
5
src/global.json
Normal file
5
src/global.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "3.1.201"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue