@@ -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 ) ]
3045struct BevyIosIapSate {
@@ -127,7 +142,7 @@ pub struct BevyIosIapRequestBuilder<'a, T>(EntityCommands<'a>, PhantomData<T>);
127142
128143impl < ' a , T > BevyIosIapRequestBuilder < ' a , T >
129144where
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) ]
173188fn 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 }
0 commit comments