Skip to content

Commit f2129d8

Browse files
committed
fix Clone cast bug
1 parent 01d9b31 commit f2129d8

File tree

7 files changed

+90
-39
lines changed

7 files changed

+90
-39
lines changed

assets/image/atlas.aseprite

290 Bytes
Binary file not shown.

assets/registry.actor.ron

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ ActorRegistry(
1818
bloods: ["blood_0", "blood_1", "blood_2"],
1919
defreeze: 1,
2020
auto_levitation: false,
21+
poise: 4,
22+
floundering: 1,
23+
fire_resistance: false,
2124
cry: true,
2225
life: 60,
2326
actor_group: Friend,
@@ -52,6 +55,9 @@ ActorRegistry(
5255
bloods: ["blood_0", "blood_1", "blood_2"],
5356
defreeze: 1,
5457
auto_levitation: false,
58+
poise: 1,
59+
floundering: 1,
60+
fire_resistance: false,
5561
cry: true,
5662
life: 100,
5763
actor_group: Friend,
@@ -86,6 +92,9 @@ ActorRegistry(
8692
bloods: ["blood_0", "blood_1", "blood_2"],
8793
defreeze: 1,
8894
auto_levitation: false,
95+
poise: 1,
96+
floundering: 1,
97+
fire_resistance: false,
8998
cry: true,
9099
life: 2,
91100
actor_group: Neutral,
@@ -120,6 +129,9 @@ ActorRegistry(
120129
bloods: [],
121130
defreeze: 1,
122131
auto_levitation: false,
132+
poise: 1,
133+
floundering: 1,
134+
fire_resistance: false,
123135
cry: true,
124136
life: 10000,
125137
actor_group: Neutral,
@@ -161,6 +173,9 @@ ActorRegistry(
161173
bloods: ["slime_blood_0", "slime_blood_1", "slime_blood_2"],
162174
defreeze: 1,
163175
auto_levitation: false,
176+
poise: 1,
177+
floundering: 1,
178+
fire_resistance: false,
164179
cry: true,
165180
life: 15,
166181
actor_group: Enemy,
@@ -204,6 +219,9 @@ ActorRegistry(
204219
bloods: ["blood_0", "blood_1", "blood_2"],
205220
defreeze: 1,
206221
auto_levitation: true,
222+
poise: 1,
223+
floundering: 1,
224+
fire_resistance: false,
207225
cry: true,
208226
life: 25,
209227
actor_group: Enemy,
@@ -247,6 +265,9 @@ ActorRegistry(
247265
bloods: [],
248266
defreeze: 1,
249267
auto_levitation: false,
268+
poise: 10,
269+
floundering: 1,
270+
fire_resistance: false,
250271
cry: true,
251272
life: 40,
252273
actor_group: Enemy,
@@ -290,6 +311,9 @@ ActorRegistry(
290311
bloods: ["blood_0", "blood_1", "blood_2"],
291312
defreeze: 2,
292313
auto_levitation: false,
314+
poise: 1,
315+
floundering: 1,
316+
fire_resistance: true,
293317
cry: true,
294318
life: 100,
295319
actor_group: Enemy,
@@ -333,6 +357,9 @@ ActorRegistry(
333357
bloods: [],
334358
defreeze: 1,
335359
auto_levitation: false,
360+
poise: 1,
361+
floundering: 1,
362+
fire_resistance: false,
336363
cry: true,
337364
life: 40,
338365
actor_group: Enemy,
@@ -360,15 +387,18 @@ ActorRegistry(
360387
strategies: {}
361388
),
362389
"HugeSlime": (
363-
collider: Ball(5.0),
390+
collider: Ball(30.0),
364391
// huge slime のみ move_force を jump_actor の impulse に設定していることに注意
365-
move_force: 400000.0,
392+
move_force: 500000.0,
366393
jump: 3.0,
367394
linear_damping: 10.0,
368395
bloods: [],
369396
// スライムの王は凍結無効
370397
defreeze: 10000,
371398
auto_levitation: false,
399+
poise: 10,
400+
floundering: 10,
401+
fire_resistance: false,
372402
cry: false,
373403
life: 4000,
374404
actor_group: Enemy,
@@ -386,7 +416,7 @@ ActorRegistry(
386416
drown: "idle",
387417
staggered: "idle",
388418
),
389-
shadow: None,
419+
shadow: "huge_shadow",
390420
wands: [
391421
[None, None, None, None, None, None, None, None],
392422
[None, None, None, None, None, None, None, None],
@@ -403,6 +433,9 @@ ActorRegistry(
403433
bloods: [],
404434
defreeze: 1,
405435
auto_levitation: false,
436+
poise: 1,
437+
floundering: 1,
438+
fire_resistance: false,
406439
cry: false,
407440
life: 100,
408441
actor_group: Entity,
@@ -437,6 +470,9 @@ ActorRegistry(
437470
bloods: [],
438471
defreeze: 1,
439472
auto_levitation: false,
473+
poise: 1,
474+
floundering: 1,
475+
fire_resistance: false,
440476
cry: false,
441477
life: 10,
442478
actor_group: Entity,
@@ -471,6 +507,9 @@ ActorRegistry(
471507
bloods: [],
472508
defreeze: 1,
473509
auto_levitation: false,
510+
poise: 1,
511+
floundering: 1,
512+
fire_resistance: false,
474513
cry: false,
475514
life: 25,
476515
actor_group: Entity,
@@ -505,6 +544,9 @@ ActorRegistry(
505544
bloods: [],
506545
defreeze: 10000,
507546
auto_levitation: false,
547+
poise: 1,
548+
floundering: 1,
549+
fire_resistance: false,
508550
cry: false,
509551
life: 100,
510552
actor_group: Entity,
@@ -539,6 +581,9 @@ ActorRegistry(
539581
bloods: [],
540582
defreeze: 10000,
541583
auto_levitation: false,
584+
poise: 1,
585+
floundering: 1,
586+
fire_resistance: false,
542587
cry: false,
543588
life: 100,
544589
actor_group: Entity,

assets/registry.game.ron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GameRegistry(
55
debug_wands: [
66
["QuickCast", "QuickCast", "TripleCast", "Slash", "Slash", "MagicBolt", None, None],
77
["DualCast", "Levitation", "MagicBolt", None, None, None, None, None],
8-
["InfinityClone", None, None, None, None, None, None, None],
8+
["Clone", None, None, None, None, None, None, None],
99
["DualCast", "Dash", "Jump", "Lantern", None, None, None, None]
1010
],
1111

assets/registry.spell.ron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SpellRegistry(
3636
cast: Bullet (
3737
slices: Slice (names: ["bullet_magic_bolt"]),
3838
collier_radius: 5.0,
39-
speed: 100.0,
39+
speed: 150.0,
4040
lifetime: 240,
4141
damage: 10,
4242
impulse: 0.0,

src/actor.rs

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,8 @@ pub struct Actor {
227227
pub state: ActorState,
228228

229229
// 定数 ////////////////////////////////////////////////////////////////////////////////////////////////
230-
/// 1フレームあたりの stagger の回復速度です
231-
pub poise: u32,
232-
233-
pub invincibility_on_staggered: bool,
234-
235230
pub point_light_radius: f32,
236231

237-
/// 蜘蛛の巣から逃れる速度
238-
/// 毎ターンこの値が trapped から減算され、trappedが0になるとアクターが解放されます
239-
/// また、解放された瞬間に trap_moratorium が 180 に設定され、
240-
/// 3秒間は再びトラップにかからないようになります
241-
pub floundering: u32,
242-
243-
pub fire_resistance: bool,
244-
245232
// 効果と状態異常 ////////////////////////////////////////////////////////////////////////////////////////////
246233
/// 再び詠唱操作をできるようになるまでの待ち時間
247234
/// フキダシを閉じたあとや変身直後など、一定時間詠唱不能にしておかないと、
@@ -459,7 +446,6 @@ impl Default for Actor {
459446
],
460447
commander: Commander::default(),
461448
inventory: Inventory::new(),
462-
fire_resistance: false,
463449
move_direction: Vec2::ZERO,
464450
fire_state: ActorFireState::Idle,
465451
fire_state_secondary: ActorFireState::Idle,
@@ -469,13 +455,10 @@ impl Default for Actor {
469455
home_position: Vec2::ZERO,
470456
trapped: 0,
471457
trap_moratorium: 0,
472-
floundering: 1,
473458
frozen: 0,
474459
levitation: 0,
475460
drown: 0,
476461
staggered: 0,
477-
poise: 1,
478-
invincibility_on_staggered: false,
479462
cloned: None,
480463
getting_up: 0,
481464
hidden: false,
@@ -702,11 +685,7 @@ fn fire_bullet(
702685
}
703686

704687
if actor.fire_state == ActorFireState::Fire {
705-
let wand = if actor_metamorphosis.is_none() {
706-
actor.current_wand
707-
} else {
708-
0
709-
};
688+
let wand = actor.current_wand;
710689
cast_spell(
711690
&mut commands,
712691
&asset_server,
@@ -777,6 +756,7 @@ fn apply_external_force(
777756
if let Some(ref chunk) = level.chunk {
778757
for (mut actor, mut external_force, transform, vertical) in query.iter_mut() {
779758
let position = transform.translation.truncate();
759+
let props = registry.get_actor_props(&actor.actor_type);
780760

781761
let on_ice = match chunk.get_tile_by_coords(position) {
782762
Tile::Ice => true,
@@ -808,7 +788,7 @@ fn apply_external_force(
808788
if 0.0 < force.length() {
809789
if 0 < actor.trapped {
810790
external_force.force = Vec2::ZERO;
811-
actor.trapped -= actor.floundering;
791+
actor.trapped -= props.floundering;
812792
if actor.trapped == 0 {
813793
actor.trap_moratorium = 180;
814794
se.send(SEEvent::pos(ZOMBIE, position));
@@ -1054,10 +1034,11 @@ fn drown_damage(
10541034
}
10551035
}
10561036

1057-
fn stagger(mut actor_query: Query<&mut Actor>) {
1037+
fn stagger(registry: Registry, mut actor_query: Query<&mut Actor>) {
10581038
for mut actor in actor_query.iter_mut() {
1059-
if actor.poise < actor.staggered {
1060-
actor.staggered -= actor.poise;
1039+
let props = registry.get_actor_props(&actor.actor_type);
1040+
if props.poise < actor.staggered {
1041+
actor.staggered -= props.poise;
10611042
} else {
10621043
actor.staggered = 0;
10631044
}
@@ -1124,13 +1105,15 @@ fn vibrate_breakabke_sprite(
11241105
/// ただし、Burnableである場合はダメージを受けませんが、その代わりに引火することがあり、
11251106
/// 引火したあとで Burnable の life がゼロになった場合はエンティティは消滅します
11261107
fn fire_damage(
1108+
registry: Registry,
11271109
mut actor_query: Query<(Entity, &mut Actor, &Transform), Without<Burnable>>,
11281110
fire_query: Query<&mut Transform, (With<Fire>, Without<Actor>)>,
11291111
rapier_context: Query<&RapierContext, With<DefaultRapierContext>>,
11301112
mut actor_event: EventWriter<ActorEvent>,
11311113
) {
11321114
for (actor_entity, mut actor, actor_transform) in actor_query.iter_mut() {
1133-
if actor.fire_damage_wait <= 0 && !actor.fire_resistance {
1115+
let props = registry.get_actor_props(&actor.actor_type);
1116+
if actor.fire_damage_wait <= 0 && !props.fire_resistance {
11341117
let mut detected_fires = Vec::<Entity>::new();
11351118
let context = rapier_context.single();
11361119

@@ -1213,7 +1196,7 @@ fn damage(
12131196
continue;
12141197
};
12151198

1216-
if actor.staggered == 0 || !actor.invincibility_on_staggered {
1199+
if actor.staggered == 0 {
12171200
actor.life = (actor.life as i32 - *damage as i32).max(0) as u32;
12181201
actor.staggered = (actor.staggered + stagger).min(120);
12191202
}
@@ -1350,13 +1333,28 @@ fn despawn(
13501333

13511334
fn add_life_bar(
13521335
mut commands: Commands,
1353-
query: Query<Entity, Added<Actor>>,
1336+
query: Query<
1337+
(
1338+
Entity,
1339+
&Actor,
1340+
Option<&Player>,
1341+
Option<&Metamorphosed>,
1342+
Option<&Boss>,
1343+
),
1344+
Added<Actor>,
1345+
>,
13541346
life_bar_resource: Res<LifeBarResource>,
13551347
) {
1356-
for entity in query.iter() {
1357-
commands.entity(entity).with_children(|spawn_children| {
1358-
spawn_life_bar(spawn_children, &life_bar_resource);
1359-
});
1348+
for (entity, actor, player, morphed, boss) in query.iter() {
1349+
if player.is_none()
1350+
&& morphed.is_none()
1351+
&& boss.is_none()
1352+
&& actor.actor_group != ActorGroup::Entity
1353+
{
1354+
commands.entity(entity).with_children(|spawn_children| {
1355+
spawn_life_bar(spawn_children, &life_bar_resource);
1356+
});
1357+
}
13601358
}
13611359
}
13621360

src/controller/player.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub fn release_holded_bullets(
233233
}
234234

235235
fn switch_wand(
236-
mut witch_query: Query<&mut Actor, (With<PlayerControlled>, With<Witch>)>,
236+
mut witch_query: Query<&mut Actor, With<PlayerControlled>>,
237237
mut wheel: EventReader<MouseWheel>,
238238
mut writer: EventWriter<SEEvent>,
239239
state: Res<State<GameMenuState>>,

src/registry.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ pub struct ActorPropsByType {
7575
/// 凍結から復帰する速度です
7676
/// 通常は 1 ですが、ボスなどの特定のモンスターはより大きい値になることがあります
7777
pub defreeze: u32,
78+
/// Staggered からの回復速度
79+
pub poise: u32,
80+
/// 蜘蛛の巣から逃れる速度
81+
/// 毎ターンこの値が trapped から減算され、trappedが0になるとアクターが解放されます
82+
/// また、解放された瞬間に trap_moratorium が 180 に設定され、
83+
/// 3秒間は再びトラップにかからないようになります
84+
pub floundering: u32,
85+
pub fire_resistance: bool,
7886
/// 常時浮遊のモンスターであることを表します
7987
/// 通常は false ですが、アイボールなどの一部のモンスターは true になります
8088
pub auto_levitation: bool,

0 commit comments

Comments
 (0)