@@ -29,7 +29,7 @@ use all_is_cubes::inv;
29
29
use all_is_cubes:: linking:: { BlockProvider , InGenError } ;
30
30
use all_is_cubes:: listen:: ListenableSource ;
31
31
use all_is_cubes:: math:: {
32
- rgb_const, rgba_const, Cube , Face6 , FaceMap , FreeCoordinate , GridAab , GridCoordinate ,
32
+ notnan , rgb_const, rgba_const, Cube , Face6 , FaceMap , FreeCoordinate , GridAab , GridCoordinate ,
33
33
GridPoint , GridRotation , GridSize , GridVector , Gridgid , NotNan , Rgb , Rgba ,
34
34
} ;
35
35
use all_is_cubes:: op:: Operation ;
@@ -55,6 +55,7 @@ pub(crate) static DEMO_CITY_EXHIBITS: &[Exhibit] = &[
55
55
TRANSPARENCY_SMALL ,
56
56
COLLISION ,
57
57
RESOLUTIONS ,
58
+ PROJECTILE ,
58
59
ANIMATION ,
59
60
MAKE_SOME_BLOCKS ,
60
61
DASHED_BOXES ,
@@ -866,6 +867,48 @@ fn MOVED_BLOCKS(_: Context<'_>) {
866
867
Ok ( ( space, txn) )
867
868
}
868
869
870
+ #[ macro_rules_attribute:: apply( exhibit!) ]
871
+ #[ exhibit(
872
+ name: "Projectile" ,
873
+ subtitle: "click me to launch" ,
874
+ placement: Placement :: Surface ,
875
+ ) ]
876
+ fn PROJECTILE ( ctx : Context < ' _ > ) {
877
+ let demo_blocks = BlockProvider :: < DemoBlocks > :: using ( ctx. universe ) ?;
878
+ let txn = ExhibitTransaction :: default ( ) ;
879
+
880
+ let projectile = & demo_blocks[ DemoBlocks :: Projectile ] ;
881
+
882
+ let moving_in = projectile
883
+ . clone ( )
884
+ . with_modifier ( Move :: new ( Face6 :: NY , 256 , -32 ) ) ;
885
+
886
+ // TODO: make the launcher block visibly contain and launch the projectile.
887
+ // This will require getting `Move` tick actions to cooperate with `Composite`.
888
+ let launcher = Block :: builder ( )
889
+ . display_name ( literal ! ( "Launcher" ) )
890
+ . color ( Rgb :: UNIFORM_LUMINANCE_RED . with_alpha ( notnan ! ( 1.0 ) ) )
891
+ . animation_hint ( block:: AnimationHint :: replacement (
892
+ block:: AnimationChange :: Shape ,
893
+ ) )
894
+ . activation_action ( Operation :: Neighbors (
895
+ [
896
+ // TODO: Instead of `DestroyTo`, we should have an operation that only
897
+ // succeeds if there is room to enter empty space here (if the destination
898
+ // is AIR, for now).
899
+ ( Cube :: new ( 0 , 1 , 0 ) , Operation :: DestroyTo ( moving_in) ) ,
900
+ ]
901
+ . into ( ) ,
902
+ ) )
903
+ . build ( ) ;
904
+
905
+ let space = Space :: builder ( GridAab :: ORIGIN_CUBE )
906
+ . filled_with ( launcher)
907
+ . build ( ) ;
908
+
909
+ Ok ( ( space, txn) )
910
+ }
911
+
869
912
#[ macro_rules_attribute:: apply( exhibit!) ]
870
913
#[ exhibit(
871
914
name: "Operation::Become" ,
0 commit comments