-
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 #356 from AnthonyTornetta/354-add-basic-fabricator
354 add basic fabricator
- Loading branch information
Showing
48 changed files
with
1,725 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"texture": { | ||
"Sides": { | ||
"right": { | ||
"Single": "cosmos:basic_fabricator_sides" | ||
}, | ||
"left": { | ||
"Single": "cosmos:basic_fabricator_sides" | ||
}, | ||
"front": { | ||
"Single": "cosmos:basic_fabricator_sides" | ||
}, | ||
"back": { | ||
"Single": "cosmos:basic_fabricator_sides" | ||
}, | ||
"top": { | ||
"Single": "cosmos:basic_fabricator_top_bottom" | ||
}, | ||
"bottom": { | ||
"Single": "cosmos:basic_fabricator_top_bottom" | ||
} | ||
} | ||
} | ||
} |
Binary file added
BIN
+160 Bytes
cosmos_client/assets/cosmos/images/blocks/basic_fabricator_sides.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+240 Bytes
cosmos_client/assets/cosmos/images/blocks/basic_fabricator_top_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
cosmos:test_crystal=Test Crystal | ||
cosmos:test_crystal=Test Crystal | ||
cosmos:iron_bar=Iron Bar |
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,70 @@ | ||
use bevy::{ | ||
app::Update, | ||
core::Name, | ||
log::error, | ||
prelude::{ | ||
in_state, App, Commands, Component, Entity, EventReader, IntoSystemConfigs, IntoSystemSetConfigs, Query, Res, SystemSet, With, | ||
}, | ||
reflect::Reflect, | ||
}; | ||
use cosmos_core::{ | ||
crafting::blocks::basic_fabricator::OpenBasicFabricatorEvent, | ||
ecs::NeedsDespawned, | ||
netty::{ | ||
sync::{ | ||
events::client_event::NettyEventReceived, | ||
mapping::{Mappable, NetworkMapping}, | ||
}, | ||
system_sets::NetworkingSystemsSet, | ||
}, | ||
prelude::StructureBlock, | ||
state::GameState, | ||
}; | ||
|
||
mod ui; | ||
|
||
#[derive(Component, Debug, Reflect)] | ||
struct OpenBasicFabricatorMenu(StructureBlock); | ||
|
||
fn open_menu( | ||
q_open_menu: Query<Entity, With<OpenBasicFabricatorMenu>>, | ||
mut commands: Commands, | ||
mut nevr: EventReader<NettyEventReceived<OpenBasicFabricatorEvent>>, | ||
network_mapping: Res<NetworkMapping>, | ||
) { | ||
let Some(ev) = nevr.read().last() else { | ||
return; | ||
}; | ||
|
||
if let Ok(ent) = q_open_menu.get_single() { | ||
commands.entity(ent).insert(NeedsDespawned); | ||
} | ||
|
||
let Ok(s_block) = ev.0.map(&network_mapping) else { | ||
error!("Bad network mapping - {:?}", ev.0); | ||
return; | ||
}; | ||
|
||
commands.spawn((OpenBasicFabricatorMenu(s_block), Name::new("Open Basic Fabricator Menu"))); | ||
} | ||
|
||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] | ||
enum FabricatorMenuSet { | ||
OpenMenu, | ||
PopulateMenu, | ||
} | ||
|
||
pub(super) fn register(app: &mut App) { | ||
ui::register(app); | ||
|
||
app.configure_sets(Update, (FabricatorMenuSet::OpenMenu, FabricatorMenuSet::PopulateMenu).chain()); | ||
|
||
app.add_systems( | ||
Update, | ||
open_menu | ||
.in_set(NetworkingSystemsSet::Between) | ||
.in_set(FabricatorMenuSet::OpenMenu) | ||
.run_if(in_state(GameState::Playing)), | ||
) | ||
.register_type::<OpenBasicFabricatorMenu>(); | ||
} |
Oops, something went wrong.