2021-01-02 20:06:33 +00:00
|
|
|
use crate::{comp, uid::Uid};
|
2020-11-16 23:32:23 +00:00
|
|
|
use comp::item::Reagent;
|
2020-07-31 17:16:20 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use vek::*;
|
|
|
|
|
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
|
|
|
},
|
|
|
|
ProjectileShot {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
body: comp::Body,
|
|
|
|
vel: Vec3<f32>,
|
|
|
|
},
|
2020-11-14 08:23:57 +00:00
|
|
|
LevelUp {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
},
|
2020-11-15 00:14:15 +00:00
|
|
|
Beam {
|
|
|
|
pos: Vec3<f32>,
|
|
|
|
heal: bool,
|
|
|
|
},
|
2021-01-02 20:06:33 +00:00
|
|
|
ExpChange {
|
|
|
|
uid: Uid,
|
|
|
|
exp: i32,
|
|
|
|
},
|
2021-01-04 19:29:15 +00:00
|
|
|
SkillPointGain {
|
|
|
|
uid: Uid,
|
|
|
|
skill_tree: comp::skills::SkillGroupType,
|
|
|
|
total_points: u16,
|
|
|
|
},
|
2020-07-31 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Outcome {
|
|
|
|
pub fn get_pos(&self) -> Option<Vec3<f32>> {
|
|
|
|
match self {
|
|
|
|
Outcome::Explosion { pos, .. } => Some(*pos),
|
|
|
|
Outcome::ProjectileShot { pos, .. } => Some(*pos),
|
2020-11-14 08:23:57 +00:00
|
|
|
Outcome::LevelUp { pos } => Some(*pos),
|
2020-11-15 00:14:15 +00:00
|
|
|
Outcome::Beam { pos, .. } => Some(*pos),
|
2021-01-02 20:06:33 +00:00
|
|
|
Outcome::ExpChange { .. } => None,
|
2021-01-04 19:29:15 +00:00
|
|
|
Outcome::SkillPointGain { .. } => None,
|
2020-07-31 17:16:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|