Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding airlocks and making normal doors leak air #166

Merged
merged 20 commits into from
Aug 19, 2016

Conversation

emilkris33
Copy link
Contributor

This is part of the goals outlined in #49

Makes doors leak air between rooms on either side. Is generalised so it can easily be controlled and applied to any furniture through lua.
This has a dual purpose. 1 air can leak into space. 2 O2 generators are not needed in every room.

Also ads airlock. More ekspensive differently colored door that only leaks air when open.

@GamerGeeked
Copy link

GamerGeeked commented Aug 18, 2016

Great Idea. 👍
UPDATE - Not that you aren't the only one to have it :)
UPDATE 2 - It should eventually have a leak speed based on pressure difference. (ex a room with full atmos leaks faster into a atmos-free room)

@emilkris33
Copy link
Contributor Author

@ComputerOverlord Leak speed is modified by pressure difference in this implementation

@GamerGeeked
Copy link

@emilkris33 Oh, I didn't look at it in-depth :P I just understood the idea.

@fre-ber
Copy link
Contributor

fre-ber commented Aug 18, 2016

I made a few attempts of getting this right in my own version of this game, as made during the video series. Unfortunately I never managed to get anything that felt natural enough. I wonder if the mechanic presented here actually does that trick. I haven't tried this code, but as the pressure depends on the volume of the room the mathematice feels off to me.

In my attempts I changed the gas dictionary to actually hold the mass of the gas as an absolute value and tried to figure out a formula for how much mass is actually transferred though a vent/door/deconstructed wall/etc. Googling this topic, however showed me just how deep this rabbit hole can go - the flow depends on the shape of the hole, roundness of the edges of the hole, smoothness of the inner sides of the hole, turbulence, temperature, density of the gas, pressure, etc.

How closely have you watched the behaviour of this code? Does it feel natural to you? I might implement the equivalent code in my own project and test for myself, but I would be happy to know how realistic you think this feels.

Also, have you thought about how to handle pressure equalisation when rooms are merged?

@GamerInspired
Copy link

GamerInspired commented Aug 18, 2016

What if there was some sort of valve that you could use the let O2 (or other/all gases) flow between room but also allowed you to close them if required?

Edit: make it clearer

@emilkris33
Copy link
Contributor Author

emilkris33 commented Aug 18, 2016

@fre-ber If I have to say it myself then the gas handling is very thought through. Most of the basic gas mechanics are from an earlier PR #77 . Gas is stored internally as pressure times volume(Units are atm times tiles). The O2 generator produces in terms of this value, but the tooltip shows it divided by number of tiles(As pressure). How much gas is transferred is dependent on the pressure difference, deltaTime, and a leakFactor for the object. LeakFactor for door is greater the more open the door is. The leakfactor takes care of all the weird variables and just has to be tuned to something that feels right. Tweaking of the leak values is still needed though i would like to have a more final version of the system before spending time on that.

Handling of merging and splitting rooms is also good. (implemented in #77 ) When splitting a room the atmosphere is split so the pressure in both rooms are as it where before, though the internal value different. When merging the total gas in the previous rooms get added.

@GamerInspired That can be implemented using this code without touching the C#. Only lua and xml and a new graphic is needed to add that. It can therefore also be modded in. Though for now you can not open for only one gas.(Though for now there is only one gas)

furniture.SetParameter("openness", Clamp01(furniture.GetParameter("openness")) )

furniture.UpdateOnChanged(furniture);
end

function OnUpdate_Leak_Door( furniture, deltaTime )
furniture.tile.EqualiseGas(deltaTime * 10.0 * (furniture.GetParameter("openness") + 0.1))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the 0.1 leak in normal doors be a parameter so that it'd be easy for other people creating doors to add more or less of it?

Copy link
Contributor Author

@emilkris33 emilkris33 Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I might look at doing that tomorrow. If this PR gets merged before that I will do it as part of my next changed to the atmosphere system(Unless someone beats me to it)

@fre-ber
Copy link
Contributor

fre-ber commented Aug 18, 2016

Cool, I will test something similar in my own project. Does the equalisation on room merge happen over time or is it instantaneous?


From: Emil notifications@github.com
Sent: Thursday, August 18, 2016 11:13:48 PM
To: TeamPorcupine/ProjectPorcupine
Cc: fre-ber; Mention
Subject: Re: [TeamPorcupine/ProjectPorcupine] Adding airlocks and making normal doors leak air (#166)

@fre-berhttps://github.com/fre-ber I have to say it myself then the gas handling is very thought through. Most of the basic gas mechanics are from an earlier PR #77#77 . Gas is stored internally as pressure times volume(Units are atm times tiles). The O2 generator produces in terms of this value, but the tooltip shows it divided by number of tiles. How much gas is transferred is dependent on the pressure difference, deltaTime, and a leakFactor for the object. LeakFactor for door is greater the more open the door is. The leakfactor takes care of all the weird variables and just has to be tuned to something that feels right. Tweaking of the leak values is still needed though i would like to have a more final version of the system before spending time on that.

Handling of merging and splitting rooms is also good. (implemented in #77#77 ) When spitting a room the atmosphere so the pressure in both rooms are as it where before, though the internal value different. When merging the total gas in the previous rooms get added.

@GamerInspiredhttps://github.com/GamerInspired That can be implemented using this code without touching the C#. Only lua and xml and a new graphic is needed to add that. It can therefore also be modded in. Though for now you can not open for only one gas.(Though for now there is only one gas)

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//pull/166#issuecomment-240858812, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJpmByAaWBlmDVqU1r0wuMvgTlLk6lUQks5qhMsMgaJpZM4Jno20.

@quill18
Copy link
Member

quill18 commented Aug 19, 2016

Merged!

@quill18 quill18 merged commit 9b2e3d1 into TeamPorcupine:master Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants