@@ -108,41 +108,6 @@ impl<'w> EntityRef<'w> {
108108 . map ( |ticks| ticks. deref ( ) )
109109 }
110110 }
111-
112- /// Gets a mutable reference to the component of type `T` associated with
113- /// this entity without ensuring there are no other borrows active and without
114- /// ensuring that the returned reference will stay valid.
115- ///
116- /// # Safety
117- ///
118- /// - The returned reference must never alias a mutable borrow of this component.
119- /// - The returned reference must not be used after this component is moved which
120- /// may happen from **any** `insert_component`, `remove_component` or `despawn`
121- /// operation on this world (non-exhaustive list).
122- #[ inline]
123- pub unsafe fn get_unchecked_mut < T : Component > (
124- & self ,
125- last_change_tick : u32 ,
126- change_tick : u32 ,
127- ) -> Option < Mut < ' w , T > > {
128- self . world
129- . storages
130- . get_component_and_ticks_with_type (
131- & self . world . archetypes ,
132- & self . world . components ,
133- TypeId :: of :: < T > ( ) ,
134- self . entity ,
135- self . location ,
136- )
137- . map ( |( value, ticks) | Mut {
138- value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
139- ticks : Ticks {
140- component_ticks : ticks. deref_mut ( ) ,
141- last_change_tick,
142- change_tick,
143- } ,
144- } )
145- }
146111}
147112
148113impl < ' w > EntityRef < ' w > {
@@ -254,7 +219,25 @@ impl<'w> EntityMut<'w> {
254219 #[ inline]
255220 pub fn get_mut < T : Component > ( & mut self ) -> Option < Mut < ' _ , T > > {
256221 // SAFETY: world access is unique, and lifetimes enforce correct usage of returned borrow
257- unsafe { self . get_unchecked_mut :: < T > ( ) }
222+ unsafe {
223+ self . world
224+ . storages
225+ . get_component_and_ticks_with_type (
226+ & self . world . archetypes ,
227+ & self . world . components ,
228+ TypeId :: of :: < T > ( ) ,
229+ self . entity ,
230+ self . location ,
231+ )
232+ . map ( |( value, ticks) | Mut {
233+ value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
234+ ticks : Ticks {
235+ component_ticks : ticks. deref_mut ( ) ,
236+ last_change_tick : self . world . last_change_tick ( ) ,
237+ change_tick : self . world . read_change_tick ( ) ,
238+ } ,
239+ } )
240+ }
258241 }
259242
260243 /// Retrieves the change ticks for the given component. This can be useful for implementing change
@@ -280,37 +263,6 @@ impl<'w> EntityMut<'w> {
280263 }
281264 }
282265
283- /// Gets a mutable reference to the component of type `T` associated with
284- /// this entity without ensuring there are no other borrows active and without
285- /// ensuring that the returned reference will stay valid.
286- ///
287- /// # Safety
288- ///
289- /// - The returned reference must never alias a mutable borrow of this component.
290- /// - The returned reference must not be used after this component is moved which
291- /// may happen from **any** `insert_component`, `remove_component` or `despawn`
292- /// operation on this world (non-exhaustive list).
293- #[ inline]
294- pub unsafe fn get_unchecked_mut < T : Component > ( & self ) -> Option < Mut < ' _ , T > > {
295- self . world
296- . storages
297- . get_component_and_ticks_with_type (
298- & self . world . archetypes ,
299- & self . world . components ,
300- TypeId :: of :: < T > ( ) ,
301- self . entity ,
302- self . location ,
303- )
304- . map ( |( value, ticks) | Mut {
305- value : value. assert_unique ( ) . deref_mut :: < T > ( ) ,
306- ticks : Ticks {
307- component_ticks : ticks. deref_mut ( ) ,
308- last_change_tick : self . world . last_change_tick ( ) ,
309- change_tick : self . world . read_change_tick ( ) ,
310- } ,
311- } )
312- }
313-
314266 #[ deprecated(
315267 since = "0.9.0" ,
316268 note = "Use `insert` instead, which now accepts bundles, components, and tuples of bundles and components."
0 commit comments