Oxygen Not Included

Oxygen Not Included

Customize Plants
Crash when modifying fruit amount of Ovagro Vines
So, when changing the fruit amount on the Ovagro Vines, I get a crash when (I think) new vines are revealed in the map:

Exception in: (VineMother).VineMother.root.grown.growingBranches.Enter
System.NullReferenceException: Object reference not set to an instance of an object
at Growing.OnNewGameSpawn (System.Object data) [0x00007] in <3b73c925114143c5bad31ccbc5facdf1>:0
at Growing+<>c.<.cctor>b__39_0 (Growing component, System.Object data) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at EventSystem+IntraObjectHandler`1[ComponentType].Trigger (UnityEngine.GameObject gameObject, System.Object eventData) [0x0001e] in <7becb3f73037484c93dc2b548fe42a58>:0
at EventSystem.Trigger (UnityEngine.GameObject go, System.Int32 hash, System.Object data) [0x0004f] in <7becb3f73037484c93dc2b548fe42a58>:0
at EventExtensions.Trigger (UnityEngine.GameObject go, System.Int32 hash, System.Object data) [0x0001d] in <7becb3f73037484c93dc2b548fe42a58>:0
at VineMother+Instance.AttemptToSpawnBranches () [0x00059] in <3b73c925114143c5bad31ccbc5facdf1>:0
at VineMother.AttemptToSpawnBranches (VineMother+Instance smi) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at VineMother.SpawnBranchesIfNewGameSpawn (VineMother+Instance smi) [0x00008] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].ExecuteActions (StateMachine`4+State[StateMachineType,StateMachineInstanceType,MasterType,DefType] state, System.Collections.Generic.List`1[T] actions) [0x00048] in <3b73c925114143c5bad31ccbc5facdf1>:0

at UnityEngine.Logger.Log (UnityEngine.LogType logType, System.Object message, UnityEngine.Object context) [0x00000] in <82f243aab18c4f32918da2df41974365>:0
at UnityEngine.Debug.LogError (System.Object message, UnityEngine.Object context) [0x00000] in <82f243aab18c4f32918da2df41974365>:0
at Debug.LogError (System.Object obj, UnityEngine.Object context) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at DebugUtil.LogErrorArgs (UnityEngine.Object context, System.Object[] objs) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at DebugUtil.LogException (UnityEngine.Object context, System.String errorMessage, System.Exception e) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].ExecuteActions (StateMachine`4+State[StateMachineType,StateMachineInstanceType,MasterType,DefType] state, System.Collections.Generic.List`1[T] actions) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].PushState (StateMachine+BaseState state) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].GoTo (StateMachine+BaseState base_state) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+Parameter`1+Transition[StateMachineType,StateMachineInstanceType,MasterType,DefType,ParameterType].Evaluate (StateMachine+Instance smi) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].TryEvaluateTransitions (StateMachine+BaseState state, System.Int32 goto_id) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].PushState (StateMachine+BaseState state) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].GoTo (StateMachine+BaseState base_state) [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine+Instance.StartSM () [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachine`4+GenericInstance[StateMachineType,StateMachineInstanceType,MasterType,DefType].StartSM () [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at StateMachineController.StartSMIS () [0x00000] in <3b73c925114143c5bad31ccbc5facdf1>:0
at KPrefabID.OnSpawn () [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at KMonoBehaviour.Spawn () [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at Util.SpawnComponent (UnityEngine.Component cmp) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at MyAttributeManager`1[T].OnStart (System.Object obj, KMonoBehaviour cmp) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at MyAttributes.OnStart (System.Object obj, KMonoBehaviour cmp) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at MyAttributes.OnStart (KMonoBehaviour c) [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at KMonoBehaviour.Spawn () [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
at KMonoBehaviour.Start () [0x00000] in <7becb3f73037484c93dc2b548fe42a58>:0
Build: U56-679336-SCRPD
< >
Showing 1-14 of 14 comments
Fumihiko  [developer] 19 Jul @ 11:31pm 
Possible you set an invalid id. The game does not like it, if you spawn a null object.
Gariba 20 Jul @ 9:35am 
It doesn't crash if I apply the setting for an existing save. It seems to me it crashes whenever a new instance of the plant is initialized (eg. through revealing new parts of the map, enabling dev mode included). Changing other parameters of VineBranch like temperature and pressure ranges causes no issues at all. Could it be that it's trying to apply the setting to a growing vine, which does not yet give fruit, therefore trying to modify a null object?
Gariba 21 Jul @ 6:52am 
May I suggest adding a check to skip modifying values if they are invalid or null to avoid the crash?
Fumihiko  [developer] 21 Jul @ 9:41am 
I looked up the plant. No wonder that does not work. That's a whole new mechanic. When you set a fruitId (or amount) it will patch the plant to give it the growth components (so decorative plants can have fruits).
This plant clearly has incompatible components that will conflict with that. There is no solution for that. If I were to patch this, I would need to remove the new mechanic, which is probably undesireable.
Fumihiko  [developer] 21 Jul @ 9:44am 
Although if the plant grows fruits through a different mechanic, I could check that and edit that instead. But that's a sizable rewrite.
Gariba 22 Jul @ 9:37am 
After some trial and error, I (well, ChatGPT mostly) finally found a patch that actually works to change the fruit yield. Here's the code I used:
using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; using TUNING; using UnityEngine; namespace Quadovagro { public class QuadovagroPatches { [HarmonyPatch(typeof(Db), nameof(Db.Initialize))] public class Db_Initialize_Patch { public static void Postfix() { for (int i = 0; i < CROPS.CROP_TYPES.Count; i++) { var crop = CROPS.CROP_TYPES;
if (crop.cropId == VineFruitConfig.ID)
{
CROPS.CROP_TYPES = new Crop.CropVal(VineFruitConfig.ID, crop.cropDuration, 4);
Debug.Log($"[Quadovagro] Updated VineFruit crop yield to 4 units.");
break;
}
}
}
}
}
}[/code]
Fumihiko  [developer] 23 Jul @ 7:42am 
How do you know it works? It seems weird to me that you can setup all the environment, but then also require an LLM to generate code.

Btw, there are at least two errors in this snipplet. CROPS_TYPES is a list, but it sets a Crop.CropVal instead. So there is the indexer missing.

Another problem is that Crop.CropVal has a completely different constructor.

But the code does look convincing. Which is a major problem. I absolutely hate LLMs. I am not exaggerating, I really mean that.
Gariba 23 Jul @ 11:51am 
I'm also not fond of LLMs. But between work, life, and actually wanting to play games, I don't really want to spend time learning to properly code every game I like. I've got enough knowledge to at least know the general direction of what I'm looking for, but that's it.
I imagined the code would like absolutely disgusting to you lol.

As for how I know it works, I tested ingame.
Fumihiko  [developer] 24 Jul @ 8:03am 
I guess there is some fragmentation because of the conflicting markup tags. You can even see the /code tag at the end.
Fumihiko  [developer] 24 Jul @ 11:02am 
I changed the code. It stops applying the components for crops, if the plant already has the Crop component.
Gariba 24 Jul @ 12:09pm 
When applying a fruit_amount multiplier to the VineBranch after your last update, the codex reflects the changes but the actual harvest is still unchanged.
Fumihiko  [developer] 24 Jul @ 12:15pm 
I guess I need to update the traits too.
Fumihiko  [developer] 26 Aug @ 10:53am 
Mh... did I fix this? Let me know, if this is broken.
Gariba 29 Aug @ 1:22pm 
Just tested it, no crashes and yield is being properly multiplied. Thank you for your awesome work!
Sorry for the delay in responding. I was... otherwise engaged in salvaging derelicts around Ganymede.
< >
Showing 1-14 of 14 comments
Per page: 1530 50