using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BioProcessing")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BioProcessing")]
[assembly: AssemblyTitle("BioProcessing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BioProcessing
{
[BepInPlugin("com.certifried.bioprocessing", "BioProcessing", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BioProcessingPlugin : BaseUnityPlugin
{
public const string GUID = "com.certifried.bioprocessing";
public const string NAME = "BioProcessing";
public const string VERSION = "1.0.0";
private static BioProcessingPlugin instance;
public static ManualLogSource Log;
private Harmony harmony;
public static ConfigEntry<float> AlgaeGrowthRate;
public static ConfigEntry<float> MushroomGrowthRate;
public static ConfigEntry<float> BiofuelYield;
public static ConfigEntry<float> CompostEfficiency;
public static ConfigEntry<bool> EnableBioRemediation;
private static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();
private static Dictionary<string, GameObject> prefabCache = new Dictionary<string, GameObject>();
public static List<AlgaeVatController> ActiveAlgaeVats = new List<AlgaeVatController>();
public static List<MushroomFarmController> ActiveMushroomFarms = new List<MushroomFarmController>();
public static List<BioReactorController> ActiveBioReactors = new List<BioReactorController>();
public static List<ComposterController> ActiveComposters = new List<ComposterController>();
public static float TotalBiofuelProduced = 0f;
public static float TotalCompostProduced = 0f;
public static int TotalPlantsHarvested = 0;
private static Material cachedMaterial;
private void Awake()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"BioProcessing v1.0.0 loading...");
InitializeConfig();
LoadAssetBundles();
harmony = new Harmony("com.certifried.bioprocessing");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"BioProcessing loaded successfully!");
}
private void InitializeConfig()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
AlgaeGrowthRate = ((BaseUnityPlugin)this).Config.Bind<float>("Production", "AlgaeGrowthRate", 1f, new ConfigDescription("Multiplier for algae growth speed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
MushroomGrowthRate = ((BaseUnityPlugin)this).Config.Bind<float>("Production", "MushroomGrowthRate", 1f, new ConfigDescription("Multiplier for mushroom growth speed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
BiofuelYield = ((BaseUnityPlugin)this).Config.Bind<float>("Production", "BiofuelYield", 1f, new ConfigDescription("Multiplier for biofuel output", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
CompostEfficiency = ((BaseUnityPlugin)this).Config.Bind<float>("Production", "CompostEfficiency", 1f, new ConfigDescription("Multiplier for compost conversion rate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
EnableBioRemediation = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "EnableBioRemediation", true, "Allow biological cleanup of hazardous zones");
}
private void LoadAssetBundles()
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Bundles");
if (!Directory.Exists(text))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Bundles folder not found at " + text));
return;
}
string[] array = new string[3] { "mushroom_forest", "lava_plants", "fauna_turtle" };
string[] array2 = array;
foreach (string text2 in array2)
{
string text3 = Path.Combine(text, text2);
if (!File.Exists(text3))
{
continue;
}
try
{
AssetBundle val = AssetBundle.LoadFromFile(text3);
if ((Object)(object)val != (Object)null)
{
loadedBundles[text2] = val;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded bundle: " + text2));
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load bundle " + text2 + ": " + ex.Message));
}
}
}
private void Update()
{
ActiveAlgaeVats.RemoveAll((AlgaeVatController v) => (Object)(object)v == (Object)null);
ActiveMushroomFarms.RemoveAll((MushroomFarmController f) => (Object)(object)f == (Object)null);
ActiveBioReactors.RemoveAll((BioReactorController r) => (Object)(object)r == (Object)null);
ActiveComposters.RemoveAll((ComposterController c) => (Object)(object)c == (Object)null);
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
foreach (AssetBundle value in loadedBundles.Values)
{
if (value != null)
{
value.Unload(true);
}
}
loadedBundles.Clear();
}
public static GameObject GetPrefab(string bundleName, string prefabName)
{
string key = bundleName + "/" + prefabName;
if (prefabCache.TryGetValue(key, out var value))
{
return value;
}
if (!loadedBundles.TryGetValue(bundleName, out var value2))
{
BioProcessingPlugin bioProcessingPlugin = instance;
if (bioProcessingPlugin != null)
{
((BaseUnityPlugin)bioProcessingPlugin).Logger.LogWarning((object)("Bundle not loaded: " + bundleName));
}
return null;
}
GameObject val = value2.LoadAsset<GameObject>(prefabName);
if ((Object)(object)val != (Object)null)
{
prefabCache[key] = val;
}
return val;
}
public static void FixPrefabMaterials(GameObject obj)
{
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)cachedMaterial == (Object)null)
{
Renderer[] array = Object.FindObjectsOfType<Renderer>();
Renderer[] array2 = array;
foreach (Renderer val in array2)
{
if ((Object)(object)val.material != (Object)null && (Object)(object)val.material.shader != (Object)null && ((Object)val.material.shader).name.Contains("Universal"))
{
cachedMaterial = val.material;
break;
}
}
}
if ((Object)(object)cachedMaterial == (Object)null)
{
return;
}
Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
Renderer[] array3 = componentsInChildren;
foreach (Renderer val2 in array3)
{
Material[] materials = val2.materials;
for (int k = 0; k < materials.Length; k++)
{
if ((Object)(object)materials[k] != (Object)null && (Object)(object)materials[k].shader != (Object)null && !((Object)materials[k].shader).name.Contains("Universal") && !((Object)materials[k].shader).name.Contains("URP"))
{
Material val3 = new Material(cachedMaterial);
if ((Object)(object)materials[k].mainTexture != (Object)null)
{
val3.mainTexture = materials[k].mainTexture;
}
val3.color = materials[k].color;
materials[k] = val3;
}
}
val2.materials = materials;
}
}
public static Material GetEffectMaterial(Color color)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Material val = new Material(Shader.Find("Sprites/Default"));
val.color = color;
return val;
}
public static AlgaeVatController SpawnAlgaeVat(Vector3 position)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateAlgaeVatPrimitive();
val.transform.position = position;
((Object)val).name = $"AlgaeVat_{ActiveAlgaeVats.Count}";
AlgaeVatController algaeVatController = val.AddComponent<AlgaeVatController>();
algaeVatController.Initialize();
ActiveAlgaeVats.Add(algaeVatController);
Log.LogInfo((object)$"Spawned Algae Vat at {position}");
return algaeVatController;
}
public static MushroomFarmController SpawnMushroomFarm(Vector3 position)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = GetPrefab("mushroom_forest", "MushroomCluster");
GameObject val;
if ((Object)(object)prefab != (Object)null)
{
val = Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
FixPrefabMaterials(val);
}
else
{
val = CreateMushroomFarmPrimitive();
val.transform.position = position;
}
((Object)val).name = $"MushroomFarm_{ActiveMushroomFarms.Count}";
MushroomFarmController mushroomFarmController = val.AddComponent<MushroomFarmController>();
mushroomFarmController.Initialize();
ActiveMushroomFarms.Add(mushroomFarmController);
Log.LogInfo((object)$"Spawned Mushroom Farm at {position}");
return mushroomFarmController;
}
public static BioReactorController SpawnBioReactor(Vector3 position)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateBioReactorPrimitive();
val.transform.position = position;
((Object)val).name = $"BioReactor_{ActiveBioReactors.Count}";
BioReactorController bioReactorController = val.AddComponent<BioReactorController>();
bioReactorController.Initialize();
ActiveBioReactors.Add(bioReactorController);
Log.LogInfo((object)$"Spawned Bio Reactor at {position}");
return bioReactorController;
}
public static ComposterController SpawnComposter(Vector3 position)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateComposterPrimitive();
val.transform.position = position;
((Object)val).name = $"Composter_{ActiveComposters.Count}";
ComposterController composterController = val.AddComponent<ComposterController>();
composterController.Initialize();
ActiveComposters.Add(composterController);
Log.LogInfo((object)$"Spawned Composter at {position}");
return composterController;
}
private static GameObject CreateAlgaeVatPrimitive()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("AlgaeVat");
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
((Object)val2).name = "Tank";
val2.transform.SetParent(val.transform);
val2.transform.localPosition = Vector3.up * 1f;
val2.transform.localScale = new Vector3(2f, 2f, 2f);
Material effectMaterial = GetEffectMaterial(new Color(0.2f, 0.6f, 0.3f, 0.7f));
val2.GetComponent<Renderer>().material = effectMaterial;
GameObject val3 = new GameObject("Bubbles");
val3.transform.SetParent(val.transform);
val3.transform.localPosition = Vector3.up * 0.5f;
ParticleSystem val4 = val3.AddComponent<ParticleSystem>();
MainModule main = val4.main;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1f);
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.1f);
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.5f, 1f, 0.5f, 0.5f));
EmissionModule emission = val4.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f);
ShapeModule shape = val4.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
((ShapeModule)(ref shape)).radius = 0.8f;
return val;
}
private static GameObject CreateMushroomFarmPrimitive()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("MushroomFarm");
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val2).name = "Plot";
val2.transform.SetParent(val.transform);
val2.transform.localPosition = Vector3.up * 0.1f;
val2.transform.localScale = new Vector3(3f, 0.2f, 3f);
val2.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.3f, 0.2f, 0.1f));
Color color = default(Color);
for (int i = 0; i < 5; i++)
{
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)val3).name = $"Mushroom_{i}";
val3.transform.SetParent(val.transform);
float num = Random.Range(-1f, 1f);
float num2 = Random.Range(-1f, 1f);
float num3 = Random.Range(0.5f, 1f);
val3.transform.localPosition = new Vector3(num, 0.2f + num3 * 0.5f, num2);
val3.transform.localScale = new Vector3(0.4f, num3, 0.4f);
((Color)(ref color))..ctor(0.8f + Random.value * 0.2f, 0.4f + Random.value * 0.2f, 0.2f + Random.value * 0.2f);
val3.GetComponent<Renderer>().material = GetEffectMaterial(color);
}
return val;
}
private static GameObject CreateBioReactorPrimitive()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("BioReactor");
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)1);
((Object)val2).name = "Chamber";
val2.transform.SetParent(val.transform);
val2.transform.localPosition = Vector3.up * 1.5f;
val2.transform.localScale = new Vector3(1.5f, 2f, 1.5f);
val2.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.4f, 0.5f, 0.3f, 0.8f));
for (int i = 0; i < 4; i++)
{
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
((Object)val3).name = $"Pipe_{i}";
val3.transform.SetParent(val.transform);
float num = (float)i * 90f * ((float)Math.PI / 180f);
val3.transform.localPosition = new Vector3(Mathf.Cos(num) * 1f, 0.5f, Mathf.Sin(num) * 1f);
val3.transform.localScale = new Vector3(0.2f, 0.5f, 0.2f);
val3.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.5f, 0.5f, 0.5f));
}
GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
((Object)val4).name = "OutputTank";
val4.transform.SetParent(val.transform);
val4.transform.localPosition = new Vector3(2f, 0.5f, 0f);
val4.transform.localScale = new Vector3(0.8f, 1f, 0.8f);
val4.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.8f, 0.9f, 0.2f, 0.9f));
return val;
}
private static GameObject CreateComposterPrimitive()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Composter");
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val2).name = "Bin";
val2.transform.SetParent(val.transform);
val2.transform.localPosition = Vector3.up * 0.75f;
val2.transform.localScale = new Vector3(2f, 1.5f, 2f);
val2.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.4f, 0.3f, 0.2f));
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val3).name = "OrganicMatter";
val3.transform.SetParent(val.transform);
val3.transform.localPosition = Vector3.up * 1.2f;
val3.transform.localScale = new Vector3(1.8f, 0.6f, 1.8f);
val3.GetComponent<Renderer>().material = GetEffectMaterial(new Color(0.3f, 0.4f, 0.1f));
return val;
}
public static bool BioRemediateZone(Vector3 center, float radius)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (!EnableBioRemediation.Value)
{
return false;
}
Log.LogInfo((object)$"Bio-remediation initiated at {center} (radius: {radius}m)");
SpawnRemediationEffect(center, radius);
return true;
}
private static void SpawnRemediationEffect(Vector3 position, float radius)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("RemediationEffect");
val.transform.position = position;
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
MainModule main = val2.main;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(3f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(2f);
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.3f);
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.2f, 0.8f, 0.3f, 0.6f));
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(50f);
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = radius;
Object.Destroy((Object)(object)val, 5f);
}
public static void LogInfo(string message)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)message);
}
}
public static void LogWarning(string message)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogWarning((object)message);
}
}
public static void LogError(string message)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogError((object)message);
}
}
}
public class AlgaeVatController : MonoBehaviour
{
private static int nextId;
public float MaxAlgae = 100f;
public float ProductionRate = 1f;
private Renderer tankRenderer;
private Color emptyColor = new Color(0.2f, 0.3f, 0.2f, 0.5f);
private Color fullColor = new Color(0.1f, 0.8f, 0.2f, 0.8f);
public int FacilityId { get; private set; }
public float AlgaeStored { get; private set; }
public bool HasWater { get; set; } = true;
public bool HasLight { get; set; } = true;
public bool IsProducing => HasWater && HasLight && AlgaeStored < MaxAlgae;
public void Initialize()
{
FacilityId = nextId++;
Transform val = ((Component)this).transform.Find("Tank");
if ((Object)(object)val != (Object)null)
{
tankRenderer = ((Component)val).GetComponent<Renderer>();
}
}
private void Update()
{
if (IsProducing)
{
float num = ProductionRate * BioProcessingPlugin.AlgaeGrowthRate.Value;
AlgaeStored = Mathf.Min(MaxAlgae, AlgaeStored + num * Time.deltaTime);
}
UpdateVisuals();
}
private void UpdateVisuals()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)tankRenderer != (Object)null)
{
float num = AlgaeStored / MaxAlgae;
tankRenderer.material.color = Color.Lerp(emptyColor, fullColor, num);
}
}
public float Harvest(float amount)
{
float num = Mathf.Min(amount, AlgaeStored);
AlgaeStored -= num;
if (num > 0f)
{
BioProcessingPlugin.TotalPlantsHarvested++;
}
return num;
}
public float HarvestAll()
{
return Harvest(AlgaeStored);
}
private void OnDestroy()
{
BioProcessingPlugin.ActiveAlgaeVats.Remove(this);
}
}
public class MushroomFarmController : MonoBehaviour
{
private static int nextId;
public int MaxMushrooms = 20;
public float GrowthTime = 30f;
public float MaxFertilizer = 50f;
public float FertilizerPerMushroom = 2f;
private List<Transform> mushroomVisuals = new List<Transform>();
public int FacilityId { get; private set; }
public int MushroomsReady { get; private set; }
public float GrowthProgress { get; private set; }
public float FertilizerLevel { get; private set; }
public bool CanGrow => FertilizerLevel >= FertilizerPerMushroom && MushroomsReady < MaxMushrooms;
public void Initialize()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
FacilityId = nextId++;
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
if (((Object)val).name.StartsWith("Mushroom"))
{
mushroomVisuals.Add(val);
((Component)val).gameObject.SetActive(false);
}
}
}
private void Update()
{
if (CanGrow)
{
float num = 1f / GrowthTime * BioProcessingPlugin.MushroomGrowthRate.Value;
GrowthProgress += num * Time.deltaTime;
if (GrowthProgress >= 1f)
{
GrowthProgress = 0f;
MushroomsReady++;
FertilizerLevel -= FertilizerPerMushroom;
UpdateMushroomVisuals();
}
}
}
private void UpdateMushroomVisuals()
{
for (int i = 0; i < mushroomVisuals.Count; i++)
{
((Component)mushroomVisuals[i]).gameObject.SetActive(i < MushroomsReady);
}
}
public void AddFertilizer(float amount)
{
FertilizerLevel = Mathf.Min(MaxFertilizer, FertilizerLevel + amount);
}
public void AddCompost(int compostAmount)
{
float amount = (float)compostAmount * BioProcessingPlugin.CompostEfficiency.Value;
AddFertilizer(amount);
BioProcessingPlugin.TotalCompostProduced += compostAmount;
}
public int Harvest()
{
int mushroomsReady = MushroomsReady;
MushroomsReady = 0;
UpdateMushroomVisuals();
if (mushroomsReady > 0)
{
BioProcessingPlugin.TotalPlantsHarvested += mushroomsReady;
}
return mushroomsReady;
}
private void OnDestroy()
{
BioProcessingPlugin.ActiveMushroomFarms.Remove(this);
}
}
public class BioReactorController : MonoBehaviour
{
private static int nextId;
public float MaxOrganicMatter = 200f;
public float MaxBiofuel = 100f;
public float MaxBiogas = 100f;
public float OrganicToBiofuel = 0.3f;
public float OrganicToBiogas = 0.5f;
public float ProcessingRate = 5f;
private Light reactorLight;
private ParticleSystem steamParticles;
public int FacilityId { get; private set; }
public float OrganicMatter { get; private set; }
public float BiofuelStored { get; private set; }
public float BiogasStored { get; private set; }
public bool IsProcessing => OrganicMatter > 0f && (BiofuelStored < MaxBiofuel || BiogasStored < MaxBiogas);
public void Initialize()
{
FacilityId = nextId++;
SetupVisuals();
}
private void SetupVisuals()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("ReactorLight");
val.transform.SetParent(((Component)this).transform);
val.transform.localPosition = Vector3.up * 1.5f;
reactorLight = val.AddComponent<Light>();
reactorLight.type = (LightType)2;
reactorLight.range = 5f;
reactorLight.intensity = 0f;
reactorLight.color = new Color(0.5f, 0.8f, 0.3f);
GameObject val2 = new GameObject("Steam");
val2.transform.SetParent(((Component)this).transform);
val2.transform.localPosition = Vector3.up * 3f;
steamParticles = val2.AddComponent<ParticleSystem>();
MainModule main = steamParticles.main;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1f);
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.5f);
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.8f, 0.8f, 0.8f, 0.3f));
EmissionModule emission = steamParticles.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
ShapeModule shape = steamParticles.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
((ShapeModule)(ref shape)).radius = 0.3f;
}
private void Update()
{
if (IsProcessing)
{
float num = Mathf.Min(OrganicMatter, ProcessingRate * Time.deltaTime);
OrganicMatter -= num;
float num2 = num * OrganicToBiofuel * BioProcessingPlugin.BiofuelYield.Value;
float num3 = num * OrganicToBiogas;
BiofuelStored = Mathf.Min(MaxBiofuel, BiofuelStored + num2);
BiogasStored = Mathf.Min(MaxBiogas, BiogasStored + num3);
BioProcessingPlugin.TotalBiofuelProduced += num2;
}
UpdateVisuals();
}
private void UpdateVisuals()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)reactorLight != (Object)null)
{
reactorLight.intensity = (IsProcessing ? 2f : 0.5f);
}
if ((Object)(object)steamParticles != (Object)null)
{
EmissionModule emission = steamParticles.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(IsProcessing ? 20f : 0f);
}
}
public void AddOrganicMatter(float amount)
{
OrganicMatter = Mathf.Min(MaxOrganicMatter, OrganicMatter + amount);
}
public void AddAlgae(float algaeAmount)
{
AddOrganicMatter(algaeAmount);
}
public void AddMushrooms(int mushroomCount)
{
AddOrganicMatter((float)mushroomCount * 5f);
}
public float TakeBiofuel(float amount)
{
float num = Mathf.Min(amount, BiofuelStored);
BiofuelStored -= num;
return num;
}
public float TakeBiogas(float amount)
{
float num = Mathf.Min(amount, BiogasStored);
BiogasStored -= num;
return num;
}
private void OnDestroy()
{
BioProcessingPlugin.ActiveBioReactors.Remove(this);
}
}
public class ComposterController : MonoBehaviour
{
private static int nextId;
public float MaxWaste = 100f;
public float MaxFertilizer = 50f;
public float WasteToFertilizer = 0.5f;
public float ProcessingTime = 60f;
private float processingProgress;
public int FacilityId { get; private set; }
public float OrganicWaste { get; private set; }
public float FertilizerReady { get; private set; }
public bool IsProcessing => OrganicWaste >= 10f && FertilizerReady < MaxFertilizer;
public void Initialize()
{
FacilityId = nextId++;
}
private void Update()
{
if (IsProcessing)
{
float num = BioProcessingPlugin.CompostEfficiency.Value / ProcessingTime;
processingProgress += num * Time.deltaTime;
if (processingProgress >= 1f)
{
processingProgress = 0f;
float num2 = Mathf.Min(10f, OrganicWaste);
OrganicWaste -= num2;
float num3 = num2 * WasteToFertilizer;
FertilizerReady = Mathf.Min(MaxFertilizer, FertilizerReady + num3);
BioProcessingPlugin.TotalCompostProduced += num3;
}
}
UpdateVisuals();
}
private void UpdateVisuals()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)this).transform.Find("OrganicMatter");
if ((Object)(object)val != (Object)null)
{
float num = OrganicWaste / MaxWaste;
val.localScale = new Vector3(1.8f, 0.6f * num + 0.1f, 1.8f);
}
}
public void AddWaste(float amount)
{
OrganicWaste = Mathf.Min(MaxWaste, OrganicWaste + amount);
}
public float TakeFertilizer(float amount)
{
float num = Mathf.Min(amount, FertilizerReady);
FertilizerReady -= num;
return num;
}
public float TakeAllFertilizer()
{
return TakeFertilizer(FertilizerReady);
}
private void OnDestroy()
{
BioProcessingPlugin.ActiveComposters.Remove(this);
}
}
}