Jump to content

Modded building is "not functioning"


Recommended Posts

Trying to create a mod that takes in gas canisters and inserts them into a ventilation network.

I've gotten to the point where it creates errands to fill itself, but the building itself reports as "not-functioning", which causes the chore to never be performed.

Anyone seen something like this? Not sure how else to debug.

current bottleneck.png

Link to comment
Share on other sites

It will always be a guess when you haven't shared the source code, but my best guess would be that you have an operational component and it's set to false (aka not operational) because it lacks input (the canisters). The chores are then disabled because you have your chore setup made in a way where disabling a building with operational will disable the chores.

You might want to look at Coal Generator Delivery Fixes as that mod works around that problem.

Link to comment
Share on other sites

You're exactly correct; I'm not sure why I didn't include the code in the first place!

 

public class CanisterInserterConfig : IBuildingConfig
	{
		public const string ID = "StormShark.CanisterInserter";
		static readonly string Name = "Canister Inserter";
		static readonly string Description = "Canister Inserters allow contained gas to be inserted directly into a ventilation network.";
		static readonly string Effect = "Loads " + UI.FormatAsLink("Gas""ELEMENTS_GAS"+ " canisters into " + UI.FormatAsLink("Pipes""GASPIPING"+ " for transport.\n\nMust be loaded by Duplicants.";
 
		public override BuildingDef CreateBuildingDef()
		{
			string id = ID;
			int width = 1;
			int height = 3;
			string anim = "gas_emptying_station_kanim";
			int hitpoints = 30;
			float construction_time = 60f;
			float[] tieR2 = TUNING.BUILDINGS.CONSTRUCTION_MASS_KG.TIER2;
			string[] refinedMetals = MATERIALS.REFINED_METALS;
			float melting_point = 1600f;
			BuildLocationRule build_location_rule = BuildLocationRule.OnFloor;
			EffectorValues tieR1 = NOISE_POLLUTION.NOISY.TIER1;
			BuildingDef buildingDef = BuildingTemplates.CreateBuildingDef(id, width, height, anim, hitpoints, construction_time, construction_mass: tieR2, construction_materials: refinedMetals,
																			melting_point: melting_point, build_location_rule: build_location_rule, decor: TUNING.BUILDINGS.DECOR.PENALTY.TIER2,
																			noise: tieR1, temperature_modification_mass_scale: 0.2f);
			buildingDef.Floodable = false;
			buildingDef.AudioCategory = "Metal";
			buildingDef.Overheatable = false;
			buildingDef.PermittedRotations = PermittedRotations.FlipH;
			buildingDef.OutputConduitType = ConduitType.Gas;
			buildingDef.UtilityOutputOffset = new CellOffset(01);
			buildingDef.ViewMode = OverlayModes.GasConduits.ID;
			return buildingDef;
		}
 
		public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
		{
 
			Prioritizable.AddRef(go);
			Storage storage = go.AddOrGet<Storage>();
			storage.fetchCategory = Storage.FetchCategory.Building;
			storage.storageFilters = STORAGEFILTERS.GASES;
			storage.showInUI = true;
			storage.showDescriptor = true;
			storage.capacityKg = 200f;
			storage.allowItemRemoval = false;
			ConduitDispenser conduitDispenser = go.AddOrGet<ConduitDispenser>();
			conduitDispenser.conduitType = ConduitType.Gas;
			conduitDispenser.alwaysDispense = true;
			go.AddOrGet<TreeFilterable>();
			go.AddOrGet<VesselInserter>();
		}
 
		public override void DoPostConfigureComplete(GameObject go)
		{
			//
		}
 
		public static void Setup()
		{
			Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ID.ToUpperInvariant()}.NAME""<link=\"" + ID + "\">" + Name + "</link>");
			Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ID.ToUpperInvariant()}.DESC", Description);
			Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ID.ToUpperInvariant()}.EFFECT", Effect);
 
 
			int categoryIndex = TUNING.BUILDINGS.PLANORDER.FindIndex(x => x.category == "HVAC");
			(TUNING.BUILDINGS.PLANORDER[categoryIndex].data as IList<String>)?.Add(ID);
 
			var TechGroup = new List<string>(Database.Techs.TECH_GROUPING["Distillation"]) { };
			TechGroup.Add(ID);
			Database.Techs.TECH_GROUPING["Distillation"= TechGroup.ToArray();
 
		}
	}
[SerializationConfig(MemberSerialization.OptIn)]
	public class VesselInserter : KMonoBehaviour
	{
 
		private FilteredStorage filteredStorage;
		private static readonly EventSystem.IntraObjectHandler<VesselInserter> OnOperationalChangedDelegate = new EventSystem.IntraObjectHandler<VesselInserter>((System.Action<VesselInserterobject>)((component, data) => component.OnOperationalChanged(data)));
		private static readonly EventSystem.IntraObjectHandler<VesselInserter> OnCopySettingsDelegate = new EventSystem.IntraObjectHandler<VesselInserter>((System.Action<VesselInserterobject>)((component, data) => component.OnCopySettings(data)));
 
 
 
		[SerializeField]
		public Color noFilterTint = (Color)FilteredStorage.NO_FILTER_TINT;
		[SerializeField]
		public Color filterTint = (Color)FilteredStorage.FILTER_TINT;
		protected override void OnPrefabInit()
		{
			base.OnPrefabInit();
			filteredStorage = new FilteredStorage(thisnullnullnullfalseDb.Get().ChoreTypes.StorageFetch);
			this.Subscribe<VesselInserter>(-592767678VesselInserter.OnOperationalChangedDelegate);
			this.Subscribe<VesselInserter>(-905833192VesselInserter.OnCopySettingsDelegate);
			filteredStorage.filterTint = filterTint;
			filteredStorage.noFilterTint = noFilterTint;
 
		}
 
		protected override void OnSpawn()
		{
			base.OnSpawn();
			Operational component = this.GetComponent<Operational>();
			component.SetActive(component.IsOperational, false);
			this.filteredStorage.FilterChanged();
		}
 
		protected override void OnCleanUp()
		{
			this.filteredStorage.CleanUp();
			base.OnCleanUp();
		}
 
		private void OnOperationalChanged(object data)
		{
			Operational component = this.GetComponent<Operational>();
			component.SetActive(component.IsOperational, false);
		}
 
		private void OnCopySettings(object data)
		{
 
		}
 
	}

In the meantime, I will poke around your github and see if I can suss something out from your code samples.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...