@@ -59,24 +59,28 @@ const DEFAULT_PORT: u16 = 5123;
59
59
#[ derive( Debug , Decode , Encode , Clone , Serialize , Deserialize , PartialEq , Eq , Copy ) ]
60
60
pub ( crate ) enum GameMode {
61
61
SharedHealth ,
62
- LocalHealth ,
62
+ LocalHealth ( LocalHealthMode ) ,
63
63
// MestariMina, // TODO later
64
64
}
65
65
66
+ #[ derive( Debug , Decode , Encode , Clone , Serialize , Deserialize , PartialEq , Eq , Copy ) ]
67
+ pub ( crate ) enum LocalHealthMode {
68
+ Normal ,
69
+ Alternate ,
70
+ PermaDeath ,
71
+ }
72
+
66
73
#[ derive( Debug , Decode , Encode , Clone , Serialize , Deserialize , PartialEq , Default ) ]
67
74
#[ serde( default ) ]
68
75
pub struct GameSettings {
69
76
seed : u64 ,
70
77
world_num : u16 ,
71
78
debug_mode : Option < bool > ,
72
- world_sync_version : Option < u32 > ,
73
79
use_constant_seed : bool ,
74
80
item_dedup : Option < bool > ,
75
81
enemy_hp_mult : Option < f32 > ,
76
- world_sync_interval : Option < u32 > ,
77
82
game_mode : Option < GameMode > ,
78
83
friendly_fire : Option < bool > ,
79
- enemy_sync_interval : Option < u32 > ,
80
84
randomize_perks : Option < bool > ,
81
85
progress : Vec < String > ,
82
86
max_players : Option < u32 > ,
@@ -85,10 +89,8 @@ pub struct GameSettings {
85
89
no_material_damage : Option < bool > ,
86
90
global_hp_loss : Option < bool > ,
87
91
perk_ban_list : Option < String > ,
88
- perma_death : Option < bool > ,
89
92
physics_damage : Option < bool > ,
90
93
share_gold : Option < bool > ,
91
- no_notplayer : Option < bool > ,
92
94
}
93
95
impl GameSettings {
94
96
fn show_editor ( & mut self , ui : & mut Ui , enabled : bool ) {
@@ -102,7 +104,25 @@ impl GameSettings {
102
104
. radio_value ( & mut temp, GameMode :: SharedHealth , tr ( "Shared-health" ) )
103
105
. changed ( )
104
106
|| ui
105
- . radio_value ( & mut temp, GameMode :: LocalHealth , tr ( "Local-health" ) )
107
+ . radio_value (
108
+ & mut temp,
109
+ GameMode :: LocalHealth ( LocalHealthMode :: Normal ) ,
110
+ tr ( "Local-health" ) ,
111
+ )
112
+ . changed ( )
113
+ || ui
114
+ . radio_value (
115
+ & mut temp,
116
+ GameMode :: LocalHealth ( LocalHealthMode :: Alternate ) ,
117
+ tr ( "Local-health-alt" ) ,
118
+ )
119
+ . changed ( )
120
+ || ui
121
+ . radio_value (
122
+ & mut temp,
123
+ GameMode :: LocalHealth ( LocalHealthMode :: PermaDeath ) ,
124
+ tr ( "Local-health-perma" ) ,
125
+ )
106
126
. changed ( )
107
127
{
108
128
game_settings. game_mode = Some ( temp)
@@ -124,55 +144,64 @@ impl GameSettings {
124
144
game_settings. health_per_player = Some ( temp)
125
145
}
126
146
}
127
- GameMode :: LocalHealth => {
147
+ GameMode :: LocalHealth ( mode ) => {
128
148
ui. label ( tr ( "local_health_desc_1" ) ) ;
129
- ui. label ( tr ( "local_health_desc_2" ) ) ;
130
- ui. add_space ( 5.0 ) ;
131
- ui. label ( tr ( "Health-percent-lost-on-reviving" ) ) ;
132
- {
133
- let mut temp = game_settings
134
- . health_lost_on_revive
135
- . unwrap_or ( def. health_lost_on_revive ) ;
136
- if ui. add ( Slider :: new ( & mut temp, 0 ..=100 ) ) . changed ( ) {
137
- game_settings. health_lost_on_revive = Some ( temp)
138
- }
139
- }
140
- {
141
- let mut temp =
142
- game_settings. global_hp_loss . unwrap_or ( def. global_hp_loss ) ;
143
- if ui. checkbox ( & mut temp, tr ( "global_hp_loss" ) ) . changed ( ) {
144
- game_settings. global_hp_loss = Some ( temp)
145
- }
146
- }
147
- {
148
- let mut temp = game_settings
149
- . no_material_damage
150
- . unwrap_or ( def. no_material_damage ) ;
151
- if ui. checkbox ( & mut temp, tr ( "no_material_damage" ) ) . changed ( ) {
152
- game_settings. no_material_damage = Some ( temp)
153
- }
154
- }
155
- ui. add_space ( 1.0 ) ;
156
- {
157
- let mut temp = game_settings. perma_death . unwrap_or ( def. perma_death ) ;
158
- if ui. checkbox ( & mut temp, tr ( "perma_death" ) ) . changed ( ) {
159
- game_settings. perma_death = Some ( temp)
160
- }
161
- }
162
- ui. add_space ( 1.0 ) ;
163
- {
164
- let mut temp =
165
- game_settings. physics_damage . unwrap_or ( def. physics_damage ) ;
166
- if ui. checkbox ( & mut temp, tr ( "physics_damage" ) ) . changed ( ) {
167
- game_settings. physics_damage = Some ( temp)
149
+ match mode {
150
+ LocalHealthMode :: Normal => {
151
+ ui. add_space ( 5.0 ) ;
152
+ ui. label ( tr ( "Health-percent-lost-on-reviving" ) ) ;
153
+ {
154
+ let mut temp = game_settings
155
+ . health_lost_on_revive
156
+ . unwrap_or ( def. health_lost_on_revive ) ;
157
+ if ui. add ( Slider :: new ( & mut temp, 0 ..=100 ) ) . changed ( ) {
158
+ game_settings. health_lost_on_revive = Some ( temp)
159
+ }
160
+ }
161
+ {
162
+ let mut temp =
163
+ game_settings. global_hp_loss . unwrap_or ( def. global_hp_loss ) ;
164
+ if ui. checkbox ( & mut temp, tr ( "global_hp_loss" ) ) . changed ( ) {
165
+ game_settings. global_hp_loss = Some ( temp)
166
+ }
167
+ }
168
+ {
169
+ let mut temp = game_settings
170
+ . no_material_damage
171
+ . unwrap_or ( def. no_material_damage ) ;
172
+ if ui. checkbox ( & mut temp, tr ( "no_material_damage" ) ) . changed ( ) {
173
+ game_settings. no_material_damage = Some ( temp)
174
+ }
175
+ }
176
+ ui. add_space ( 1.0 ) ;
177
+ {
178
+ let mut temp =
179
+ game_settings. physics_damage . unwrap_or ( def. physics_damage ) ;
180
+ if ui. checkbox ( & mut temp, tr ( "physics_damage" ) ) . changed ( ) {
181
+ game_settings. physics_damage = Some ( temp)
182
+ }
183
+ }
168
184
}
169
- }
170
- ui. add_space ( 1.0 ) ;
171
- {
172
- let mut temp = game_settings. no_notplayer . unwrap_or ( def. no_notplayer ) ;
173
- if ui. checkbox ( & mut temp, "no minua" ) . changed ( ) {
174
- game_settings. no_notplayer = Some ( temp)
185
+ LocalHealthMode :: Alternate => {
186
+ ui. add_space ( 5.0 ) ;
187
+ ui. label ( tr ( "Health-percent-lost-on-reviving" ) ) ;
188
+ {
189
+ let mut temp = game_settings
190
+ . health_lost_on_revive
191
+ . unwrap_or ( def. health_lost_on_revive ) ;
192
+ if ui. add ( Slider :: new ( & mut temp, 0 ..=100 ) ) . changed ( ) {
193
+ game_settings. health_lost_on_revive = Some ( temp)
194
+ }
195
+ }
196
+ {
197
+ let mut temp =
198
+ game_settings. global_hp_loss . unwrap_or ( def. global_hp_loss ) ;
199
+ if ui. checkbox ( & mut temp, tr ( "global_hp_loss" ) ) . changed ( ) {
200
+ game_settings. global_hp_loss = Some ( temp)
201
+ }
202
+ }
175
203
}
204
+ LocalHealthMode :: PermaDeath => { }
176
205
}
177
206
}
178
207
}
@@ -284,38 +313,30 @@ impl GameSettings {
284
313
}
285
314
pub struct DefaultSettings {
286
315
debug_mode : bool ,
287
- world_sync_version : u32 ,
288
316
item_dedup : bool ,
289
317
enemy_hp_mult : f32 ,
290
- world_sync_interval : u32 ,
291
318
game_mode : GameMode ,
292
319
friendly_fire : bool ,
293
- enemy_sync_interval : u32 ,
294
320
randomize_perks : bool ,
295
321
max_players : u32 ,
296
322
health_per_player : u32 ,
297
323
health_lost_on_revive : u32 ,
298
324
no_material_damage : bool ,
299
325
global_hp_loss : bool ,
300
326
perk_ban_list : String ,
301
- perma_death : bool ,
302
327
physics_damage : bool ,
303
328
share_gold : bool ,
304
- no_notplayer : bool ,
305
329
}
306
330
307
331
impl Default for DefaultSettings {
308
332
fn default ( ) -> Self {
309
333
DefaultSettings {
310
334
debug_mode : false ,
311
- world_sync_version : 2 ,
312
335
item_dedup : true ,
313
336
randomize_perks : true ,
314
337
enemy_hp_mult : 1.0 ,
315
- world_sync_interval : 3 ,
316
- game_mode : GameMode :: LocalHealth ,
338
+ game_mode : GameMode :: LocalHealth ( LocalHealthMode :: Normal ) ,
317
339
friendly_fire : false ,
318
- enemy_sync_interval : 3 ,
319
340
max_players : 250 ,
320
341
health_per_player : 100 ,
321
342
health_lost_on_revive : 0 ,
@@ -324,10 +345,8 @@ impl Default for DefaultSettings {
324
345
perk_ban_list :
325
346
"GLOBAL_GORE,GLASS_CANNON,REVENGE_RATS,PLAGUE_RATS,VOMIT_RATS,CORDYCEPS,MOLD"
326
347
. to_string ( ) ,
327
- perma_death : false ,
328
348
physics_damage : true ,
329
349
share_gold : false ,
330
- no_notplayer : false ,
331
350
}
332
351
}
333
352
}
0 commit comments