Git Product home page Git Product logo

Comments (14)

originalfoo avatar originalfoo commented on July 26, 2024

boformer wrote:

One way I could think of is to replace the illumination texture, but that means all buildings of the same type will turn off their lights at the same time. Performance would also be a concern.

You could also look into the method that determines if a building has electricity, and then detour that or a method that calls it (no electricity = no lights)

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

Other things that cause lights out:

  • Power cut
  • Daytime
  • Building turned off

All those things likely call a function rather than replicating code. I have no idea how to find that in the code though :/

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

More from boformer:

Take a look at CommonBuildingAI.RenderInstance, especially this line:

instance.m_dataColor0 = buildingInfo.m_buildingAI.GetColor(buildingID, ref data, Singleton<InfoManager>.instance.CurrentMode);

That one calls CommonBuildingAI.GetColor (for normal buildings), which sets the correct color for the building when info view are open (e.g. electricity info view).

But there is also InfoManager.InfoMode.None (no overlay open), and it also returns a color!

The first 3 channels (r, g, b) are used for the visible color variation of the building (growable buildings have 4 color variations), but it seems like the alpha channel (a) is used to store the electricity value (0f for off, 1f for on):

if (ShowConsumption(buildingID, ref data) && data.m_fireIntensity == 0 && flag)
{
    Singleton<ElectricityManager>.instance.CheckElectricity(data.m_position, out bool flag2);
    result.a = ((!flag2 && ElectricityGridRadius() != 0f) ? 0f : 1f);
}
else
{
    result.a = 0f;
}

You can see that the lights are always turned off when the building is on fire, or when the building is not active (when flag is false).

You can also see that before setting alpha to 1f, ShowConsumption(buildingID, ref data) is checked. You could detour that method to return false under certain circumstances to turn off the lights of a particular building! Make sure that your detoured code is efficient!

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

EDIT: moved off-topic feature request to #78

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

Just guessing at some possible problems that might arise and what mods could illustrate how to work round them...

For hiding problem indicators: https://steamcommunity.com/sharedfiles/filedetails/?id=561293123

For disabling problems: https://steamcommunity.com/sharedfiles/filedetails/?id=917543381

Couldn't find the source for the mods on github, but I assume it might be included as plain text in the workshop file?

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

Building light overrides was added to Rush Hour 2 mod: PropaneDragon/Rush-Hour-2@afd83ca

from realtime.

dymanoid avatar dymanoid commented on July 26, 2024

@aubergine10 ...and that causes chaos, when I read the user comments on that mod.

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

The update was pushed to Steam on Sat 22nd July, and I've not see any comments on the mod page (or /r/CitiesSkylines) from that time to present about issues with the lights. Are there other places where the mod is being discussed?

Regardless, I was posting more as confirmation that the code mentioned by boformer does seem to work in respect of turning lights on and off.

I'm not sure the somewhat excessive mod config options relating to lighting in the RH2 mod are necessary (a single option would suffice IMO).

from realtime.

dymanoid avatar dymanoid commented on July 26, 2024

@aubergine10 The Rush Hour 2 developer quickly reverted the published update, because it caused massive performance drops. People reported 3-5 FPS.

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

Performance has been an issue with Rush Hour 2 since inception, and affects many aspects of that mod (eg. see: PropaneDragon/Rush-Hour-2#22 ).

The update with "lights out" was bundled with loads of other stuff, all of which was implemented in ways that caused performance issues, including the lights out bit.

Part of the problem is that RH2 is doing "lights out" for all types of buildings, and also doing a shed load of logic to determine if a building has it's lights out or not every frame? - isn't that going to fubar branch predication?

The "lights out but building still on" should only be applied to residential buildings (as turning building off would be non viable due to causing all cims to be evicted).

All other types of buildings should really use the "building turned off" approach (maybe with some override of warning indicators) as that would also prevent deliveries, workers, etc. -- discussed in #78 .

For the residential buildings it should be just a percentage of them (from memory RH2 is actually checking whether the cims in a residence are at home and crazy stuff like that). So once a percentage has the lights turned out (ideally of a time span of one in-game hour for some variance) they just stay off until morning (specifically ~1 hour before day shift starts?).

I assume the game is already retaining lighting state somehow - otherwise all the lights would be flashing on and off all night in vanilla. As long as the function(s) which affect lighting on residences can be found, it should be viable to prevent the lights coming back on at unwanted times.

Note: I'd expect things like power coming back on after a power outage to cause lights to go back on, and I'd be happy for them to stay on until morning in that scenario because I'd be checking all areas of my city for power outages (a power outage will often cause other problems so when checking I've fixed things I tend to look at the lights rather than confusing multi-state warning bubbles).

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

To be blunt, the reason I'm asking for these features in RealTime, rather that RushHour, is that you are consistently finding performant ways to implement features. The graphs in PropaneDragon/Rush-Hour-2#30 exemplify this.

If residential lights out at night can be implemented in a performant manner, my bets are on RealTime being the mod where that will happen. Same with the "turn buildings off during certain shifts" stuff discussed in #78.

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

Yesssssssssssssssss!

from realtime.

dymanoid avatar dymanoid commented on July 26, 2024

@aubergine10, just curious: are you enjoying these croutons in our soup as they are or do we need some salt/pepper?

from realtime.

originalfoo avatar originalfoo commented on July 26, 2024

The croutons are great, but I think a tweak to the seasoning could make them better. Will create separate issue in morning when I'm a bit more awake.

from realtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.