Skip to content

Commit

Permalink
Auto Sweeper fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AkiSenkinn committed Dec 25, 2021
1 parent 5e8f825 commit 636c9f0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Asphalt/Asphalt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- General Package Properties -->
<PropertyGroup>
<PackageId>Asphalt</PackageId>
<Version>2.0.0.0</Version>
<Version>2.2.0.0</Version>
<Authors>Aki</Authors>
<Copyright>2021 Aki</Copyright>
<RepositoryUrl>https://github.com/aki-art/ONI-Mods</RepositoryUrl>
Expand Down Expand Up @@ -40,23 +40,23 @@

<ItemGroup>
<Reference Include="Unity.TextMeshPro">
<HintPath>D:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Unity.TextMeshPro.dll</HintPath>
<HintPath>D:\Programs\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Unity.TextMeshPro.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>D:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>D:\Programs\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>D:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
<HintPath>D:\Programs\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>D:\Programs\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>D:\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<HintPath>D:\Programs\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions Asphalt/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FUtility.SaveData;
using HarmonyLib;
using KMod;
using System.Collections.Generic;

namespace Asphalt
{
Expand All @@ -11,17 +12,20 @@ public class Mod : UserMod2
public const string ID = "Asphalt";
public static string modPath;
public static SaveDataManager<Config> config;

public static Config Settings => config.Settings;

public override void OnLoad(Harmony harmony)
{
base.OnLoad(harmony);
Log.Debuglog("DEBUG");
Log.PrintVersion();
ModAssets.LoadAssets();
modPath = path;
config = new SaveDataManager<Config>(path);
}

public override void OnAllModsLoaded(Harmony harmony, IReadOnlyList<KMod.Mod> mods)
{
base.OnAllModsLoaded(harmony, mods);
}
}
}
43 changes: 34 additions & 9 deletions Asphalt/Patches/ElementLoaderPatch.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,65 @@
using FUtility;
using HarmonyLib;
using System.Collections.Generic;
using UnityEngine;

namespace Asphalt.Patches
{
// Prepare Bitumen to be introduced to actual gameplay
class ElementLoaderPatch
public class ElementLoaderPatch
{
[HarmonyPatch(typeof(ElementLoader), "Load")]
public static class Patch_ElementLoader_Load
{
private static void AddTag(ref Tag[] tags, Tag tag)
{
// dont add duplicate tags (in case another mod added stuff before me)
foreach (Tag t in tags)
{
if (t == tag) return;
}

tags = tags.AddToArray(tag);
}
private static Tag CreateMaterialCategoryTag(Tag phaseTag, string materialCategoryField)
{
if (string.IsNullOrEmpty(materialCategoryField))
return phaseTag;

return TagManager.Create(materialCategoryField);
}

public static void Postfix(Dictionary<string, SubstanceTable> substanceTablesByDlc)
{
Element bitumen = ElementLoader.FindElementByHash(SimHashes.Bitumen);
bitumen.materialCategory = GameTags.ManufacturedMaterial;
//bitumen.materialCategory = GameTags.ManufacturedMaterial;
bitumen.materialCategory = CreateMaterialCategoryTag(TagManager.Create("Solid"), GameTags.ManufacturedMaterial.ToString()); // This tag is for storage

if (bitumen.oreTags is null)
{
bitumen.oreTags = new Tag[] { };
}

bitumen.oreTags.AddToArray(GameTags.ManufacturedMaterial);
bitumen.oreTags.AddToArray(GameTags.BuildableAny);
bitumen.oreTags.AddToArray(GameTags.Solid);
AddTag(ref bitumen.oreTags, GameTags.ManufacturedMaterial);
AddTag(ref bitumen.oreTags, GameTags.BuildableAny);
AddTag(ref bitumen.oreTags, GameTags.Solid);

if (bitumen.substance is null)
{
Log.Warning("Bitumen has no substance.");
return;
}

bitumen.substance = ModUtil.CreateSubstance(
"bitumen",
Element.State.Solid,
Assets.Anims.Find(anim => anim.name == "solid_bitumen_kanim"),
new Material(bitumen.substance.material),
ModAssets.Colors.bitumen,
ModAssets.Colors.bitumen,
ModAssets.Colors.bitumen );

bitumen.substance.material.mainTexture = ModAssets.bitumenTexture;
bitumen.substance.anim = Assets.Anims.Find(anim => anim.name == "solid_bitumen_kanim");
bitumen.substance.colour = ModAssets.Colors.bitumen;
bitumen.substance.conduitColour = ModAssets.Colors.bitumen;
bitumen.substance.uiColour = ModAssets.Colors.bitumen;
}
}
}
Expand Down

0 comments on commit 636c9f0

Please sign in to comment.