Skip to content

Commit bcfcf50

Browse files
committed
bevy 0.17 update
1 parent a3e9a26 commit bcfcf50

File tree

7 files changed

+77
-45
lines changed

7 files changed

+77
-45
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ or
6565

6666
```toml
6767
# always pin to the same exact version you also of the Swift package
68-
bevy_ios_iap = { version = "=0.2.1" }
68+
bevy_ios_iap = { version = "=0.8" }
6969
```
7070

7171
### 3. Setup Plugin
@@ -158,7 +158,8 @@ fn process_iap_events(
158158

159159
|bevy|crate|
160160
|---|---|
161-
|0.16|0.6,main|
161+
|0.17|0.8,main|
162+
|0.16|0.6,0.7|
162163
|0.15|0.5|
163164
|0.14|0.3,0.4|
164165
|0.13|0.2|

bevy_ios_iap/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_ios_iap"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
edition = "2024"
55
build = "build.rs"
66
readme = "../README.md"
@@ -15,11 +15,11 @@ description = "Bevy Plugin and Swift Package to provide access to iOS native Sto
1515
crate-type = ["staticlib", "rlib"]
1616

1717
[dependencies]
18-
bevy_app = { version = "0.16", default-features = false }
19-
bevy_ecs = { version = "0.16", default-features = false }
20-
bevy_ecs_macros = { version = "0.16", default-features = false }
21-
bevy_log = { version = "0.16", default-features = false }
22-
bevy_crossbeam_event = "0.8"
18+
bevy_app = { version = "0.17", default-features = false }
19+
bevy_ecs = { version = "0.17", default-features = false }
20+
bevy_ecs_macros = { version = "0.17", default-features = false }
21+
bevy_log = { version = "0.17", default-features = false }
22+
bevy_channel_message = {path = "../../bevy_channel_message"}
2323
swift-bridge = "0.1"
2424

2525
[build-dependencies]

bevy_ios_iap/src/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::sync::OnceLock;
44

5-
use bevy_crossbeam_event::CrossbeamEventSender;
5+
use bevy_channel_message::CrossbeamEventSender;
66

77
#[allow(unused_imports)]
88
pub use ffi::*;

bevy_ios_iap/src/plugin.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
};
99

1010
/// All possible responses for communication from the native iOS (Swift) side to Rust/Bevy as a reaction to a method call / request.
11-
#[derive(Event, Clone, Debug)]
11+
#[derive(Message, Clone, Debug)]
1212
pub enum IosIapResponse {
1313
/// Triggered by calls to [`get_products`][crate::get_products]
1414
Products((i64, IosIapProductsResponse)),
@@ -24,7 +24,7 @@ pub enum IosIapResponse {
2424

2525
/// Events for pro-active communication from native iOS (Swift) side to Rust/Bevy that are not a direct response to a request.
2626
#[non_exhaustive]
27-
#[derive(Event, Clone, Debug)]
27+
#[derive(Message, Clone, Debug)]
2828
pub enum IosIapEvents {
2929
/// Triggered automatically by TransactionObserver registered by [`init`][crate::init]
3030
/// for every update on any Transaction while the app is running.
@@ -50,13 +50,13 @@ impl Plugin for IosIapPlugin {
5050

5151
#[cfg(not(target_os = "ios"))]
5252
{
53-
app.add_event::<IosIapEvents>();
54-
app.add_event::<IosIapResponse>();
53+
app.add_message::<IosIapEvents>();
54+
app.add_message::<IosIapResponse>();
5555
}
5656

5757
#[cfg(target_os = "ios")]
5858
{
59-
use bevy_crossbeam_event::{CrossbeamEventApp, CrossbeamEventSender};
59+
use bevy_channel_message::{CrossbeamEventApp, CrossbeamEventSender};
6060

6161
app.add_crossbeam_event::<IosIapEvents>();
6262

bevy_ios_iap/src/request.rs

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,35 @@ use crate::{
1111
IosIapTransactionResponse, plugin::IosIapResponse,
1212
};
1313

14-
#[derive(Event, Debug)]
15-
pub struct CurrentEntitlements(pub IosIapTransactionResponse);
14+
#[derive(EntityEvent, Debug)]
15+
pub struct CurrentEntitlements {
16+
pub entity: Entity,
17+
pub response: IosIapTransactionResponse,
18+
}
1619

17-
#[derive(Event, Debug)]
18-
pub struct Products(pub IosIapProductsResponse);
20+
#[derive(EntityEvent, Debug)]
21+
pub struct Products {
22+
pub entity: Entity,
23+
pub response: IosIapProductsResponse,
24+
}
1925

20-
#[derive(Event, Debug)]
21-
pub struct Purchase(pub IosIapPurchaseResponse);
26+
#[derive(EntityEvent, Debug)]
27+
pub struct Purchase {
28+
pub entity: Entity,
29+
pub response: IosIapPurchaseResponse,
30+
}
2231

23-
#[derive(Event, Debug)]
24-
pub struct FinishTransaction(pub IosIapTransactionFinishResponse);
32+
#[derive(EntityEvent, Debug)]
33+
pub struct FinishTransaction {
34+
pub entity: Entity,
35+
pub response: IosIapTransactionFinishResponse,
36+
}
2537

26-
#[derive(Event, Debug)]
27-
pub struct AllTransactions(pub IosIapTransactionResponse);
38+
#[derive(EntityEvent, Debug)]
39+
pub struct AllTransactions {
40+
pub entity: Entity,
41+
pub response: IosIapTransactionResponse,
42+
}
2843

2944
#[derive(Resource, Default)]
3045
struct BevyIosIapSate {
@@ -127,7 +142,7 @@ pub struct BevyIosIapRequestBuilder<'a, T>(EntityCommands<'a>, PhantomData<T>);
127142

128143
impl<'a, T> BevyIosIapRequestBuilder<'a, T>
129144
where
130-
T: 'static + Event,
145+
T: 'static + Event + bevy_ecs::event::EntityEvent,
131146
{
132147
fn new(ec: EntityCommands<'a>) -> Self {
133148
Self(ec, PhantomData)
@@ -151,7 +166,7 @@ pub fn plugin(app: &mut App) {
151166
PreUpdate,
152167
(
153168
cleanup_finished_requests,
154-
process_events.run_if(on_event::<IosIapResponse>),
169+
process_events.run_if(on_message::<IosIapResponse>),
155170
)
156171
.chain()
157172
.in_set(BevyIosIapSet),
@@ -171,7 +186,7 @@ fn cleanup_finished_requests(
171186

172187
#[allow(unused_variables, unused_mut)]
173188
fn process_events(
174-
mut events: EventReader<IosIapResponse>,
189+
mut events: MessageReader<IosIapResponse>,
175190
mut commands: Commands,
176191
query_current_entitlements: Query<(Entity, &RequestId), With<RequestCurrentEntitlements>>,
177192
query_products: Query<(Entity, &RequestId), With<RequestProducts>>,
@@ -182,7 +197,10 @@ fn process_events(
182197
IosIapResponse::CurrentEntitlements((r, response)) => {
183198
for (e, id) in &query_current_entitlements {
184199
if id.0 == *r {
185-
commands.trigger_targets(CurrentEntitlements(response.clone()), e);
200+
commands.trigger(CurrentEntitlements {
201+
entity: e,
202+
response: response.clone(),
203+
});
186204
if let Ok(mut ec) = commands.get_entity(e) {
187205
ec.remove::<RequestId>();
188206
}
@@ -193,7 +211,10 @@ fn process_events(
193211
IosIapResponse::Products((r, response)) => {
194212
for (e, id) in &query_products {
195213
if id.0 == *r {
196-
commands.trigger_targets(Products(response.clone()), e);
214+
commands.trigger(Products {
215+
entity: e,
216+
response: response.clone(),
217+
});
197218
if let Ok(mut ec) = commands.get_entity(e) {
198219
ec.remove::<RequestId>();
199220
}
@@ -204,7 +225,10 @@ fn process_events(
204225
IosIapResponse::Purchase((r, response)) => {
205226
for (e, id) in &query_purchases {
206227
if id.0 == *r {
207-
commands.trigger_targets(Purchase(response.clone()), e);
228+
commands.trigger(Purchase {
229+
entity: e,
230+
response: response.clone(),
231+
});
208232
if let Ok(mut ec) = commands.get_entity(e) {
209233
ec.remove::<RequestId>();
210234
}
@@ -215,7 +239,10 @@ fn process_events(
215239
IosIapResponse::TransactionFinished((r, response)) => {
216240
for (e, id) in &query_purchases {
217241
if id.0 == *r {
218-
commands.trigger_targets(FinishTransaction(response.clone()), e);
242+
commands.trigger(FinishTransaction {
243+
entity: e,
244+
response: response.clone(),
245+
});
219246
if let Ok(mut ec) = commands.get_entity(e) {
220247
ec.remove::<RequestId>();
221248
}
@@ -226,7 +253,10 @@ fn process_events(
226253
IosIapResponse::AllTransactions((r, response)) => {
227254
for (e, id) in &query_purchases {
228255
if id.0 == *r {
229-
commands.trigger_targets(AllTransactions(response.clone()), e);
256+
commands.trigger(AllTransactions {
257+
entity: e,
258+
response: response.clone(),
259+
});
230260
if let Ok(mut ec) = commands.get_entity(e) {
231261
ec.remove::<RequestId>();
232262
}

bevy_ios_iap_egui/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.2.0"
44
edition = "2021"
55

66
[dependencies]
7-
bevy_ios_iap = "0.7"
8-
bevy = { version = "0.16", default-features = false }
9-
bevy_egui = { version = "0.34", default-features = false }
10-
egui_extras = { version = "0.31" }
7+
bevy_ios_iap = {path="../bevy_ios_iap"}
8+
bevy = { version = "0.17", default-features = false }
9+
bevy_egui = { version = "0.37", default-features = false }
10+
egui_extras = { version = "0.32" }

bevy_ios_iap_egui/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ pub struct IosIapEguiPlugin {
3333
impl Plugin for IosIapEguiPlugin {
3434
fn build(&self, app: &mut App) {
3535
if !app.is_plugin_added::<EguiPlugin>() {
36-
app.add_plugins(EguiPlugin {
37-
enable_multipass_for_primary_context: false,
38-
});
36+
app.add_plugins(EguiPlugin::default());
3937
}
4038

4139
app.init_resource::<DebugUiResource>();
@@ -49,23 +47,26 @@ impl Plugin for IosIapEguiPlugin {
4947
app.add_systems(Update, update);
5048
app.add_systems(
5149
Update,
52-
process_iap_responses.run_if(on_event::<IosIapResponse>),
50+
process_iap_responses.run_if(on_message::<IosIapResponse>),
51+
);
52+
app.add_systems(
53+
Update,
54+
process_iap_events.run_if(on_message::<IosIapEvents>),
5355
);
54-
app.add_systems(Update, process_iap_events.run_if(on_event::<IosIapEvents>));
5556

5657
app.add_observer(on_toggle);
5758
}
5859
}
5960

60-
fn on_toggle(trigger: Trigger<IosIapEguiOpen>, mut res: ResMut<DebugUiResource>) {
61+
fn on_toggle(trigger: On<IosIapEguiOpen>, mut res: ResMut<DebugUiResource>) {
6162
match trigger.event() {
6263
IosIapEguiOpen::Toggle => res.open = !res.open,
6364
IosIapEguiOpen::Open => res.open = true,
6465
IosIapEguiOpen::Close => res.open = false,
6566
}
6667
}
6768

68-
fn process_iap_responses(mut events: EventReader<IosIapResponse>, mut res: ResMut<DebugIosIap>) {
69+
fn process_iap_responses(mut events: MessageReader<IosIapResponse>, mut res: ResMut<DebugIosIap>) {
6970
for e in events.read() {
7071
match e {
7172
IosIapResponse::Products((_r, IosIapProductsResponse::Done(products))) => {
@@ -107,7 +108,7 @@ fn process_iap_responses(mut events: EventReader<IosIapResponse>, mut res: ResMu
107108
}
108109
}
109110

110-
fn process_iap_events(mut events: EventReader<IosIapEvents>, mut res: ResMut<DebugIosIap>) {
111+
fn process_iap_events(mut events: MessageReader<IosIapEvents>, mut res: ResMut<DebugIosIap>) {
111112
for e in events.read() {
112113
match e {
113114
IosIapEvents::TransactionUpdate(t) => {
@@ -125,7 +126,7 @@ fn update(
125126
mut res_iap: ResMut<DebugIosIap>,
126127
) {
127128
let mut open_state = res.open;
128-
let Some(ctx) = contexts.try_ctx_mut() else {
129+
let Ok(ctx) = contexts.ctx_mut() else {
129130
return;
130131
};
131132

0 commit comments

Comments
 (0)