mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 04:13:32 +08:00
Add new MOD: Dustbin
This commit is contained in:
@@ -24,6 +24,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json package/README.md" />
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json package/README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogisticMiner", "LogisticMi
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HideTips", "HideTips\HideTips.csproj", "{4EABD71D-477F-448B-801B-48F8745A3FA7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dustbin", "Dustbin\Dustbin.csproj", "{931F0230-5941-4E49-AB19-66921AF14096}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -24,5 +26,9 @@ Global
|
||||
{4EABD71D-477F-448B-801B-48F8745A3FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4EABD71D-477F-448B-801B-48F8745A3FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4EABD71D-477F-448B-801B-48F8745A3FA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
77
Dustbin/Dustbin.cs
Normal file
77
Dustbin/Dustbin.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Dustbin;
|
||||
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class Dustbin : BaseUnityPlugin
|
||||
{
|
||||
private new static readonly BepInEx.Logging.ManualLogSource Logger =
|
||||
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
|
||||
|
||||
private bool _cfgEnabled = true;
|
||||
private static readonly int[] SandsFactors = { 0, 1, 5, 10, 100 };
|
||||
private static readonly bool[] IsFluid = new bool[2000];
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cfgEnabled = Config.Bind("General", "Enabled", _cfgEnabled, "enable/disable this plugin").Value;
|
||||
SandsFactors[1] = Config.Bind("General", "SandsPerItem", SandsFactors[1], "Sands gathered from normal items").Value;
|
||||
SandsFactors[0] = Config.Bind("General", "SandsPerFluid", SandsFactors[0], "Sands gathered from fluids").Value;
|
||||
SandsFactors[2] = Config.Bind("General", "SandsPerStone", SandsFactors[2], "Sands gathered from stones").Value;
|
||||
SandsFactors[3] = Config.Bind("General", "SandsPerSilicon", SandsFactors[3], "Sands gathered from silicon ores").Value;
|
||||
SandsFactors[4] = Config.Bind("General", "SandsPerFractal", SandsFactors[4], "Sands gathered from fractal silicon ores").Value;
|
||||
Harmony.CreateAndPatchAll(typeof(Dustbin));
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(string))]
|
||||
private static void OnGameStart()
|
||||
{
|
||||
foreach (var data in LDB.items.dataArray)
|
||||
{
|
||||
if (data.ID < 2000 && data.IsFluid)
|
||||
{
|
||||
IsFluid[data.ID] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), "AddItem",
|
||||
new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(bool) },
|
||||
new[]
|
||||
{
|
||||
ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal
|
||||
})]
|
||||
public static bool AbandonItems(ref int __result, StorageComponent __instance, int itemId, int count, int inc,
|
||||
out int remainInc, bool useBan = false)
|
||||
{
|
||||
remainInc = inc;
|
||||
Logger.LogInfo($"${__instance.id} ${__instance.top}");
|
||||
if (!useBan || count == 0 || __instance.id != __instance.top) return true;
|
||||
var size = __instance.size;
|
||||
if (size == 0 || size != __instance.bans || __instance.grids[0].count > 0) return true;
|
||||
__result = count;
|
||||
var isFluid = itemId < 2000 && IsFluid[itemId];
|
||||
var sandsPerItem = SandsFactors[isFluid
|
||||
? 0
|
||||
: itemId switch
|
||||
{
|
||||
1005 => 2,
|
||||
1003 => 3,
|
||||
1013 => 4,
|
||||
_ => 1,
|
||||
}];
|
||||
if (sandsPerItem <= 0) return false;
|
||||
var player = GameMain.mainPlayer;
|
||||
var addCount = count * sandsPerItem;
|
||||
player.sandCount += addCount;
|
||||
GameMain.history.OnSandCountChange(player.sandCount, addCount);
|
||||
/* Following line crashes game, seems that it should not be called in this working thread:
|
||||
* UIRoot.instance.uiGame.OnSandCountChanged(player.sandCount, addCount);
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
||||
29
Dustbin/Dustbin.csproj
Normal file
29
Dustbin/Dustbin.csproj
Normal file
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.dustbin</BepInExPluginGuid>
|
||||
<Description>DSP MOD - Dustbin</Description>
|
||||
<Version>1.0.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>Dustbin</PackageId>
|
||||
<RootNamespace>Dustbin</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.9.26.13026-r.0" />
|
||||
<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="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json package/README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
12
Dustbin/package/README.md
Normal file
12
Dustbin/package/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## Dustbin
|
||||
|
||||
### Storages with capacity limited to zero act like dustbins(abandon incoming items)
|
||||
|
||||
* Conditions to become dustbin: Storages with capacity limited to zero at top of storage stacks with nothing in 1st cell.
|
||||
* Items sent into dustbin are removed immediately.
|
||||
* Can get sands from abandoned items (with factors configurable):
|
||||
* Get 100 sands from each fractal silicon ore
|
||||
* Get 10 sands from each silicon ore
|
||||
* Get nothing from fluids
|
||||
* Get 1 sand from any other normal item
|
||||
* Known bug: stack 1 more storage up on a zero limited one and remove it will cause dustbin stop working. Just put somethings in and take them out to make the dustbin working again.
|
||||
BIN
Dustbin/package/icon.png
Normal file
BIN
Dustbin/package/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
9
Dustbin/package/manifest.json
Normal file
9
Dustbin/package/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Dustbin",
|
||||
"version_number": "1.0.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/Dustbin",
|
||||
"description": "Storages with capacity limited to zero act like dustbins(abandon incoming items)",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17"
|
||||
]
|
||||
}
|
||||
@@ -23,6 +23,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json package/README.md" />
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json package/README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
13
README.md
13
README.md
@@ -68,3 +68,16 @@
|
||||
* Skip prologue for new game.
|
||||
* Each type of tips/messages is configurable individually.
|
||||
* For sanity check warning messages, please check [CheatEnabler](CheatEnabler)
|
||||
|
||||
## [Dustbin](Dustbin)
|
||||
|
||||
### Storages with capacity limited to zero act like dustbins(abandon incoming items)
|
||||
|
||||
* Conditions to become dustbin: Storages with capacity limited to zero at top of storage stacks with nothing in 1st cell.
|
||||
* Items sent into dustbin are removed immediately.
|
||||
* Can get sands from abandoned items (with factors configurable):
|
||||
* Get 100 sands from each fractal silicon ore
|
||||
* Get 10 sands from each silicon ore
|
||||
* Get nothing from fluids
|
||||
* Get 1 sand from any other normal item
|
||||
* Known bug: stack 1 more storage up on a zero limited one and remove it will cause dustbin stop working. Just put somethings in and take them out to make the dustbin working again.
|
||||
Reference in New Issue
Block a user