Skip to content

Commit 52d22fd

Browse files
authored
Add default AI repairable building logic
1 parent ba94da2 commit 52d22fd

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Text=Power; dynamically generated
287287
[lblStatsObjectsCount]
288288
$X=getX(lblStatsHeader)
289289
$Y=getBottom(lblStatsPower) + VERTICAL_SPACING
290-
Text=Aircraft:@Infantry:@Vehicles:Buildings@AI repairable:@not AI repairable; dynamically generated
290+
Text=Aircraft:@Infantry:@Vehicles:Buildings@AI Repairable by default:@AI repairable:@not AI repairable; dynamically generated
291291
292292
[lblStatsAllianceMutualAlliance]
293293
$X=getX(lblStatsHeader)

src/TSMapEditor/Config/Translations/en/Translation_en.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,9 @@ HousesWindow.HouseExists.Description=Cannot generate standard because the map al
738738
HousesWindow.NoHouseSelected.Title=No House Selected
739739
HousesWindow.NoHouseSelected.Description=Select a house first.
740740
HousesWindow.EnableAIRepairs.Title=Are you sure?
741-
HousesWindow.EnableAIRepairs.Description=This enables the "AI Repairs" flag on all buildings of the house, which makes the AI repair them.@@No un-do is available. Do you wish to continue?
741+
HousesWindow.EnableAIRepairs.Description.v2=This enables the "AI Repairable" flag on all buildings of the house, which makes the AI repair them.@@Additionally, this will cause the "AI Repairable" flag to be automatically enabled for all buildings you place for this house.@@No un-do is available. Do you wish to continue?
742742
HousesWindow.DisableAIRepairs.Title=Are you sure?
743-
HousesWindow.DisableAIRepairs.Description=This disables the "AI Repairs" flag on all buildings of the house, which makes the AI NOT repair them.@@No un-do is available. Do you wish to continue?
743+
HousesWindow.DisableAIRepairs.Description.v2=This disables the "AI Repairable" flag on all buildings of the house, which makes the AI NOT repair them.@@Additionally, this will cause the "AI Repairable" flag to be automatically disabled for all buildings you place for this house.@@No un-do is available. Do you wish to continue?
744744

745745
InfantryOptionsWindow.lblHeader.Text=Infantry Options
746746
InfantryOptionsWindow.lblSelectedInfantry.Text=Selected Infantry:

src/TSMapEditor/Models/House.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public House(string iniName, HouseType houseType) : this(iniName)
9494
public int TechLevel { get; set; }
9595
public int PercentBuilt { get; set; }
9696
public bool PlayerControl { get; set; }
97+
public bool DefaultRepairableStructures { get; set; } = false;
9798

9899
[INI(false)]
99100
public int ID { get; set; }

src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public override void Perform()
3535
var structure = new Structure(buildingType);
3636
structure.Owner = MutationTarget.ObjectOwner;
3737
structure.Position = cellCoords;
38+
structure.AIRepairable = structure.Owner.DefaultRepairableStructures;
3839
MutationTarget.Map.PlaceBuilding(structure);
3940
MutationTarget.AddRefreshPoint(cellCoords);
4041

src/TSMapEditor/UI/Windows/HousesWindow.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,14 @@ private void BtnMakeHouseRepairBuildings_LeftClick(object sender, EventArgs e)
309309

310310
var dialog = EditorMessageBox.Show(WindowManager,
311311
Translate(this, "EnableAIRepairs.Title", "Are you sure?"),
312-
Translate(this, "EnableAIRepairs.Description", "This enables the \"AI Repairs\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine + Environment.NewLine +
312+
Translate(this, "EnableAIRepairs.Description.v2", "This enables the \"AI Repairable\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine +
313+
"Additionally, this will cause the \"AI Repairable\" flag to be automatically enabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine +
313314
"No un-do is available. Do you wish to continue?"),
314315
MessageBoxButtons.YesNo);
315316
dialog.YesClickedAction = _ =>
316317
{
317318
map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = true);
319+
editedHouse.DefaultRepairableStructures = true;
318320
RefreshHouseInfo();
319321
};
320322
}
@@ -332,12 +334,14 @@ private void BtnMakeHouseNotRepairBuildings_LeftClick(object sender, EventArgs e
332334

333335
var dialog = EditorMessageBox.Show(WindowManager,
334336
Translate(this, "DisableAIRepairs.Title", "Are you sure?"),
335-
Translate(this, "DisableAIRepairs.Description", "This disables the \"AI Repairs\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine + Environment.NewLine +
337+
Translate(this, "DisableAIRepairs.Description.v2", "This disables the \"AI Repairable\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine +
338+
"Additionally, this will cause the \"AI Repairable\" flag to be automatically disabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine +
336339
"No un-do is available. Do you wish to continue?"),
337340
MessageBoxButtons.YesNo);
338341
dialog.YesClickedAction = _ =>
339342
{
340343
map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = false);
344+
editedHouse.DefaultRepairableStructures = false;
341345
RefreshHouseInfo();
342346
};
343347
}
@@ -588,8 +592,12 @@ private void RefreshHouseStats()
588592
objectCountStats += Translate(this, "HouseStats.Infantry", "Infantry: ") + map.Infantry.Count(s => s.Owner == editedHouse) + Environment.NewLine;
589593
objectCountStats += Translate(this, "HouseStats.Vehicles", "Vehicles: ") + map.Units.Count(s => s.Owner == editedHouse) + Environment.NewLine;
590594
objectCountStats += Translate(this, "HouseStats.Buildings", "Buildings: ") + map.Structures.Count(s => s.Owner == editedHouse) + Environment.NewLine;
591-
objectCountStats += Translate(this, "HouseStats.AIRepairable", " AI repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && s.AIRepairable) + Environment.NewLine;
592-
objectCountStats += Translate(this, "HouseStats.NotAIRepairable", " not AI repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && !s.AIRepairable);
595+
objectCountStats += Translate(this, "HouseStats.DefaultRepairable", " AI Repairable by default: ") +
596+
(editedHouse.DefaultRepairableStructures ?
597+
Translate(this, "HouseStats.DefaultRepairableYes", "Yes") :
598+
Translate(this, "HouseStats.DefaultRepairableNo", "No")) + Environment.NewLine;
599+
objectCountStats += Translate(this, "HouseStats.AIRepairable", " AI Repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && s.AIRepairable) + Environment.NewLine;
600+
objectCountStats += Translate(this, "HouseStats.NotAIRepairable", " not AI Repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && !s.AIRepairable) + Environment.NewLine;
593601

594602
lblStatsObjectsCount.Text = objectCountStats;
595603

0 commit comments

Comments
 (0)