boformer / BuildingThemes

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

Clean Up everything #46

Closed boformer closed 9 years ago

boformer commented 9 years ago

So far it seems to work.

Did I make any mistakes?

SamsamTS commented 9 years ago

The file structure is a lot clearer now.

Keep in mind I know little about this project, I just jumped in recently. As far as I'm concerned I don't really need to know how the mod works to make the UI. Personally I would have chosen a different approach than detouring, but as long as it works it's fine by me.

I tried to run the clean up version and I get this error repeatedly. Is there something I'm missing?

NullReferenceException: Object reference not set to an instance of an object at BuildingThemes.BuildingThemesManager.b__3 (BuildingThemes.Theme theme) [0x00000] in :0

at System.Linq.Enumerable+c__Iterator12`2[BuildingThemes.Configuration+Theme,BuildingThemes.Configuration+Building].MoveNext () [0x00000] in :0

at BuildingThemes.BuildingThemesManager.MergeThemes (System.Collections.Generic.HashSet`1 themes) [0x00000] in :0

at BuildingThemes.BuildingThemesManager.MergeDistrictThemes (UInt32 districtIdx) [0x00000] in :0

at BuildingThemes.BuildingThemesManager.GetMergedThemes (UInt32 districtIdx) [0x00000] in :0

at BuildingThemes.BuildingThemesManager.DoesBuildingBelongToDistrict (System.String buildingName, UInt32 districtIdx) [0x00000] in :0

at BuildingThemes.Filter.DefaultFilteringStrategy.DoesBuildingBelongToDistrict (System.String name, UInt32 districtIdx) [0x00000] in :0

at BuildingThemes.Detour.BuildingManagerDetour.FilterList (Vector3 position, .FastList`1& list) [0x00000] in :0

at BuildingThemes.Detour.BuildingManagerDetour.GetRandomBuildingInfo (ColossalFramework.Math.Randomizer& r, Service service, SubService subService, Level level, Int32 width, Int32 length, ZoningMode zoningMode) [0x00000] in :0

at PrivateBuildingAI.GetUpgradeInfo (UInt16 buildingID, .Building& data) [0x00000] in :0

at CommonBuildingAI.RefreshInstance (.CameraInfo cameraInfo, UInt16 buildingID, .Building& data, Int32 layerMask, .Instance& instance) [0x00000] in :0

at Building.RenderInstance (.CameraInfo cameraInfo, UInt16 buildingID, Int32 layerMask, .BuildingInfo info, .Instance& data) [0x00000] in :0

at Building.RenderInstance (.CameraInfo cameraInfo, UInt16 buildingID, Int32 layerMask) [0x00000] in :0

at BuildingManager.EndRenderingImpl (.CameraInfo cameraInfo) [0x00000] in :0

at SimulationManagerBase`2[Manager,Properties].EndRendering (.CameraInfo cameraInfo) [0x00000] in :0

at BuildingManager.IRenderableManager.EndRendering (.CameraInfo cameraInfo) [0x00000] in :0

at RenderManager.LateUpdate () [0x00000] in :0

boformer commented 9 years ago

oh yes, I think you forgot something. You have to put the BuildingThemes.xml into the directory of the compiled mod (AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods\BuildingThemes).

The xml file contain the 2 default themes. The mod is referencing them (not there = null = exception).

Do you know a way to automate the copying of the file into the build folder?

SamsamTS commented 9 years ago

That was it.

Yes there is a way to copy the file with post build event. Here are new post build commands that copy the xml too (right click on the project > properties > build events) :

mkdir "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)" del "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)\$(TargetFileName)" xcopy /y "$(TargetPath)" "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)" xcopy /y "$(TargetDir)BuildingThemes.xml" "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(SolutionName)"

boformer commented 9 years ago

The last commit added a detour for the GetUpgradeInfo method of the BuildingAIs.

It replaces the ugly seed table lookup we used before (because we found no way to detour GetUpgradeInfo).

Tested it, seems to work fine.

I ran into trouble when I tried to detour PrivateBuildingAI.SimulationStep. That's why we still need the ImmaterialResourceManager hook.

boformer commented 9 years ago

Merging this...