Comments (5)
I only know that the policies are hidden deep in the source code (was going after it when I created the GUI).
It would definitely be possible to ban more buildings if the building height can be obtained (by filtering the list).
from buildingthemes.
I inspected the source code of the game to see how we can override the policy.
public override void ResidentialBuildingAI.SimulationStep
:
// seems like this code demolishes level5 buildings in highriseban districts
if (this.m_info.m_class.m_subService == ItemClass.SubService.ResidentialHigh && (cityPlanningPolicies & DistrictPolicies.CityPlanning.HighriseBan) != DistrictPolicies.CityPlanning.None && this.m_info.m_class.m_level == ItemClass.Level.Level5)
{
SimulationManager instance2 = Singleton<SimulationManager>.instance;
if (instance2.m_randomizer.Int32(10u) == 0 && Singleton<ZoneManager>.instance.m_lastBuildIndex == instance2.m_currentBuildIndex)
{
District[] expr_179_cp_0 = instance.m_districts.m_buffer;
byte expr_179_cp_1 = district;
expr_179_cp_0[(int)expr_179_cp_1].m_cityPlanningPoliciesEffect = (expr_179_cp_0[(int)expr_179_cp_1].m_cityPlanningPoliciesEffect | DistrictPolicies.CityPlanning.HighriseBan);
buildingData.m_flags |= Building.Flags.Demolishing;
instance2.m_currentBuildIndex += 1u;
}
}
private void ResidentialBuildingAI.CheckBuildingLevel
:
// "level3" is the calculated level that the building should upgrade to
if (level3 > this.m_info.m_class.m_level)
{
num3 = 0;
num5 = 0;
// this piece of code checks if the policy is enabled
if (this.m_info.m_class.m_subService == ItemClass.SubService.ResidentialHigh && (cityPlanningPolicies & DistrictPolicies.CityPlanning.HighriseBan) != DistrictPolicies.CityPlanning.None && level3 == ItemClass.Level.Level5)
{
District[] expr_414_cp_0 = instance.m_districts.m_buffer;
byte expr_414_cp_1 = district;
expr_414_cp_0[(int)expr_414_cp_1].m_cityPlanningPoliciesEffect = (expr_414_cp_0[(int)expr_414_cp_1].m_cityPlanningPoliciesEffect | DistrictPolicies.CityPlanning.HighriseBan);
// here the level is reduced to 4 if the policy is enabled
level3 = ItemClass.Level.Level4;
num3 = 1;
}
// if the upgrade level is still higher than the current level, start upgrading
if (buildingData.m_problems == Notification.Problem.None && level3 > this.m_info.m_class.m_level && this.GetUpgradeInfo(buildingID, ref buildingData) != null)
{
frameData.m_constructState = 0;
base.StartUpgrading(buildingID, ref buildingData);
}
}
Similar code can be found in the commercial and office AIs. We could detour the sealed methods and extend the AIs to override the virtual methods to change the behavior of the policy.
from buildingthemes.
Each mesh has bounds.size property:
- bounds.size.y is proportional to assets height
- bounds.size.x is proportional to assets width
- bounds.size.z is proportional to assets length
from buildingthemes.
👍
from buildingthemes.
Nohealforu's Building Simulation Overhaul overrides No High Rises policy in the suggested way. But it completely replaces buildings AI, which renders it incompatible with our mod. We may use its height calculation algorithm though :)
We definitely need to find a way to detour virtual functions.
from buildingthemes.
Related Issues (20)
- option to disable the "footprint shrinking"
- Bug: Random Texture appears in preview box HOT 2
- Building Themes Feature included in after dark patch - What will we do now? HOT 16
- Clone feature: More color variations of vanilla and euro growables HOT 2
- filter the list of themes that is displayed in the themes tab
- Update style CRP when user modifies associated theme
- Add icons to themes in policies panel
- Fix asset preview area light
- Detect asset by package id if the asset can't be found by name
- Results of the Building Themes Polls
- NullReferenceException during themes tab initialization HOT 1
- Add option for district that will allow to auto bulldoze buildings not belonging to district's theme
- Zone blocks should get lowest available info for the building in a plot. HOT 1
- Don't allow themed buildings from imported themes grow in non-themed districts by default HOT 1
- Hide after dark buildings for players who do not own the DLC HOT 4
- NullReferenceException at PoliciesPanel.SetParentButton HOT 1
- Allow subscribing to workshop items in themes from menu
- Error in BuildingVariationManager
- Error m_class = null
- Patch 1.1.1 extra buildings aren't included in default European theme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildingthemes.