2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-07-01 16:33:43 -04:00

Reorganize all observatory core projects into monorepo (#25)

* chore: move all observatory repos to core

* only save journal folder on change, don't constantly re-check during monitoring

* chore: monorepo project changes

* chore: monorepo migration
This commit is contained in:
Xjph
2021-10-21 19:31:32 -02:30
committed by GitHub
parent 456c80198a
commit 4c1031b8f9
371 changed files with 7565 additions and 5 deletions

View File

@ -0,0 +1,188 @@
using Observatory.Framework;
using Observatory.Framework.Files;
using Observatory.Framework.Files.Journal;
using Observatory.Framework.Interfaces;
using Observatory.Framework.Files.ParameterTypes;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Collections.ObjectModel;
namespace Observatory.Botanist
{
public class Botanist : IObservatoryWorker
{
private IObservatoryCore Core;
private bool OdysseyLoaded = false;
private Dictionary
<
(
ulong systemAddress,
int bodyID
),
(
string bodyName,
int bioTotal,
List<string> speciesFound,
List<string> speciesAnalysed
)
> BioPlanets;
ObservableCollection<object> GridCollection;
private PluginUI pluginUI;
private bool readAllInProgress = false;
public string Name => "Observatory Botanist";
public string ShortName => "Botanist";
public string Version => typeof(Botanist).Assembly.GetName().Version.ToString();
public PluginUI PluginUI => pluginUI;
public object Settings { get => null; set { } }
public void JournalEvent<TJournal>(TJournal journal) where TJournal : JournalBase
{
switch (journal)
{
case LoadGame loadGame:
OdysseyLoaded = loadGame.Odyssey;
break;
case SAASignalsFound signalsFound:
{
var systemBodyId = (signalsFound.SystemAddress, signalsFound.BodyID);
if (OdysseyLoaded && !BioPlanets.ContainsKey(systemBodyId))
{
var bioSignals = from signal in signalsFound.Signals
where signal.Type == "$SAA_SignalType_Biological;"
select signal;
if (bioSignals.Any())
{
if (!BioPlanets.ContainsKey(systemBodyId))
{
BioPlanets.Add(
systemBodyId,
(signalsFound.BodyName, bioSignals.First().Count, new List<string>(), new List<string>())
);
}
else
{
var bioPlanet = BioPlanets[systemBodyId];
bioPlanet.bodyName = signalsFound.BodyName;
bioPlanet.bioTotal = bioSignals.First().Count;
}
}
}
}
break;
case ScanOrganic scanOrganic:
{
var systemBodyId = (scanOrganic.SystemAddress, scanOrganic.Body);
if (!BioPlanets.ContainsKey(systemBodyId))
{
//Unlikely to ever end up in here, but just in case create a new planet entry.
List<string> genus = new();
List<string> species = new();
genus.Add(scanOrganic.Genus_Localised);
species.Add(scanOrganic.Species_Localised);
var bioPlanet = (string.Empty, 0, genus, species);
BioPlanets.Add(systemBodyId, bioPlanet);
}
else
{
var bioPlanet = BioPlanets[systemBodyId];
switch (scanOrganic.ScanType)
{
case ScanOrganicType.Log:
case ScanOrganicType.Sample:
if (!bioPlanet.speciesFound.Contains(scanOrganic.Species_Localised))
{
bioPlanet.speciesFound.Add(scanOrganic.Species_Localised);
}
break;
case ScanOrganicType.Analyse:
if (!bioPlanet.speciesAnalysed.Contains(scanOrganic.Species_Localised))
{
bioPlanet.speciesAnalysed.Add(scanOrganic.Species_Localised);
}
break;
}
}
UpdateUIGrid();
}
break;
}
}
public void Load(IObservatoryCore observatoryCore)
{
GridCollection = new();
BotanistGrid uiObject = new();
GridCollection.Add(uiObject);
pluginUI = new PluginUI(GridCollection);
BioPlanets = new();
Core = observatoryCore;
}
public void ReadAllStarted()
{
readAllInProgress = true;
Core.ClearGrid(this, new BotanistGrid());
}
public void ReadAllFinished()
{
readAllInProgress = false;
UpdateUIGrid();
}
private void UpdateUIGrid()
{
// Suppress repainting the entire contents of the grid on every ScanOrganic record we read.
if (readAllInProgress) return;
BotanistGrid uiObject = new();
Core.ClearGrid(this, uiObject);
foreach (var bioPlanet in BioPlanets.Values)
{
if (bioPlanet.speciesFound.Count == 0)
{
var planetRow = new BotanistGrid()
{
Body = bioPlanet.bodyName,
BioTotal = bioPlanet.bioTotal.ToString(),
Species = "(NO SAMPLES TAKEN)",
Analysed = string.Empty
};
Core.AddGridItem(this, planetRow);
}
for (int i = 0; i < bioPlanet.speciesFound.Count; i++)
{
var speciesRow = new BotanistGrid()
{
Body = i == 0 ? bioPlanet.bodyName : string.Empty,
BioTotal = i == 0 ? bioPlanet.bioTotal.ToString() : string.Empty,
Species = bioPlanet.speciesFound[i],
Analysed = bioPlanet.speciesAnalysed.Contains(bioPlanet.speciesFound[i]) ? "✓" : ""
};
Core.AddGridItem(this, speciesRow);
}
}
}
}
public class BotanistGrid
{
public string Body { get; set; }
public string BioTotal { get; set; }
public string Species { get; set; }
public string Analysed { get; set; }
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>ObservatoryKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<VersionSuffix>0.0.$([System.DateTime]::UtcNow.DayOfYear.ToString()).$([System.DateTime]::UtcNow.ToString(HHmm))</VersionSuffix>
<AssemblyVersion Condition=" '$(VersionSuffix)' == '' ">0.0.0.1</AssemblyVersion>
<AssemblyVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
<Version Condition=" '$(VersionSuffix)' == '' ">0.0.1.0</Version>
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</Version>
</PropertyGroup>
<ItemGroup>
<Reference Include="ObservatoryFramework">
<HintPath>..\ObservatoryFramework\bin\Release\net5.0\ObservatoryFramework.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy $(TargetPath) $(SolutionDir)\..\ObservatoryCore\$(OutDir)plugins\ /y" />
</Target>
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObservatoryBotanist", "ObservatoryBotanist.csproj", "{498F7360-D443-4D64-895C-9EAB5570D019}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{498F7360-D443-4D64-895C-9EAB5570D019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{498F7360-D443-4D64-895C-9EAB5570D019}.Debug|Any CPU.Build.0 = Debug|Any CPU
{498F7360-D443-4D64-895C-9EAB5570D019}.Release|Any CPU.ActiveCfg = Release|Any CPU
{498F7360-D443-4D64-895C-9EAB5570D019}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0CC48015-0A6F-420C-9939-A71F3D33FF60}
EndGlobalSection
EndGlobal