Search in sources :

Example 1 with WorkAtHomeBuildingModule

use of com.minecolonies.coremod.colony.buildings.modules.WorkAtHomeBuildingModule in project minecolonies by Minecolonies.

the class CitizenManager method calculateMaxCitizens.

@Override
public void calculateMaxCitizens() {
    int newMaxCitizens = 0;
    int potentialMax = 0;
    for (final IBuilding b : colony.getBuildingManager().getBuildings().values()) {
        if (b.getBuildingLevel() > 0) {
            if (b.hasModule(BedHandlingModule.class) && b.hasModule(WorkAtHomeBuildingModule.class)) {
                final WorkAtHomeBuildingModule module = b.getFirstModuleOccurance(WorkAtHomeBuildingModule.class);
                newMaxCitizens += b.getAllAssignedCitizen().size();
                potentialMax += module.getModuleMax() - b.getAllAssignedCitizen().size();
            } else if (b.hasModule(LivingBuildingModule.class)) {
                newMaxCitizens += b.getFirstModuleOccurance(LivingBuildingModule.class).getModuleMax();
            }
        }
    }
    if (getMaxCitizens() != newMaxCitizens) {
        setMaxCitizens(newMaxCitizens);
        setPotentialMaxCitizens(potentialMax + newMaxCitizens);
        colony.markDirty();
    }
}
Also used : LivingBuildingModule(com.minecolonies.coremod.colony.buildings.modules.LivingBuildingModule) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkAtHomeBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkAtHomeBuildingModule) BedHandlingModule(com.minecolonies.coremod.colony.buildings.modules.BedHandlingModule)

Example 2 with WorkAtHomeBuildingModule

use of com.minecolonies.coremod.colony.buildings.modules.WorkAtHomeBuildingModule in project minecolonies by ldtteam.

the class CitizenManager method calculateMaxCitizens.

@Override
public void calculateMaxCitizens() {
    int newMaxCitizens = 0;
    int potentialMax = 0;
    for (final IBuilding b : colony.getBuildingManager().getBuildings().values()) {
        if (b.getBuildingLevel() > 0) {
            if (b.hasModule(BedHandlingModule.class) && b.hasModule(WorkAtHomeBuildingModule.class)) {
                final WorkAtHomeBuildingModule module = b.getFirstModuleOccurance(WorkAtHomeBuildingModule.class);
                newMaxCitizens += b.getAllAssignedCitizen().size();
                potentialMax += module.getModuleMax() - b.getAllAssignedCitizen().size();
            } else if (b.hasModule(LivingBuildingModule.class)) {
                newMaxCitizens += b.getFirstModuleOccurance(LivingBuildingModule.class).getModuleMax();
            }
        }
    }
    if (getMaxCitizens() != newMaxCitizens) {
        setMaxCitizens(newMaxCitizens);
        setPotentialMaxCitizens(potentialMax + newMaxCitizens);
        colony.markDirty();
    }
}
Also used : LivingBuildingModule(com.minecolonies.coremod.colony.buildings.modules.LivingBuildingModule) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkAtHomeBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkAtHomeBuildingModule) BedHandlingModule(com.minecolonies.coremod.colony.buildings.modules.BedHandlingModule)

Aggregations

IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 BedHandlingModule (com.minecolonies.coremod.colony.buildings.modules.BedHandlingModule)2 LivingBuildingModule (com.minecolonies.coremod.colony.buildings.modules.LivingBuildingModule)2 WorkAtHomeBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkAtHomeBuildingModule)2