pushing for zac

This commit is contained in:
Brady Bodily
2020-12-10 14:35:10 -07:00
parent 31a4309a47
commit 1cdf498800
19 changed files with 236 additions and 129 deletions

View File

@@ -4,9 +4,14 @@
<e p="$PROJECT_DIR$" t="IncludeFlat"> <e p="$PROJECT_DIR$" t="IncludeFlat">
<e p="ConsoleApp" t="IncludeRecursive"> <e p="ConsoleApp" t="IncludeRecursive">
<e p="bin" t="ExcludeRecursive" /> <e p="bin" t="ExcludeRecursive" />
<e p="Bootstrapper.cs" t="Include" />
<e p="ConsoleApp.csproj" t="IncludeRecursive" /> <e p="ConsoleApp.csproj" t="IncludeRecursive" />
<e p="CoreModule.cs" t="Include" /> <e p="CoreModule.cs" t="Include" />
<e p="IMapFactory.cs" t="Include" />
<e p="IModule.cs" t="Include" /> <e p="IModule.cs" t="Include" />
<e p="IUserConsole.cs" t="Include" />
<e p="MapFactory.cs" t="Include" />
<e p="Module.cs" t="Include" />
<e p="obj" t="ExcludeRecursive"> <e p="obj" t="ExcludeRecursive">
<e p="Debug" t="Include"> <e p="Debug" t="Include">
<e p="netcoreapp3.1" t="Include"> <e p="netcoreapp3.1" t="Include">
@@ -15,6 +20,7 @@
</e> </e>
</e> </e>
<e p="Program.cs" t="Include" /> <e p="Program.cs" t="Include" />
<e p="UserConsole.cs" t="Include" />
</e> </e>
<e p="packages" t="ExcludeRecursive" /> <e p="packages" t="ExcludeRecursive" />
<e p="RobotIntelFinal.sln" t="IncludeFlat" /> <e p="RobotIntelFinal.sln" t="IncludeFlat" />

View File

@@ -15,15 +15,23 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="dafcaeb7-80aa-43a3-a480-786fafb78c0b" name="Default Changelist" comment=""> <list default="true" id="dafcaeb7-80aa-43a3-a480-786fafb78c0b" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/Bootstrapper.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/IMapFactory.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ConsoleApp/IModule.cs" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/IUserConsole.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/RobotIntelFinal.sln" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/MapFactory.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Simulator/Networking/INetworkInterface.cs" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/Module.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Simulator/Networking/INetworkInterfaceFactory.cs" afterDir="false" /> <change afterPath="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Simulator/Networking/NetworkInterface.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/contentModel.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Simulator/Networking/NetworkInterfaceFactory.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.RobotIntelFinal/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Simulator/SimulatorModule.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleApp/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleApp/Program.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Networking/INetworkInterface.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Networking/INetworkInterfaceFactory.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Networking/NetworkInterface.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Networking/NetworkInterfaceFactory.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Networking/SimulatorModule.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Program.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Simulator/Simulator.csproj" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -38,8 +46,6 @@
<list> <list>
<option value="$PROJECT_DIR$/Simulator/Program.cs" /> <option value="$PROJECT_DIR$/Simulator/Program.cs" />
<option value="$PROJECT_DIR$/Simulator/CoreModule.cs" /> <option value="$PROJECT_DIR$/Simulator/CoreModule.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/Program.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/IModule.cs" /> <option value="$PROJECT_DIR$/ConsoleApp/IModule.cs" />
<option value="$PROJECT_DIR$/Simulator/SimulatorModule.cs" /> <option value="$PROJECT_DIR$/Simulator/SimulatorModule.cs" />
<option value="$PROJECT_DIR$/Simulator/NetworkInterfaceFactory.cs" /> <option value="$PROJECT_DIR$/Simulator/NetworkInterfaceFactory.cs" />
@@ -49,6 +55,14 @@
<option value="$PROJECT_DIR$/Simulator/Networking/INetworkInterfaceFactory.cs" /> <option value="$PROJECT_DIR$/Simulator/Networking/INetworkInterfaceFactory.cs" />
<option value="$PROJECT_DIR$/Simulator/Networking/INetworkInterface.cs" /> <option value="$PROJECT_DIR$/Simulator/Networking/INetworkInterface.cs" />
<option value="$PROJECT_DIR$/Simulator/Networking/NetworkInterface.cs" /> <option value="$PROJECT_DIR$/Simulator/Networking/NetworkInterface.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/IUserConsole.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/Module.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/CoreModule.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/IMapFactory.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/MapFactory.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/UserConsole.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/Program.cs" />
<option value="$PROJECT_DIR$/ConsoleApp/Bootstrapper.cs" />
</list> </list>
</option> </option>
</component> </component>
@@ -65,7 +79,7 @@
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="vue.rearranger.settings.migration" value="true" /> <property name="vue.rearranger.settings.migration" value="true" />
</component> </component>
<component name="RunManager" selected=".NET Project.Simulator"> <component name="RunManager" selected=".NET Project.ConsoleApp">
<configuration name="ConsoleApp" type="DotNetProject" factoryName=".NET Project"> <configuration name="ConsoleApp" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="" /> <option name="EXE_PATH" value="" />
<option name="PROGRAM_PARAMETERS" value="" /> <option name="PROGRAM_PARAMETERS" value="" />
@@ -96,7 +110,7 @@
<option name="PROJECT_EXE_PATH_TRACKING" value="1" /> <option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" /> <option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" /> <option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
<option name="PROJECT_KIND" value="DotNetCore" /> <option name="PROJECT_KIND" value="Unloaded" />
<option name="PROJECT_TFM" value="" /> <option name="PROJECT_TFM" value="" />
<method v="2"> <method v="2">
<option name="Build" /> <option name="Build" />
@@ -118,7 +132,7 @@
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="UnityProjectConfiguration" hasMinimizedUI="null" /> <component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" /> <component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" />
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES"> <option name="TAB_STATES">
@@ -130,6 +144,7 @@
</entry> </entry>
</map> </map>
</option> </option>
<option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" /> <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
@@ -140,5 +155,13 @@
</state> </state>
<state x="1640" y="-86" key="Rider.ProjectTemplateDialog.Size/0.0.1440.900/2640.-782.1200.1920/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607286605974" /> <state x="1640" y="-86" key="Rider.ProjectTemplateDialog.Size/0.0.1440.900/2640.-782.1200.1920/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607286605974" />
<state x="1640" y="-86" key="Rider.ProjectTemplateDialog.Size/0.25.1440.798/2640.-757.1200.1895/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607287214952" /> <state x="1640" y="-86" key="Rider.ProjectTemplateDialog.Size/0.25.1440.798/2640.-757.1200.1895/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607287214952" />
<state x="1860" y="-144" key="RiderGenerateDialog" timestamp="1607634276930">
<screen x="1440" y="-782" width="1200" height="1920" />
</state>
<state x="1860" y="-144" key="RiderGenerateDialog/0.0.1440.900/2640.-782.1200.1920/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607634276930" />
<state x="1703" y="-333" width="672" height="678" key="search.everywhere.popup" timestamp="1607633696072">
<screen x="1440" y="-782" width="1200" height="1920" />
</state>
<state x="1703" y="-333" width="672" height="678" key="search.everywhere.popup/0.0.1440.900/2640.-782.1200.1920/1440.-782.1200.1920@1440.-782.1200.1920" timestamp="1607633696072" />
</component> </component>
</project> </project>

View File

@@ -0,0 +1,7 @@
namespace ConsoleApp
{
public class Bootstrapper
{
p
}
}

View File

@@ -1,7 +1,20 @@
using System.Threading;
using ConsoleApp;
using DryIoc;
using Module = ConsoleApp.Module;
namespace Final namespace Final
{ {
public class CoreModule public class CoreModule : Module
{
public virtual void Register(IContainer container, ExecutionContext executionContext)
{
//container.Register<IUserConsole, UserConsole>(Reuse.Singleton);
}
public virtual void Resolve(IContainer container)
{ {
} }
}
} }

8
ConsoleApp/ISimRunner.cs Normal file
View File

@@ -0,0 +1,8 @@
namespace ConsoleApp
{
public interface ISimRunner
{
void GenerateMaps(int x, int y);
void StartSim();
}
}

View File

@@ -0,0 +1,7 @@
namespace ConsoleApp
{
public interface IUserConsole
{
void PrintStartMenu();
}
}

View File

@@ -0,0 +1,11 @@
using System.Dynamic;
namespace ConsoleApp
{
public interface IMapFactory
{
int Height { get; }
int Width { get; }
SquareMap SquareMap { get; }
}
}

View File

@@ -0,0 +1,29 @@
namespace ConsoleApp
{
public class MapFactory : IMapFactory
{
private int _defaultHeight;
private int _defaultWidth;
public int Height { get; protected set; }
public int Width { get; protected set; }
public MapFactory()
{
_defaultHeight = 0;
_defaultWidth = 0;
Height = _defaultHeight;
Width = _defaultWidth;
}
void CreateMaps(int height, int width)
{
Height = height;
Width = width;
}
void CreateMaps()
{
}
}
}

21
ConsoleApp/Module.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using DryIoc;
namespace ConsoleApp
{
public abstract class Module : IModule
{
public virtual void Register(IContainer container)
{
}
public virtual void Resolve(IContainer container)
{
}
}
}

View File

@@ -4,9 +4,35 @@ namespace ConsoleApp
{ {
class Program class Program
{ {
private static UserConsole _userConsole;
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine("Hello World!"); _userConsole = new UserConsole();
StartSimulation();
} }
private static void StartSimulation()
{
_userConsole.PrintStartMenu();
var input = _userConsole.GetUserInput();
if (input == "1")
{
var (x,y) = _userConsole.GetMapDimensions();
RunSimulation(x, y);
}
else
{
_userConsole.PrintInvalidInput();
StartSimulation();
}
}
private static void RunSimulation(int x,int y)
{
var bootStrapper = new Bootstrapper
var simRunner = new SimRunner();
}
} }
} }

23
ConsoleApp/SimRunner.cs Normal file
View File

@@ -0,0 +1,23 @@
namespace ConsoleApp
{
public class SimRunner : ISimRunner
{
private IMapFactory _mapFactory;
public SimRunner(IMapFactory mapFactory)
{
_mapFactory = mapFactory;
}
public void GenerateMaps(int x, int y)
{
_mapFactory.GenerateMaps(x, y);
_mapFactory.SquareMap();
throw new System.NotImplementedException();
}
public void StartSim()
{
throw new System.NotImplementedException();
}
}
}

45
ConsoleApp/UserConsole.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Linq;
namespace ConsoleApp
{
public class UserConsole : IUserConsole
{
private IMapFactory _mapFactory;
public UserConsole()
{
}
public void PrintStartMenu()
{
Console.WriteLine($"Make a selection: \n" +
$"\t 1: Auto generate maps. \n" +
$"\t 2: Load custom map. \n");
}
public string GetUserInput() => Console.ReadLine();
public void PrintInvalidInput()
{
Console.WriteLine($"Invalid input try again \n");
}
public (int width, int height) GetMapDimensions()
{
Console.WriteLine($"Enter Dimensions of map/area to clear as (x, y)");
var input = GetUserInput();
var numbers = input.Split();
if (numbers.Length != 4)
{
PrintInvalidInput();
GetMapDimensions();
}
var parsedNumbers = numbers.Where(x => !(x.Equals("(") || x.Equals(")"))).ToList();
int.TryParse(parsedNumbers[0], out var width);
int.TryParse(parsedNumbers[1], out var height);
return (width, height);
}
}
}

View File

@@ -1,7 +0,0 @@
namespace Final.Simulator
{
public interface INetworkInterface
{
}
}

View File

@@ -1,10 +0,0 @@
using System;
using System.Dynamic;
namespace Final.Simulator
{
public interface INetworkInterfaceFactory
{
INetworkInterface Create(UInt16 port);
}
}

View File

@@ -1,42 +0,0 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
namespace Final.Simulator
{
public class NetworkInterface : INetworkInterface
{
public UdpClient UdpClient { get; }
public Action<string> MessageRecieved;
private UInt16 _remotePort { get; }
private IPAddress _remoteIP { get; }
private UInt16 _localPort { get; }
private IPAddress _localIP { get; }
public NetworkInterface(IPAddress localIp, UInt16 localPort, )
{
_remoteEp = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
UdpClient = new UdpClient();
Task.Run(() => RegisterForMessages());
}
private void RegisterForMessages()
{
while (true)
{
var remoteEP = new IPEndPoint(_remoteIP, _remotePort);
MessageRecieved.Invoke(UdpClient.Receive(ref remoteEP).ToString());
UdpClient.Send(new byte[] {1}, 1, remoteEP);
}
}
private void TMP(object o)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,7 +0,0 @@
namespace Final.Simulator
{
public class NetworkInterfaceFactory : INetworkInterfaceFactory
{
public INetworkInterface Create(ushort port) => new NetworkInterface(port);
}
}

View File

@@ -1,18 +0,0 @@
using ConsoleApp;
using DryIoc;
namespace Final.Simulator
{
public class SimulatorModule : IModule
{
public void Register(IContainer container)
{
}
public void Resolve(IContainer container)
{
}
}
}

View File

@@ -1,12 +0,0 @@
using System;
namespace Simulator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View File

@@ -1,16 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ConsoleApp\ConsoleApp.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="UdpMessages" />
</ItemGroup>
</Project>