diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a53e9e..5079c27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Dialog Update - [v0.4.0](https://github.com/Fabinistere/fabien-et-la-trahison-de-olf/releases/tag/v0.4.0) - 2023-09-04 +### Changed + +- globalize `PlayerLocation` to `Location` + - The component `Location` is given to + - Each npc + - Each landmark + - `Location` is still a `State` to keep the quick and easy access to the player's location + +### Dialog + +- YML Dialog and reorganize ui components + +### NPCs' Behavior + +#### Refactored + +- Follow Behavior + - add and use a `FollowRangeSensor` to detect the follow_target's hitbox + +#### Added + +- Detection Behavior + - `TargetSeeker` + - `DetectionRangeSensor` used to analyze all entering characters' hitbox and compare with their `TargetType` + - if it correpond: Deactivate this sensor and start the Chase Behavior with the component `Chaser`. +- Chase Behavior + - `Chaser` + - `PursuitRangeSensor` used to analyze all exiting characters' hitbox and compare with their `Chaser`'s `target` + - if it correpond: Deactivate this sensor and remove the Chase Behavior. + - The `CharacterCloseSensor` used to detect all entering `Chaser`s hitbox and start a Combat if the `Chaser`'s `target` is the parent of the `CharacterCloseSensor`. + ## Map, Title Screen and Animation Update - [v0.3.9](https://github.com/Fabinistere/fabien-et-la-trahison-de-olf/releases/tag/v0.3.9) - 2023-08-31 [![v0.3.9](https://img.shields.io/badge/v0.3.9-gray?style=flat&logo=github&logoColor=181717&link=https://github.com/Fabinistere/fabien-et-la-trahison-de-olf/releases/tag/v0.3.9)](https://github.com/Fabinistere/fabien-et-la-trahison-de-olf/releases/tag/v0.3.9) diff --git a/src/animations/mod.rs b/src/animations/mod.rs old mode 100644 new mode 100755 index 6bea73a..5944442 --- a/src/animations/mod.rs +++ b/src/animations/mod.rs @@ -7,7 +7,15 @@ use bevy::prelude::*; pub use fade::{Fade, FadeType}; pub use slide::{Slide, UiSlide, UiSlideType}; -use crate::in_menu; +use crate::{ + constants::character::{ + COLUMN_FRAME_IDLE_END, COLUMN_FRAME_IDLE_START, COLUMN_FRAME_RUN_END, + SPRITESHEET_COLUMN_NUMBER, SPRITESHEET_LINE_NUMBER, + }, + in_menu, +}; + +use self::sprite_sheet_animation::CharacterState; // DOC: create systemsLabel for `sprite_sheet_animation::tempo_animation_timer` @@ -16,6 +24,7 @@ pub struct AnimationPlugin; impl Plugin for AnimationPlugin { fn build(&self, app: &mut App) { app.init_resource::() + .init_resource::() .add_systems( PostUpdate, ( @@ -68,3 +77,31 @@ impl FromWorld for CharacterSpriteSheet { } } } + +#[derive(Deref, Clone, Resource)] +pub struct GlobalAnimationIndices(Vec>); + +impl FromWorld for GlobalAnimationIndices { + fn from_world(_world: &mut World) -> Self { + let mut global_animations_indices: Vec> = Vec::new(); + for line in 0..SPRITESHEET_LINE_NUMBER { + global_animations_indices.push(vec![ + // Run Indexes for each line + ( + line * SPRITESHEET_COLUMN_NUMBER, + line * SPRITESHEET_COLUMN_NUMBER + COLUMN_FRAME_RUN_END, + CharacterState::Idle, + // CharacterState::Run, ? + ), + // Idle Indexes for each line + ( + line * SPRITESHEET_COLUMN_NUMBER + COLUMN_FRAME_IDLE_START, + line * SPRITESHEET_COLUMN_NUMBER + COLUMN_FRAME_IDLE_END, + CharacterState::Idle, + ), + ]); + } + + GlobalAnimationIndices(global_animations_indices) + } +} diff --git a/src/characters/npcs/idle.rs b/src/characters/npcs/idle.rs index 8624357..6d9d860 100755 --- a/src/characters/npcs/idle.rs +++ b/src/characters/npcs/idle.rs @@ -1,4 +1,5 @@ use bevy::prelude::*; +use bevy_rapier2d::prelude::Velocity; use super::{movement::NPCBehavior, NPC}; @@ -11,12 +12,19 @@ pub struct RestTime { pub fn flexing_timer( mut commands: Commands, time: Res