Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build to load from NuGet and update theoretical max amounts to consider Proliferator Points #125

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
!.editorconfig
!.gitignore
!*.md
!*.ps1
!*.psm1
!NuGet.Config

bin/
obj/
tmp_release
.idea
.vs
32 changes: 27 additions & 5 deletions BetterStats/BetterStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

namespace BetterStats
{
// TODO: button to next producer/consumer
[BepInPlugin("com.brokenmass.plugin.DSP.BetterStats", "BetterStats", "1.3.2")]
[BepInPlugin("com.brokenmass.plugin.DSP.BetterStats", PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class BetterStats : BaseUnityPlugin
{
public class EnhancedUIProductEntryElements
Expand Down Expand Up @@ -650,11 +649,21 @@ public static void AddPlanetFactoryData(PlanetFactory planetFactory)
{
production = frequency * speed * (float)((double)veinPool[veinId].amount * (double)VeinData.oilSpeedMultiplier);
}

// flag to tell us if it's one of the advanced miners they added in the 20-Jan-2022 release
var isAdvancedMiner = false;
if (factorySystem.minerPool[i].type == EMinerType.Vein)
{
production = frequency * speed * miner.veinCount;
var minerEntity = factorySystem.factory.entityPool[miner.entityId];
isAdvancedMiner = minerEntity.stationId > 0 && minerEntity.minerId > 0;
}

// advanced miners aren't limited by belts
if (!isAdvancedMiner)
{
production = Math.Min(BELT_MAX_ITEMS_PER_MINUTE, production);
}
production = Math.Min(BELT_MAX_ITEMS_PER_MINUTE, production);

counter[productId].production += production;
counter[productId].producers++;
Expand All @@ -665,7 +674,12 @@ public static void AddPlanetFactoryData(PlanetFactory planetFactory)
if (assembler.id != i || assembler.recipeId == 0) continue;

var frequency = 60f / (float)((double)assembler.timeSpend / 600000.0);
var speed = (float)(0.0001 * (double)assembler.speed);
var speed = (float)(0.0001 * Math.Max(assembler.speedOverride, assembler.speed));
// forceAccMode is true when Production Speedup is selected
if (!assembler.forceAccMode)
{
frequency += 60f / (float)( assembler.extraTimeSpend / 600000.0);
mattsemar marked this conversation as resolved.
Show resolved Hide resolved
}

for (int j = 0; j < assembler.requires.Length; j++)
{
Expand Down Expand Up @@ -733,7 +747,15 @@ public static void AddPlanetFactoryData(PlanetFactory planetFactory)
{
var lab = factorySystem.labPool[i];
if (lab.id != i) continue;
float frequency = 60f / (float)((double)lab.timeSpend / 600000.0);
// lab timeSpend is in game ticks, here we are figuring out the same number shown in lab window, example: 2.5 / m
// when we are in Production Speedup mode `speedOverride` is juiced. Otherwise we need to bump the frequency to account
// for the extra product produced after `extraTimeSpend` game ticks
float frequency = (float)(1f / (lab.timeSpend / GameMain.tickPerSec / (60f * Math.Max(lab.speed, lab.speedOverride))));

if (!lab.forceAccMode && lab.extraTimeSpend > 0 && lab.extraSpeed > 0)
{
frequency += (float)(1f / (lab.extraTimeSpend / GameMain.tickPerSec / (60f * lab.extraSpeed)));
}

if (lab.matrixMode)
{
Expand Down
139 changes: 25 additions & 114 deletions BetterStats/BetterStats.csproj
Original file line number Diff line number Diff line change
@@ -1,114 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F415C8D1-768D-407C-86AE-4D2EEAC179F1}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>DSM.BetterStats</RootNamespace>
<AssemblyName>BetterStats</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.2.0</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="BetterStats.cs" />
<Compile Include="ACPublic.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp_publicized, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\core\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\core\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="netstandard">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\netstandard.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\DowngradedAssemblies\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy $(TargetPath) "C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\scripts\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Add more information to the production stats panel</Description>
<AssemblyName>BetterStats</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>1.3.3</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package creates a temporary PluginInfo file with the plugin version coming from the csproj file and that can be referenced from the Plugin code.

https://github.com/BepInEx/BepInEx.Templates/tree/master/BepInEx.PluginInfoProps

<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-*" />
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<!-- <Exec Command="COPY $(TargetPath) 'C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\scripts\'" />-->
</Target>
</Project>
6 changes: 6 additions & 0 deletions BetterStats/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>
32 changes: 0 additions & 32 deletions BetterStats/Properties/AssemblyInfo.cs

This file was deleted.

8 changes: 5 additions & 3 deletions BetterStats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ Inspired by https://docs.bepinex.dev/master/articles/dev_guide/plugin_tutorial/1
### Setup visual studio

- Install Visual Studio (not visual studio code)
- In Visual Studio, create a new blank project and there choose "add more tools" and add .Net developpement support
- In Visual Studio, create a new blank project and there choose "add more tools" and add .Net development support
- Install .Net Framework 3.5 (be careful to choose "Framework")

### project setup

- In Visual Studio, choose import and then select "BetterStats.csproj"
- In the right tree, right click references and then select "add references" and add the requered references (most of them located in C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed ; others are from BepinEx)
- You will find the last DLL "Assembly-CSharp.refstub.dll" in https://discord.com/channels/806549677209944084/806556447885623336/809241758323572766
- Game libraries should be loaded from NuGet

### Create a release
- From a PowerShell prompt run `.\package -vertype ` with either major, minor, patch or 'none'. 'none' will not increment the version number
- Uploadable zip file will be placed in .\tmp_release
<div>Icon made by <a href="https://www.freepik.com" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>
71 changes: 71 additions & 0 deletions BetterStats/package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
param ($vertype = 'patch')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A build script I use in my own projects. Seems to make packaging releases a little less error prone.


Set-StrictMode -Version Latest

write-host "version type $vertype"

Remove-Item .\tmp_release -Force -Recurse
New-Item .\tmp_release -ItemType "directory" -Force

$manifestContent = Get-Content -path .\manifest.json -Raw
$j = $manifestContent | ConvertFrom-Json

$sourceFileContent = Get-Content -path .\BetterStats.csproj -Raw
$sourceFileContent -match '.*<Version>(\d+.\d+.\d+)</Version>.*'

$old_vernum = $Matches[1]

$v = [version]$old_vernum
write-host "v = $v"

if ($vertype -eq "minor")
{
$new_version = [version]::New($v.Major, $v.Minor + 1, 0)
}
elseif ($vertype -eq "patch")
{
$new_version = [version]::New($v.Major, $v.Minor, $v.Build + 1)
}
elseif ($vertype -eq "major")
{
$new_version = [version]::New($v.Major + 1, 0, 0)
}
elseif ($vertype -eq "none")
{
$new_version = [version]::New($v.Major, $v.Minor, $v.Build)
}
else
{
Write-Host "invalid vertype: should be (major, minor, patch), got $vertype"
exit
}

Write-Host "next version $new_version"
$new_version_string = "$([string]::Join(".", $new_version))";

$sourceFileContent -replace $old_vernum, $new_version_string | Set-Content -Path .\BetterStats.csproj -NoNewline

Start-Process dotnet.exe -ArgumentList "build" -NoNewWindow -PassThru -Wait

Copy-Item -Path bin/Debug/netstandard2.0/BetterStats.dll -Destination tmp_release
Copy-Item README.md -Destination tmp_release\README.md
Copy-Item icon.png -Destination tmp_release

if ($vertype -ne "none")
{
$j.version_number = $new_version_string
$j |ConvertTo-Json | Set-Content -Path .\tmp_release\manifest.json
Copy-Item .\tmp_release\manifest.json manifest.json
} else
{
Copy-Item .\manifest.json .\tmp_release\manifest.json
}


$compress = @{
Path = "tmp_release\*"
CompressionLevel = "Fastest"
DestinationPath = "tmp_release\BetterStats.zip"
}
Compress-Archive @compress