-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from AnthonyTornetta/367-rework-pirate-spawns
367 rework pirate spawns
- Loading branch information
Showing
26 changed files
with
489 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//! Used to identify the causer of this projectile. | ||
//! | ||
//! Typically used to determine damage source | ||
use bevy::{ | ||
prelude::{App, Component, Entity}, | ||
reflect::Reflect, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[cfg(feature = "client")] | ||
use crate::netty::sync::mapping::Mappable; | ||
#[cfg(feature = "client")] | ||
use crate::netty::sync::mapping::MappingError; | ||
|
||
#[derive(Component, Debug, Reflect, Clone, Copy, Serialize, Deserialize)] | ||
/// Identifies who fired this projectile. | ||
pub struct Causer(pub Entity); | ||
|
||
#[cfg(feature = "client")] | ||
impl Mappable for Causer { | ||
fn map( | ||
self, | ||
network_mapping: &crate::netty::sync::mapping::NetworkMapping, | ||
) -> Result<Self, crate::netty::sync::mapping::MappingError<Self>> | ||
where | ||
Self: Sized, | ||
{ | ||
network_mapping | ||
.client_from_server(&self.0) | ||
.map(|x| Ok(Self(x))) | ||
.unwrap_or(Err(MappingError::MissingRecord(self))) | ||
} | ||
|
||
fn map_to_server( | ||
self, | ||
network_mapping: &crate::netty::sync::mapping::NetworkMapping, | ||
) -> Result<Self, crate::netty::sync::mapping::MappingError<Self>> | ||
where | ||
Self: Sized, | ||
{ | ||
network_mapping | ||
.server_from_client(&self.0) | ||
.map(|x| Ok(Self(x))) | ||
.unwrap_or(Err(MappingError::MissingRecord(self))) | ||
} | ||
} | ||
|
||
pub(super) fn register(app: &mut App) { | ||
app.register_type::<Causer>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.