@@ -7,18 +7,25 @@ use rendering::renderers::{Color};
77use rendering:: windows:: Windows ;
88use movement:: { AggroMovementComponent , RandomMovementComponent , UserMovementComponent , MovementComponent } ;
99
10- pub struct Actor < ' a > {
10+ pub struct Actor {
1111 pub position : Point ,
1212 pub display_char : char ,
13- pub movement_component : Box < MovementComponent + ' a > ,
13+ pub movement_component : Box < MovementComponent + ' static > ,
1414 pub is_pc : bool ,
1515 pub foreground : Color ,
1616 pub background : Color ,
1717 pub health : u8
1818}
1919
20- impl < ' a > Actor < ' a > {
21- pub fn new ( x : i32 , y : i32 , dc : char , mc : Box < MovementComponent + ' a > , is_pc : bool , foreground : Color , background : Color , health : u8 ) -> Actor < ' a > {
20+ impl Clone for Actor {
21+ pub fn clone ( & self ) -> Actor {
22+ let mc = self . movement_component . box_clone ( ) ;
23+ Actor :: new ( self . position . x , self . position . y , self . display_char , mc, self . is_pc , self . foreground , self . background , self . health )
24+ }
25+ }
26+
27+ impl Actor {
28+ pub fn new ( x : i32 , y : i32 , dc : char , mc : Box < MovementComponent + ' static > , is_pc : bool , foreground : Color , background : Color , health : u8 ) -> Actor {
2229 Actor {
2330 position : Point { x : x, y : y } ,
2431 display_char : dc,
@@ -30,30 +37,25 @@ impl<'a> Actor<'a> {
3037 }
3138 }
3239
33- pub fn clone ( & ' a self ) -> Actor < ' a > {
34- let mc = self . movement_component . box_clone ( ) ;
35- Actor :: new ( self . position . x , self . position . y , self . display_char , mc, self . is_pc , self . foreground , self . background , self . health )
36- }
37-
38- pub fn dog ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor < ' a > {
40+ pub fn dog ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor {
3941 let mc : Box < RandomMovementComponent > = box MovementComponent :: new ( move_info) ;
4042 Actor :: new ( x, y, 'd' , mc, false , Color :: White , Color :: Black , 20u8 )
4143 }
4244
43- pub fn cat ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor < ' a > {
45+ pub fn cat ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor {
4446 let mc : Box < RandomMovementComponent > = box MovementComponent :: new ( move_info) ;
4547 Actor :: new ( x, y, 'c' , mc, false , Color :: White , Color :: Black , 20u8 )
4648 }
4749
48- pub fn heroine ( move_info : Rc < RefCell < MoveInfo > > ) -> Actor < ' a > {
50+ pub fn heroine ( move_info : Rc < RefCell < MoveInfo > > ) -> Actor {
4951 let point = {
5052 move_info. borrow ( ) . deref ( ) . char_location
5153 } ;
5254 let mc : Box < UserMovementComponent > = box MovementComponent :: new ( move_info) ;
5355 Actor :: new ( point. x , point. y , '@' , mc, true , Color :: Blue , Color :: Black , 20u8 )
5456 }
5557
56- pub fn kobold ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor < ' a > {
58+ pub fn kobold ( x : i32 , y : i32 , move_info : Rc < RefCell < MoveInfo > > ) -> Actor {
5759 let mc : Box < AggroMovementComponent > = box MovementComponent :: new ( move_info) ;
5860 Actor :: new ( x, y, 'k' , mc, false , Color :: Red , Color :: Black , 20u8 )
5961 }
0 commit comments