2023-03-11 12:59:30 +00:00
|
|
|
use crate::{combat::DamageContributor, comp, terrain::SpriteKind, uid::Uid, DamageSource};
|
2021-10-17 04:28:39 +00:00
|
|
|
use comp::{beam, item::Reagent, poise::PoiseState, skillset::SkillGroupKind, UtteranceKind};
|
2021-06-09 20:03:25 +00:00
|
|
|
use hashbrown::HashSet;
|
2020-07-31 17:16:20 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use vek::*;
|
|
|
|
|
2022-01-21 18:14:24 +00:00
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
2022-06-14 21:11:58 +00:00
|
|
|
pub struct HealthChangeInfo {
|
2022-01-21 18:14:24 +00:00
|
|
|
pub amount: f32,
|
2023-11-11 19:20:38 +00:00
|
|
|
pub precise: bool,
|
2022-01-21 18:14:24 +00:00
|
|
|
pub target: Uid,
|
2022-01-22 20:15:12 +00:00
|
|
|
pub by: Option<DamageContributor>,
|
2022-07-12 21:01:47 +00:00
|
|
|
pub cause: Option<DamageSource>,
|
2022-01-26 10:16:45 +00:00
|
|
|
pub instance: u64,
|
2022-01-21 18:14:24 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 16:41:43 +00:00
|
|
|
/// An outcome represents the final result of an instantaneous event. It implies
|
|
|
|
/// that said event has already occurred. It is not a request for that event to
|
|
|
|
/// occur, nor is it something that may be cancelled or otherwise altered. Its
|
|
|
|
/// primary purpose is to act as something for frontends (both server and
|
|
|
|
/// client) to listen to in order to receive feedback about events in the world.
|
2020-07-31 17:16:20 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub enum Outcome {
|
|
|
|
Explosion {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
power: f32,
|
2020-10-06 02:19:41 +00:00
|
|
|
radius: f32,
|
2020-10-08 00:32:30 +00:00
|
|
|
is_attack: bool,
|
2020-08-11 14:05:34 +00:00
|
|
|
reagent: Option<Reagent>, // How can we better define this?
|
2020-07-31 17:16:20 +00:00
|
|
|
},
|
2022-07-08 22:26:33 +00:00
|
|
|
Lightning {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2020-07-31 17:16:20 +00:00
|
|
|
ProjectileShot {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
body: comp::Body,
|
|
|
|
vel: Vec3<f32>,
|
|
|
|
},
|
2021-03-28 23:29:48 +00:00
|
|
|
ProjectileHit {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
body: comp::Body,
|
|
|
|
vel: Vec3<f32>,
|
|
|
|
source: Option<Uid>,
|
|
|
|
target: Option<Uid>,
|
|
|
|
},
|
2020-11-15 00:14:15 +00:00
|
|
|
Beam {
|
|
|
|
pos: Vec3<f32>,
|
2021-03-03 04:56:09 +00:00
|
|
|
specifier: beam::FrontendSpecifier,
|
2020-11-15 00:14:15 +00:00
|
|
|
},
|
2021-01-02 20:06:33 +00:00
|
|
|
ExpChange {
|
|
|
|
uid: Uid,
|
2021-10-13 14:44:28 +00:00
|
|
|
exp: u32,
|
2021-06-09 20:03:25 +00:00
|
|
|
xp_pools: HashSet<SkillGroupKind>,
|
2021-01-02 20:06:33 +00:00
|
|
|
},
|
2021-01-04 19:29:15 +00:00
|
|
|
SkillPointGain {
|
|
|
|
uid: Uid,
|
2022-07-15 12:08:04 +00:00
|
|
|
skill_tree: SkillGroupKind,
|
2021-01-04 19:29:15 +00:00
|
|
|
total_points: u16,
|
|
|
|
},
|
2021-03-04 20:43:58 +00:00
|
|
|
ComboChange {
|
|
|
|
uid: Uid,
|
|
|
|
combo: u32,
|
|
|
|
},
|
2021-03-21 20:09:59 +00:00
|
|
|
BreakBlock {
|
|
|
|
pos: Vec3<i32>,
|
|
|
|
color: Option<Rgb<u8>>,
|
|
|
|
},
|
2021-03-27 15:47:56 +00:00
|
|
|
SummonedCreature {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
body: comp::Body,
|
|
|
|
},
|
2022-06-14 21:11:58 +00:00
|
|
|
HealthChange {
|
2021-04-04 03:04:02 +00:00
|
|
|
pos: Vec3<f32>,
|
2022-06-14 21:11:58 +00:00
|
|
|
info: HealthChangeInfo,
|
2021-04-04 03:04:02 +00:00
|
|
|
},
|
2021-06-27 21:45:07 +00:00
|
|
|
Death {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2021-04-19 05:35:46 +00:00
|
|
|
Block {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
parry: bool,
|
2021-04-24 04:11:41 +00:00
|
|
|
uid: Uid,
|
2021-04-19 05:35:46 +00:00
|
|
|
},
|
2021-04-29 23:36:22 +00:00
|
|
|
PoiseChange {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
state: PoiseState,
|
|
|
|
},
|
2021-04-28 22:41:04 +00:00
|
|
|
GroundSlam {
|
2021-04-28 04:23:28 +00:00
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-02-15 00:10:37 +00:00
|
|
|
IceSpikes {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
|
|
|
IceCrack {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
|
|
|
FlashFreeze {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-05-24 18:13:29 +00:00
|
|
|
Steam {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-04-12 22:53:38 +00:00
|
|
|
LaserBeam {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
|
|
|
CyclopsCharge {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-07-09 20:03:09 +00:00
|
|
|
FlamethrowerCharge {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2024-01-20 17:45:23 +00:00
|
|
|
FuseCharge {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2021-06-15 16:15:58 +00:00
|
|
|
Utterance {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
body: comp::Body,
|
|
|
|
kind: UtteranceKind,
|
|
|
|
},
|
2022-03-13 05:44:07 +00:00
|
|
|
Glider {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
wielded: bool,
|
|
|
|
},
|
2023-01-15 18:28:38 +00:00
|
|
|
SpriteDelete {
|
2023-10-15 21:00:36 +00:00
|
|
|
pos: Vec3<i32>,
|
2023-01-15 18:28:38 +00:00
|
|
|
sprite: SpriteKind,
|
|
|
|
},
|
2023-03-03 23:21:37 +00:00
|
|
|
SpriteUnlocked {
|
|
|
|
pos: Vec3<i32>,
|
|
|
|
},
|
|
|
|
FailedSpriteUnlock {
|
|
|
|
pos: Vec3<i32>,
|
|
|
|
},
|
2023-08-02 07:55:10 +00:00
|
|
|
Whoosh {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
|
|
|
Swoosh {
|
2023-04-19 23:56:10 +00:00
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2024-01-20 17:45:23 +00:00
|
|
|
Slash {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-07-09 20:03:09 +00:00
|
|
|
FireShockwave {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-08-03 19:52:55 +00:00
|
|
|
GroundDig {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-08-17 19:53:28 +00:00
|
|
|
PortalActivated {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-08-19 09:44:58 +00:00
|
|
|
TeleportedByPortal {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2023-11-28 11:13:18 +00:00
|
|
|
FromTheAshes {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2024-01-20 17:45:23 +00:00
|
|
|
ClayGolemDash {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2020-07-31 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Outcome {
|
|
|
|
pub fn get_pos(&self) -> Option<Vec3<f32>> {
|
|
|
|
match self {
|
2021-03-04 20:43:58 +00:00
|
|
|
Outcome::Explosion { pos, .. }
|
2022-07-08 22:26:33 +00:00
|
|
|
// TODO: Include this, but allow it to be sent to clients when outside of the VD
|
|
|
|
// | Outcome::Lightning { pos }
|
2021-03-04 20:43:58 +00:00
|
|
|
| Outcome::ProjectileShot { pos, .. }
|
2021-03-28 23:29:48 +00:00
|
|
|
| Outcome::ProjectileHit { pos, .. }
|
2021-03-04 20:43:58 +00:00
|
|
|
| Outcome::Beam { pos, .. }
|
2021-04-04 03:04:02 +00:00
|
|
|
| Outcome::SummonedCreature { pos, .. }
|
2022-06-14 21:11:58 +00:00
|
|
|
| Outcome::HealthChange { pos, .. }
|
2021-06-27 21:45:07 +00:00
|
|
|
| Outcome::Death { pos, .. }
|
2021-04-29 23:36:22 +00:00
|
|
|
| Outcome::Block { pos, .. }
|
2021-04-28 04:23:28 +00:00
|
|
|
| Outcome::PoiseChange { pos, .. }
|
2021-06-15 16:15:58 +00:00
|
|
|
| Outcome::GroundSlam { pos }
|
2023-02-15 00:10:37 +00:00
|
|
|
| Outcome::FlashFreeze { pos }
|
2023-08-02 07:55:10 +00:00
|
|
|
| Outcome::Whoosh { pos }
|
|
|
|
| Outcome::Swoosh { pos }
|
2024-01-20 17:45:23 +00:00
|
|
|
| Outcome::Slash { pos }
|
2023-02-15 00:10:37 +00:00
|
|
|
| Outcome::IceSpikes { pos }
|
2023-05-24 18:13:29 +00:00
|
|
|
| Outcome::Steam { pos }
|
2023-07-09 20:03:09 +00:00
|
|
|
| Outcome::FireShockwave { pos }
|
2023-02-15 00:10:37 +00:00
|
|
|
| Outcome::IceCrack { pos }
|
2022-03-13 05:44:07 +00:00
|
|
|
| Outcome::Utterance { pos, .. }
|
2023-04-12 22:53:38 +00:00
|
|
|
| Outcome::CyclopsCharge { pos }
|
2023-07-09 20:03:09 +00:00
|
|
|
| Outcome::FlamethrowerCharge { pos }
|
2024-01-20 17:45:23 +00:00
|
|
|
| Outcome::FuseCharge { pos }
|
2023-04-12 22:53:38 +00:00
|
|
|
| Outcome::LaserBeam { pos }
|
2023-08-03 19:52:55 +00:00
|
|
|
| Outcome::GroundDig { pos }
|
2023-08-17 19:53:28 +00:00
|
|
|
| Outcome::PortalActivated { pos }
|
2023-08-19 09:44:58 +00:00
|
|
|
| Outcome::TeleportedByPortal { pos}
|
2023-11-28 11:13:18 +00:00
|
|
|
| Outcome::FromTheAshes { pos }
|
2024-01-20 17:45:23 +00:00
|
|
|
| Outcome::ClayGolemDash { pos }
|
2022-03-18 19:49:28 +00:00
|
|
|
| Outcome::Glider { pos, .. } => Some(*pos),
|
2023-03-03 23:21:37 +00:00
|
|
|
Outcome::BreakBlock { pos, .. }
|
|
|
|
| Outcome::SpriteUnlocked { pos }
|
2023-10-15 21:00:36 +00:00
|
|
|
| Outcome::SpriteDelete { pos, .. }
|
2023-03-03 23:21:37 +00:00
|
|
|
| Outcome::FailedSpriteUnlock { pos } => Some(pos.map(|e| e as f32 + 0.5)),
|
2022-03-19 09:14:54 +00:00
|
|
|
Outcome::ExpChange { .. }
|
|
|
|
| Outcome::ComboChange { .. }
|
2022-07-08 22:26:33 +00:00
|
|
|
| Outcome::Lightning { .. }
|
2022-03-19 09:14:54 +00:00
|
|
|
| Outcome::SkillPointGain { .. } => None,
|
2020-07-31 17:16:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|