@@ -47,13 +47,18 @@ namespace
47
47
}
48
48
49
49
50
- CrimeExecution::CrimeExecution (NotificationArea& notificationArea, const Difficulty& difficulty) :
51
- mDifficulty{difficulty},
52
- mNotificationArea {notificationArea}
50
+ CrimeExecution::CrimeExecution (const Difficulty& difficulty) :
51
+ mDifficulty{difficulty}
53
52
{
54
53
}
55
54
56
55
56
+ CrimeExecution::CrimeExecution (const Difficulty& difficulty, Signal::DelegateType onCrimeEvent) : CrimeExecution{difficulty}
57
+ {
58
+ mCrimeEventSignal .connect (onCrimeEvent);
59
+ }
60
+
61
+
57
62
void CrimeExecution::executeCrimes (const std::vector<Structure*>& structuresCommittingCrime)
58
63
{
59
64
mMoraleChanges .clear ();
@@ -88,13 +93,11 @@ void CrimeExecution::stealFood(FoodProduction& structure)
88
93
int foodStolen = calcAmountForStealing (mDifficulty , 5 , 15 , structure.foodLevel ());
89
94
structure.foodLevel (structure.foodLevel () - foodStolen);
90
95
91
- const auto & structureTile = NAS2D::Utility<StructureManager>::get ().tileFromStructure (&structure);
92
-
93
- mNotificationArea .push ({
96
+ mCrimeEventSignal .emit (
94
97
" Food Stolen" ,
95
98
NAS2D::stringFrom (foodStolen) + " units of food was pilfered from a " + structure.name () + " . " + getReasonForStealing () + " ." ,
96
- structureTile. xyz (),
97
- NotificationArea::NotificationType::Warning} );
99
+ structure
100
+ );
98
101
}
99
102
}
100
103
@@ -125,25 +128,21 @@ void CrimeExecution::stealResources(Structure& structure, const std::array<std::
125
128
int amountStolen = calcAmountForStealing (mDifficulty , 2 , 5 , structure.storage ().resources [indexToStealFrom]);
126
129
structure.storage ().resources [indexToStealFrom] -= amountStolen;
127
130
128
- const auto & structureTile = NAS2D::Utility<StructureManager>::get ().tileFromStructure (&structure);
129
-
130
- mNotificationArea .push ({
131
+ mCrimeEventSignal .emit (
131
132
" Resources Stolen" ,
132
133
NAS2D::stringFrom (amountStolen) + " units of " + resourceNames[indexToStealFrom] + " were stolen from a " + structure.name () + " . " + getReasonForStealing () + " ." ,
133
- structureTile. xyz (),
134
- NotificationArea::NotificationType::Warning} );
134
+ structure
135
+ );
135
136
}
136
137
137
138
138
139
void CrimeExecution::vandalize (Structure& structure)
139
140
{
140
141
mMoraleChanges .push_back (std::make_pair (" Vandalism" , -1 ));
141
142
142
- const auto & structureTile = NAS2D::Utility<StructureManager>::get ().tileFromStructure (&structure);
143
-
144
- mNotificationArea .push ({
143
+ mCrimeEventSignal .emit (
145
144
" Vandalism" ,
146
145
" A " + structure.name () + " was vandalized." ,
147
- structureTile. xyz (),
148
- NotificationArea::NotificationType::Warning} );
146
+ structure
147
+ );
149
148
}
0 commit comments