Eloreden

[Mod Help Fix] Airlock Door (Iraku)

Recommended Posts

Eloreden    0

Hi guy i'm here cause i need help with my mod. the mod in question kept gases and liquids separated when the door was in "auto" state so if the duplicators crossed it there was no passage of elements. the idea was very simple and functional.

Override the "SetSimState" method of the doors so that only with my Door the "ReplaceAndDisplaceElement" was called even if the door was open for passage. but now apparently this method also affects duplicators by "throwing them back if they stop at the door".

Specifically, the call to the "SimMessages.ModifyCell (arg)" method

ModifyCellMessage * modifyCellMessagePtr = stackalloc ModifyCellMessage [1];
                editCellMessagePtr-> cellIdx = gameCell;
                editCellMessagePtr-> callbackIdx = callbackIdx;
                editCellMessagePtr-> temperature = temperature;
                editCellMessagePtr-> mass = mass;
                editCellMessagePtr-> elementIdx = (byte) elementIdx;
                editCellMessagePtr-> replaceType = (byte) replace_type;
                editCellMessagePtr-> diseaseIdx = disease_idx;
                modifyCellMessagePtr-> diseaseCount = disease_count;
                editCellMessagePtr-> addSubType = do_vertical_solid_displacement? (byte) 0: (byte) 1;
Sim.SIM_HandleMessage ((int) SimMessageHashes.ModifyCell, sizeof (ModifyCellMessage), (byte *) modifyCellMessagePtr);

Do you have any idea how I can fix it?

Share this post


Link to post
Share on other sites
jiuye007    0

If you don't know how to do, you can refer to other mods of the same type.such as stephen's airlock door.come on!

Edited by jiuye007

Share this post


Link to post
Share on other sites
StarGeek    0

 

6 hours ago, jiuye007 said:

If you don't know how to do, you can refer to other mods of the same type.such as stephen's airlock door.come on!

I admittedly don't know much about creating mods, but I believe the  Stephen's Airlock Door works in a completely different manner.  That mod lets things into the center chamber, then pushes the gas/liquids back into the room they came from.  The dupe is stuck in the inner chamber until that happens.


Eloreden's mod, in the base game, completely prevents gas/liquids from passing through when the door is set to auto without impeding the movement of dupes.

The only other mod that works the same as Eloreden's, chromiumboy's Self-sealing Airlocks, suffers from the same problem.  Dupes trying to pass through stop and get entombed in the DLC.
 

 

Share this post


Link to post
Share on other sites
Eloreden    0

I actually took inspiration for the creation of the chromiumboy Mod. Enhancing it so that it can only be applied to a specific port. Right now the only way I can conceive is to completely change the flow of the elements by preventing it from going through the door, however I can't find in the code where the physics of the elements is managed.

 

Actually as I understand the world is evolving in the background. There is the game grid where each cell has its own properties, (set as pointers in memory or something similar) these properties change with the movement of the elements. But how these elements move I cannot understand.

the last thing that comes to my mind is that the UI affects the game code. But I don't know if this can actually be true.

Edited by Eloreden

Share this post


Link to post
Share on other sites
Eloreden    0

After numerous tests I realized that even inserting and managing the mod in the same way it is managed by the source code the error remains. So I don't think it depended on the "ReplaceAndDisplace" but on the initialization of the assets maybe ...

Share this post


Link to post
Share on other sites
EnemyArea    1

Hey there,

could you please use this code and try it again?

worked 4 me :)

using HarmonyLib;

namespace SelfSealingAirlocks
{
    // Update sim state setter to make airlock doors gas impermable
    [HarmonyPatch(typeof(Door), "SetWorldState")]
    internal class SelfSealingAirlocks_Door_SetWorldState
    {
        private static void Postfix(Door __instance)
        {
            // If the attached gameobject doesn't exist, exit here
            if (__instance.gameObject == null) return;

            Door.DoorType doorType = __instance.doorType;
            if (doorType <= Door.DoorType.ManualPressure || doorType == Door.DoorType.Sealed)
            {
                for (var i = 0; i < __instance.building.PlacementCells.Length; i++)
                {
                    var offsetCell = __instance.building.PlacementCells[i];
                    SimMessages.ClearCellProperties(offsetCell, 1);
                    SimMessages.ClearCellProperties(offsetCell, 2);
                    SimMessages.ClearCellProperties(offsetCell, 4);
                    SimMessages.SetCellProperties(offsetCell, (byte)(__instance.CurrentState == Door.ControlState.Auto ? 7 : 4));
                }
            }
        }
    }
}

 

Edited by EnemyArea

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now