mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 06:13:36 +08:00
Dustbin v1.2.1, fixes #2
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<BepInExPluginGuid>org.soardev.dustbin</BepInExPluginGuid>
|
<BepInExPluginGuid>org.soardev.dustbin</BepInExPluginGuid>
|
||||||
<Description>DSP MOD - Dustbin</Description>
|
<Description>DSP MOD - Dustbin</Description>
|
||||||
<Version>1.2.0</Version>
|
<Version>1.2.1</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<PackageId>Dustbin</PackageId>
|
<PackageId>Dustbin</PackageId>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
## Updates
|
## Updates
|
||||||
|
|
||||||
|
* 1.2.1
|
||||||
|
* Fix dynamic array bug in codes, which causes various bugs and errors.
|
||||||
|
|
||||||
* 1.2.0
|
* 1.2.0
|
||||||
* Use [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/) to save dustbin specified data now, which fixes [#1](https://github.com/soarqin/DSP_Mods/issues/1).
|
* Use [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/) to save dustbin specified data now, which fixes [#1](https://github.com/soarqin/DSP_Mods/issues/1).
|
||||||
* Fix issue for storages on multiple planets.
|
* Fix issue for storages on multiple planets.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using HarmonyLib.Tools;
|
||||||
|
|
||||||
namespace Dustbin;
|
namespace Dustbin;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ using IsDustbinIndexer = DynamicObjectArray<DynamicObjectArray<DynamicValueArray
|
|||||||
|
|
||||||
public class DynamicValueArray<T> where T: struct
|
public class DynamicValueArray<T> where T: struct
|
||||||
{
|
{
|
||||||
private T[] _store = new T[16];
|
private T[] _store = new T[64];
|
||||||
|
|
||||||
public T this[int index]
|
public T this[int index]
|
||||||
{
|
{
|
||||||
@@ -21,7 +22,12 @@ public class DynamicValueArray<T> where T: struct
|
|||||||
{
|
{
|
||||||
if (index >= _store.Length)
|
if (index >= _store.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _store, _store.Length * 2);
|
var count = index | (index >> 1);
|
||||||
|
count |= count >> 2;
|
||||||
|
count |= count >> 4;
|
||||||
|
count |= count >> 8;
|
||||||
|
count |= count >> 16;
|
||||||
|
Array.Resize(ref _store, count + 1);
|
||||||
}
|
}
|
||||||
_store[index] = value;
|
_store[index] = value;
|
||||||
}
|
}
|
||||||
@@ -51,13 +57,21 @@ public class DynamicObjectArray<T> where T: class, new()
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= _store.Length) return null;
|
if (index < 0) return null;
|
||||||
var result = _store[index];
|
if (index >= _store.Length)
|
||||||
if (result == null)
|
|
||||||
{
|
{
|
||||||
|
var count = index | (index >> 1);
|
||||||
|
count |= count >> 2;
|
||||||
|
count |= count >> 4;
|
||||||
|
count |= count >> 8;
|
||||||
|
count |= count >> 16;
|
||||||
|
Array.Resize(ref _store, count + 1);
|
||||||
|
}
|
||||||
|
T result = _store[index];
|
||||||
|
if (result != null)
|
||||||
|
return result;
|
||||||
result = new T();
|
result = new T();
|
||||||
_store[index] = result;
|
_store[index] = result;
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,10 +143,13 @@ public static class TankPatch
|
|||||||
{
|
{
|
||||||
r.ReadByte();
|
r.ReadByte();
|
||||||
var planetId = r.ReadInt32();
|
var planetId = r.ReadInt32();
|
||||||
var data = tankIsDustbin[planetId / 100][planetId % 100];
|
var data = tankIsDustbin[15];
|
||||||
|
data[0][0] = true;
|
||||||
|
data = tankIsDustbin[20];
|
||||||
|
data[0][0] = true;
|
||||||
for (var count = r.ReadInt32(); count > 0; count--)
|
for (var count = r.ReadInt32(); count > 0; count--)
|
||||||
{
|
{
|
||||||
data[r.ReadInt32()] = true;
|
tankIsDustbin[planetId / 100][planetId % 100][r.ReadInt32()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Dustbin",
|
"name": "Dustbin",
|
||||||
"version_number": "1.2.0",
|
"version_number": "1.2.1",
|
||||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/Dustbin",
|
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/Dustbin",
|
||||||
"description": "Can turn Storages and Tanks into Dustbin(Destroy incoming items) / 储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)",
|
"description": "Can turn Storages and Tanks into Dustbin(Destroy incoming items) / 储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
Reference in New Issue
Block a user