boformer / BuildingThemes

Mod for Cities:Skylines
http://steamcommunity.com/sharedfiles/filedetails/?id=466158459
MIT License
13 stars 11 forks source link

Realistic buildung upgrades #36

Closed boformer closed 9 years ago

boformer commented 9 years ago

From simtropolis:

Would it be possible to make mod that can allow buildings to level up without replacing the lot?

Old buildings like row homes may have been originally been built as cheap housing, but were renovated as the land values increased and the city grew.

It makes it hard to try to find a place for historical building models in the game.

My answer:

What would be possible is the following:

Asset creators create multiple versions of their assets (lvl 1 ugly with trash, lvl 2 renovated, lvl 3 with small pool).

The mod hooks into the building selection that occurs on upgrading and looks for an asset with a similar name ("myhome L1" -> "myhome L2").

I could easily integrate this into the Building Themes mod. It would just require the help of the asset authors to create the different asset versions and to name them correctly.

boformer commented 9 years ago

Another memory-friendly solution: Duplicate the assets ingame, use same mesh and texture.

There could be a slider in the themes manager to select the levels where an asset can grow ( e.g. 2 - 4). What do you think?

bloodypenguin commented 9 years ago

slider in the themes manager to select the levels

I once thought about that. This would be really nice. If I like a building but it's a L1 asset (like most fast food assets), I want to let it level up without changing mesh. Some buildings must level up with mesh changing though (like cheap condos)

Duplicate the assets

I don't like that idea much. First, it should be done on level loading to prevent unwanted side effects. Second, it will be to hard for users to configure and for us to control.

Another idea that comes to mind: Let buildings grow straight from level > L1 (e.g. to spawn a L5 building without previous levelups if land value is high enough. This is what happens IRL. If user thinks that some building is L5 but building's author set it another level, user should be able to override assets level.

boformer commented 9 years ago

I don't like that idea much. First, it should be done on level loading to prevent unwanted side effects.

This mod seems to do it as well in a way: https://github.com/AJ3D/PloppableRCI/blob/master/PloppableRCI/OnLoad.cs

AJ3D commented 9 years ago

Hey guys!

You can do the leveling range by using the custom attributes fields on the building AI. I haven't fully cleaned this up on my mod, but I was able to get it to work in a test.

The BuildingInfo object also stores the information related to the props, and can be changed.

I had an idea for this feature, and was thinking it could work by creating a new AI that was extended from the basic ones. The new AI would have the custom fields, and would bypass the normal leveling logic. On scene load, the game would find the assets with the new AI, and create the additional BuildingInfos for assignment upon leveling.

I did talk with BloodyPengiun, and I think he mentioned that creating a new AI class should be ok....

bloodypenguin commented 9 years ago

@AJ3D It should be OK only for new assets (designed specially for your mod). Replacing existing assets AI is not a good idea IMO.

AJ3D commented 9 years ago

Having the XML files that store custom information could completely eliminate the need for new AI's. I don't fully understand how reflection works yet, but I think you can add logic to existing objects and methods.
A simple if statement in the simulation step could allow you to implement the different logic selectively for the buildings that are not meant to have their meshes changed on level up. From what I've read in the source code, when the Building object levelUpProgress his 255, it sets off a long chain of methods that destroys the Building object, and creates a new one. If you wanted to preserve the current residents and workers, you would need to catch it earlier, and impement your own simple leveling logic. Mine so far just simply assigns a new BuildingInfo object that was instantiated from the original. The original references are the same, except for the new ItemClass that has a higher level assigned.

boformer commented 9 years ago

Actually it doesn't matter if the building gets destroyed and rebuilt.

We have hooked into the method that selects the new BuildingInfo on building upgrade.

We just need a way to copy the BuildingInfo and to change the assigned level.

For compatibility, it makes sense to revert the BuildingInfos to the original ones when the level is saved.

No messing with the AI.

boformer commented 9 years ago

Working on this as a separate mod.