RimWorld

RimWorld

LightsOut
Denne tråd er blevet låst
SlippyCheeze 2. juni 2022 kl. 7:29
wishlist: add latency between "should turn off" and "actually turn off"...
Hoi. Thanks for this mod – really appreciate it, and it just "makes sense" to me in that this is how the game *should* have worked from day on.

I have a feature request though: sometimes the lights are way more "disco" than "eco" because of random stuff. Long corridors where they are not forced on, rebuilding stuff where pawns take down a wall, then wander off for a decade-long meditation retreat keeping it reserved to rebuild, and other random things.

Actually, the most frequent trigger is that tiny little corridor between the kitchen, the freezer, and the storage zone that always winds up being a "legacy nightmare" that I can't get rid of.


I think it would work great if there was a "delay" between the current "turn off" trigger and the actual "turning off" of the light. (optionally, tables, too.)

I'm imagining something like five real-world seconds, after which the device turns off. That avoids the disco effect, without my micromanaging the occasional part of the base where this is an issue. Turning on, of course, resets this imaginary countdown. :)


I think that *should* be implementable in a more or less performance-neutral way, but if you want to come back with "bring me a pull request that does" that'd be reasonable. :)
< >
Viser 1-6 af 6 kommentarer
juanlopez2008  [udvikler] 11. juni 2022 kl. 16:03 
Only just seeing this now, how odd.

This is something that I've thought about before, but I ruled it out for a few reasons. Primarily I intended for this mod to model real-world things -- off switches on workbenches and light switches for rooms. You could make the argument that occupancy sensors exist, but that requires additional hardware and as such doesn't work well as a default for all rooms.

The Keep On feature was added as a means to address the disco problem, does that not address it for you? I typically leave my lights on in the kitchen and in high-traffic areas since they're pretty much always on anyway; for the big storage areas that I can't get rid of, I'll keep one of the lights on (or a couple if it's sufficiently big) so that as a pawn enters it isn't so jarring when the rest of the lights turn on. I find that it's a pretty nice setup for me.

The biggest part to consider here is that a static timeout time isn't likely to be a good solution. Some folks will feel it's too long, others too short; for some lights, a timeout of n ticks is right, for others it would be much too long. You could give users the option to customize this, which helps the first of those two example issues, but there's no amount of feasible configuration that is going to help with the second, at least trivially.

The feasible solution to the problem would be to add some kind of occupancy sensor building that would have a configurable delay so it could be set for each room individually. Further, a smarter solution might gather statistics about the room and how pawns are using it. For example, if a pawn leaves the room empty and then a pawn enters shortly thereafter, how long, on average, was the room empty? You could set the delay to somewhere around that average, which would keep the lights on for an appropriate time for that room without requiring users to micromanage the delay.

I don't think this would be a performance-intensive modification, but it would require a number of changes to how this mod is set up, since there's no way to delay things at the moment. It's entirely possible, but I definitely wouldn't have time to do this any time soon -- so I am unfortunately going to leave you with a "feel free to submit a PR" on it.

As a note, I could get behind a PR for an occupancy sensor, but I don't know that I'd approve a PR with a base timeout for all lights in general. If you feel strongly that that's the solution you'd like, I'd also definitely accept a PR that makes the modifications necessary for you to make your own mod that patches that behavior into my mod. Just because I won't add it doesn't mean you can't -- that's what modding is all about!

What are your thoughts?
SlippyCheeze 13. juni 2022 kl. 0:07 
my own "model of the real world" is that I would totally switch off the room lights, unless I expected to be back there in a couple of minutes. the "time delay turn-off" is really a cheap way to simulate that.

anyway, those are super-useful thoughts, and I hadn't considered some of them. I'll think further, and see how I go writing my own logic to do the "is someone here, countdown timer" style thing.

if that turns out to be useful, I'll send you a PR for anything that makes integration better, should it come to that. :) if it turns out to be, well, a "great idea on paper, not so much in the game" then it'll just quietly walk away... haha.
juanlopez2008  [udvikler] 13. juni 2022 kl. 17:43 
That thought process is something I considered, but I didn’t think that I’d be able to reliably detect if a pawn was going to return to a room (what if they got drafted, saw an enemy, etc… tons of reasons they legitimately wouldn’t return, which would leave the light on). While that’s realistic enough, it feels like buggy behavior. The delay serves some of the same purpose, but it breaks the “it’s a light switch mod” vibe, so I decided against it.

If you were thinking about it, I would recommend NOT redoing the logic to see if someone is in a room, or the triggers for turning lights on and off, etc… as someone who wrote it once, it’s not worth it. I’d rather part my mod out into a Core package that other folks can use in their mods than have anyone try and do it again to get the same functionality. It would also lessen your burden since it would be on me to support all the different lights (not that I’m stoked about that, but it be like that sometimes).

If I were implementing these changes, I would change the dictionary of “can these be on” (I forget the name, it’s in Common.Resources I think?) to be an int instead of a bool, and have it represent the number of ticks until it turns off: let 0 be off (no ticks remaining), -1 be on (infinite ticks remaining), and n be a countdown of ticks before the light turns off, which gets decremented once per tick.

Then change the EnableLight function to take an int to set it to (default value of -1), and adjust the tick to decrement that value (probably add another method in Common.Lights for that). There are a couple ways you could get the tickwise behavior, but I don’t know if I have any readily available in my mod yet.

After that, I’d change the DisableAllLights code to check for the occupancy sensor and use that value instead of -1. Alternatively, if you wanted to make it your own mod (with or without the occupancy sensor) you could do a bool prefix patch on the DisableAllLights method and return true if you handled the lights. If you did it that way, you’d most likely still want to do the PR to change the dictionary to an int instead of a bool since that would make the rest much, much easier.

I think that would be the bulk of the work; the rest of the triggering events and enabling/disabling lights my mod could handle for you! I can also be a resource, if that would be helpful.
Sidst redigeret af juanlopez2008; 13. juni 2022 kl. 17:55
SlippyCheeze 14. juni 2022 kl. 5:16 
<3
juanlopez2008  [udvikler] 2. nov. 2022 kl. 5:54 
It’s been added in the latest update, my friend :NeoPanda:
SlippyCheeze 8. nov. 2022 kl. 7:19 
Wow, thank you! I'm not playing RimWorld right now, outside context, but I'll definitely check this out the next time I grab it. :)
< >
Viser 1-6 af 6 kommentarer
Per side: 1530 50