Skip to content

Commit

Permalink
remove DroppedItemType
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Nov 16, 2024
1 parent 629bc09 commit bbc41e8
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 58 deletions.
Binary file modified docs/assets/image/atlas.aseprite
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=assets/favicon.png rel=icon><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="2WHReOIsSy/GI7WCUgSyrA==" type=module>import init, * as bindings from './magiacircle-1a1a1376457cef33.js';
const wasm = await init('./magiacircle-1a1a1376457cef33_bg.wasm');
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=assets/favicon.png rel=icon><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="pIrzXoMynA67iu1KY7LYeA==" type=module>import init, * as bindings from './magiacircle-9949efff13842b68.js';
const wasm = await init('./magiacircle-9949efff13842b68_bg.wasm');


window.wasmBindings = bindings;


dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title>magiacircle 0.1</title><link crossorigin href=./magiacircle-1a1a1376457cef33.js integrity=sha384-QGMiPNLyOCeJBMB4HtHLgpXZJRNAUOblB/m88Oh8eRauyL9lbwpVE1p0HbZKGtwi rel=modulepreload><link as=fetch crossorigin href=./magiacircle-1a1a1376457cef33_bg.wasm integrity=sha384-jich4YFJNiBXGzaaBR3NUsRRj/JPyQWnFD0CPnmi72Z+yrEdSd7AUfICjUBSTY/E rel=preload type=application/wasm></head><body></body></html>
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title>magiacircle 0.1</title><link crossorigin href=./magiacircle-9949efff13842b68.js integrity=sha384-n83H0AAGgwBF90Hr4gZwMBEUg/1kKPni2K4ZttbIaPB0FtSNBClA9QkY+ZP2tPoO rel=modulepreload><link as=fetch crossorigin href=./magiacircle-9949efff13842b68_bg.wasm integrity=sha384-mtNpwphwfU49AqUKm9F3oTP4wF02oj+nPPX15SpDYvGclXjlk8OeF1ji94yQjrZG rel=preload type=application/wasm></head><body></body></html>
1 change: 0 additions & 1 deletion docs/magiacircle-1a1a1376457cef33.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/magiacircle-9949efff13842b68.js

Large diffs are not rendered by default.

Binary file not shown.
48 changes: 15 additions & 33 deletions src/entity/dropped_item.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::entity::EntityDepth;
use crate::inventory_item::InventoryItem;
use crate::spell::SpellType;
use crate::spell_props::spell_to_props;
use crate::wand::WandType;
use crate::wand_props::wand_to_props;
use crate::{asset::GameAssets, constant::*, states::GameState};
use bevy::core::FrameCount;
Expand All @@ -11,25 +9,9 @@ use bevy_aseprite_ultra::prelude::*;
use bevy_rapier2d::prelude::*;
use rand::random;

pub enum DroppedItemType {
Spell(SpellType),
Wand(WandType),
Lantern,
}

impl DroppedItemType {
pub fn to_inventory_item(&self) -> InventoryItem {
match self {
DroppedItemType::Spell(spell) => InventoryItem::Spell(*spell),
DroppedItemType::Lantern => InventoryItem::Lantern,
DroppedItemType::Wand(wand) => InventoryItem::Wand(*wand),
}
}
}

#[derive(Component)]
pub struct DroppedItemEntity {
pub item_type: DroppedItemType,
pub item_type: InventoryItem,
pub interaction_marker: bool,
}

Expand All @@ -46,45 +28,45 @@ pub fn spawn_dropped_item(
assets: &Res<GameAssets>,
x: f32,
y: f32,
item_type: DroppedItemType,
item_type: InventoryItem,
) {
let tx = x;
let ty = y;
let icon = match item_type {
DroppedItemType::Spell(spell) => {
InventoryItem::Spell(spell) => {
let props = spell_to_props(spell);
props.icon
}
DroppedItemType::Wand(wand) => {
InventoryItem::Wand(wand) => {
let props = wand_to_props(wand);
props.icon
}
DroppedItemType::Lantern => "lantern",
InventoryItem::Lantern => "lantern",
};
let name = match item_type {
DroppedItemType::Spell(spell) => {
InventoryItem::Spell(spell) => {
let props = spell_to_props(spell);
props.name.en
}
DroppedItemType::Wand(wand) => {
InventoryItem::Wand(wand) => {
let props = wand_to_props(wand);
props.name.en
}
DroppedItemType::Lantern => "lantern",
InventoryItem::Lantern => "lantern",
};
let frame_slice = match item_type {
DroppedItemType::Wand(_) => "empty", //"wand_frame",
DroppedItemType::Spell(_) => "spell_frame",
DroppedItemType::Lantern => "empty",
InventoryItem::Wand(_) => "empty", //"wand_frame",
InventoryItem::Spell(_) => "spell_frame",
InventoryItem::Lantern => "empty",
};
let collider_width = match item_type {
DroppedItemType::Wand(_) => 16.0,
InventoryItem::Wand(_) => 16.0,
_ => 8.0,
};
let swing = match item_type {
DroppedItemType::Spell(_) => 2.0,
DroppedItemType::Wand(_) => 0.0,
DroppedItemType::Lantern => 0.0,
InventoryItem::Spell(_) => 2.0,
InventoryItem::Wand(_) => 0.0,
InventoryItem::Lantern => 0.0,
};
commands
.spawn((
Expand Down
2 changes: 1 addition & 1 deletion src/interaction_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn pick_up(
pick_nearest_drop_item(&mut spells, player_transform.translation.truncate())
{
if let Ok((_, DroppedItemEntity { item_type, .. }, _)) = spell_query.get(nearest) {
if player.insert_inventory_item(item_type.to_inventory_item()) {
if player.insert_inventory_item(*item_type) {
commands.entity(nearest).despawn_recursive();
global.send(GameCommand::SEPickUp(None));
// エンティティを削除すれば Stopped イベントが発生してリストから消えるので、
Expand Down
9 changes: 4 additions & 5 deletions src/inventory_item.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use bevy::prelude::*;

use crate::{
asset::GameAssets,
constant::MAX_ITEMS_IN_INVENTORY,
entity::dropped_item::{spawn_dropped_item, DroppedItemType},
entity::dropped_item::spawn_dropped_item,
language::{Dict, Languages},
spell::SpellType,
spell_props::{get_spell_appendix, spell_to_props},
wand::WandType,
wand_props::wand_to_props,
};
use bevy::prelude::*;

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum InventoryItem {
Expand All @@ -31,7 +30,7 @@ pub fn spawn_inventory_item(
&assets,
position.x,
position.y,
DroppedItemType::Spell(spell),
InventoryItem::Spell(spell),
);
}
InventoryItem::Lantern => {
Expand All @@ -40,7 +39,7 @@ pub fn spawn_inventory_item(
&assets,
position.x,
position.y,
DroppedItemType::Lantern,
InventoryItem::Lantern,
);
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/equipment_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ fn spawn_equipment_slot(parent: &mut ChildBuilder, assets: &Res<GameAssets>, ind
pub struct EquipmentListPlugin;

impl Plugin for EquipmentListPlugin {
fn build(&self, app: &mut App) {}
fn build(&self, _app: &mut App) {}
}
6 changes: 2 additions & 4 deletions src/ui/inventory.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::entity::dropped_item::{spawn_dropped_item, DroppedItemType};
use crate::inventory_item::spawn_inventory_item;
use crate::entity::dropped_item::spawn_dropped_item;
use crate::ui::floating::{InventoryItemFloating, InventoryItemFloatingContent};
use crate::wand_props::wand_to_props;
use crate::{asset, command};
use crate::{
asset::GameAssets, constant::MAX_ITEMS_IN_INVENTORY, controller::player::Player,
entity::actor::Actor, inventory_item::InventoryItem, spell_props::spell_to_props,
Expand Down Expand Up @@ -228,7 +226,7 @@ fn interaction(
&assets,
player_position.translation.x,
player_position.translation.y,
DroppedItemType::Spell(spell),
InventoryItem::Spell(spell),
);
}

Expand Down
11 changes: 4 additions & 7 deletions src/ui/wand_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use crate::{
asset::GameAssets,
constant::{TILE_SIZE, WAND_EDITOR_Z_INDEX},
controller::player::Player,
entity::{
actor::Actor,
dropped_item::{spawn_dropped_item, DroppedItemType},
},
entity::{actor::Actor, dropped_item::spawn_dropped_item},
inventory_item::{sort_inventory, spawn_inventory_item, InventoryItem},
language::Dict,
set::GameSet,
Expand Down Expand Up @@ -217,7 +214,7 @@ fn item_drop_button_pressed(
&assets,
dest.x,
dest.y,
DroppedItemType::Spell(spell),
InventoryItem::Spell(spell),
);
}
}
Expand All @@ -226,7 +223,7 @@ fn item_drop_button_pressed(
&assets,
dest.x,
dest.y,
DroppedItemType::Wand(wand.wand_type),
InventoryItem::Wand(wand.wand_type),
);
actor.wands[index] = None;
*floating = InventoryItemFloating(None);
Expand All @@ -243,7 +240,7 @@ fn item_drop_button_pressed(
&assets,
pointer_in_world.x,
pointer_in_world.y,
DroppedItemType::Spell(spell),
InventoryItem::Spell(spell),
);
wand.slots[spell_index] = None;
*floating = InventoryItemFloating(None);
Expand Down
5 changes: 2 additions & 3 deletions src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::entity::broken_magic_circle::spawn_broken_magic_circle;
use crate::entity::chest::spawn_chest;
use crate::entity::chest::ChestType;
use crate::entity::dropped_item::spawn_dropped_item;
use crate::entity::dropped_item::DroppedItemType;
use crate::entity::magic_circle::spawn_magic_circle;
use crate::entity::magic_circle::MagicCircleDestination;
use crate::entity::stone_lantern::spawn_stone_lantern;
Expand Down Expand Up @@ -409,7 +408,7 @@ fn spawn_entities(mut commands: &mut Commands, assets: &Res<GameAssets>, chunk:
&assets,
tx + TILE_HALF,
ty - TILE_HALF,
DroppedItemType::Spell(SpellType::MagicBolt),
InventoryItem::Spell(SpellType::MagicBolt),
);
}
GameEntity::Wand => {
Expand All @@ -418,7 +417,7 @@ fn spawn_entities(mut commands: &mut Commands, assets: &Res<GameAssets>, chunk:
&assets,
tx + TILE_HALF,
ty - TILE_HALF,
DroppedItemType::Wand(WandType::CypressWand),
InventoryItem::Wand(WandType::CypressWand),
);
}
}
Expand Down

0 comments on commit bbc41e8

Please sign in to comment.