Hello. Recently I was developing a new mod, and noticed a strange phenomenon. I consider it necessary to report him.
So, the four components in their respective methods, incorrectly calculate the I/O cell, if they are configured to use a secondary port, this port has a non-zero offset, and the building is rotated or flipped.
- ConduitConsumer.GetInputCell
- ConduitDispenser.GetOutputCell
- SolidConduitConsumer.GetInputCell
- SolidConduitDispenser.GetOutputCell
In an unmodified game, the problem does not manifest itself, for the simple reason that there is no such building that simultaneously has a secondary port and can be rotated or flipped.
But if we try to add such a building, the following will happen:
On the left is a non-flipped building, on the right is an flipped building. As you can see, liquid chunks appear and disappear in an unexpected place in the wrong pipe.
Let's take a look, for example, at the decompiled code of method ConduitDispenser.GetOutputCell
private int GetOutputCell(ConduitType outputConduitType) { Building building = GetComponent<Building>(); if (useSecondaryOutput) { ISecondaryOutput[] components = GetComponents<ISecondaryOutput>(); foreach (ISecondaryOutput secondaryOutput in components) { if (secondaryOutput.HasSecondaryConduitType(outputConduitType)) { return Grid.OffsetCell(building.NaturalBuildingCell(), secondaryOutput.GetSecondaryConduitOffset(outputConduitType)); } } return Grid.OffsetCell(building.NaturalBuildingCell(), components[0].GetSecondaryConduitOffset(outputConduitType)); } return building.GetUtilityOutputCell(); }
My suggestion is to fix the code as follows, add building.GetRotatedOffset call:
private int GetOutputCell(ConduitType outputConduitType) { Building building = GetComponent<Building>(); if (useSecondaryOutput) { ISecondaryOutput[] components = GetComponents<ISecondaryOutput>(); foreach (ISecondaryOutput secondaryOutput in components) { if (secondaryOutput.HasSecondaryConduitType(outputConduitType)) { return Grid.OffsetCell(building.NaturalBuildingCell(), building.GetRotatedOffset(secondaryOutput.GetSecondaryConduitOffset(outputConduitType))); } } return Grid.OffsetCell(building.NaturalBuildingCell(), building.GetRotatedOffset(components[0].GetSecondaryConduitOffset(outputConduitType))); } return building.GetUtilityOutputCell(); }
Similarly, all four methods of the four components should be fixed. Then everything will be according to Feng Shui
PS. of course, in my mod, I can easily make a patch to fix this. But if there is another modder who also wants to add a rotatable building with secondary ports, and also makes his own patch, then an inter-mod conflict with unpredictable consequences is possible.
1. Just add a new rotatable building with secondary ports with a non-zero offset, and components ConduitConsumer / ConduitDispenser / SolidConduitConsumer / SolidConduitDispenser.
2. look what happened.
- 1
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now