character now teleports to specified marker when switching maps
							parent
							
								
									8d20d96059
								
							
						
					
					
						commit
						9de1b41acd
					
				|  | @ -29,20 +29,13 @@ public partial class ConnectorBox : Area2D | |||
|     [Export] | ||||
|     public InteractionTrigger InteractionTrigger { get; set; } | ||||
| 
 | ||||
|     [Export] | ||||
|     public CollisionShape2D Collision { get; set; } | ||||
| 
 | ||||
|     private Player _player = null; | ||||
| 
 | ||||
|     public override void _Ready() | ||||
|     { | ||||
|         if (Collision is null) | ||||
|         { | ||||
|             throw new NullReferenceException("Collision not specified"); | ||||
|         } | ||||
| 
 | ||||
|         BodyEntered += (Node2D body) => | ||||
|         { | ||||
|             GD.Print(body.Name + " entered"); | ||||
|             if (body is Player && InteractionTrigger is null) | ||||
|             { | ||||
|                 OnInteraction(); | ||||
|  |  | |||
|  | @ -29,13 +29,11 @@ offset_bottom = -28.0 | |||
| [node name="Label" parent="InteractionTrigger/Popup" index="0"] | ||||
| text = "Enter" | ||||
| 
 | ||||
| [node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("InteractionTrigger", "Collision")] | ||||
| [node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("InteractionTrigger")] | ||||
| script = ExtResource("3_4rsih") | ||||
| ToArea = "res://Scenes/Maps/Arena.tscn" | ||||
| ToConnector = "entrance" | ||||
| Identifier = "arena_entrance" | ||||
| ToConnector = "Entrance" | ||||
| InteractionTrigger = NodePath("../InteractionTrigger") | ||||
| Collision = NodePath("CollisionShape2D") | ||||
| 
 | ||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] | ||||
| shape = SubResource("RectangleShape2D_djn8q") | ||||
|  |  | |||
|  | @ -1832,7 +1832,7 @@ background_mode = 3 | |||
| glow_enabled = true | ||||
| glow_hdr_threshold = 1.4 | ||||
| 
 | ||||
| [node name="TileMap" type="TileMap" node_paths=PackedStringArray("Entities", "Areas", "Spawners")] | ||||
| [node name="TileMap" type="TileMap" node_paths=PackedStringArray("Entities", "Areas", "Spawners", "Markers")] | ||||
| y_sort_enabled = true | ||||
| texture_filter = 3 | ||||
| tile_set = SubResource("TileSet_18c7j") | ||||
|  | @ -1878,11 +1878,7 @@ script = ExtResource("2_4m0a1") | |||
| Entities = NodePath("Entities") | ||||
| Areas = NodePath("Areas") | ||||
| Spawners = NodePath("Spawners") | ||||
| CameraLowerBound = null | ||||
| CameraUpperBound = null | ||||
| ClearColor = null | ||||
| AreaName = null | ||||
| MapName = null | ||||
| Markers = NodePath("Markers") | ||||
| 
 | ||||
| [node name="CanvasModulate" type="CanvasModulate" parent="."] | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,6 +14,9 @@ public partial class Map : TileMap | |||
|     [Export] | ||||
|     public Node2D Spawners { get; set; } | ||||
| 
 | ||||
|     [Export] | ||||
|     public Node2D Markers { get; set; } | ||||
| 
 | ||||
|     [Export] | ||||
|     public Vector2 CameraLowerBound { get; set; } | ||||
| 
 | ||||
|  |  | |||
											
												
													File diff suppressed because one or more lines are too long
												
											
										
									
								
											
												
													File diff suppressed because one or more lines are too long
												
											
										
									
								|  | @ -27,6 +27,7 @@ public partial class LocationDisplay : CenterContainer | |||
|         _subtitle.Visible = map.AreaName != map.MapName; | ||||
|         _mapName.Text = map.MapName; | ||||
|         _subtitle.Text = map.AreaName; | ||||
|         _animPlayer.Stop(); | ||||
|         _animPlayer.Play("show"); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -97,7 +97,7 @@ public partial class World : Node | |||
|         EventBus = this.GetEventBus(); | ||||
|         EventBus.RequestMoveToArea += (Events.RequestAreaArgs args) => | ||||
|         { | ||||
|             MoveToArea(args.Area, args.Connector); | ||||
|             CallDeferred(MethodName.MoveToArea, args.Area, args.Connector); | ||||
|         }; | ||||
|         EventBus.RegisteredBoss += RegisterBoss; | ||||
|         EventBus.DeregisteredBoss += DeregisterBoss; | ||||
|  | @ -138,14 +138,17 @@ public partial class World : Node | |||
|     { | ||||
|         GD.Print("Loading map " + map.Name); | ||||
| 
 | ||||
|         var root = GetTree().Root; | ||||
| 
 | ||||
|         if (CurrentMap is not null) | ||||
|         { | ||||
|             _maps.Update(CurrentMap.SceneFilePath); | ||||
|             CurrentMap.Entities.RemoveChild(CurrentPlayer); | ||||
|             GetTree().Root.RemoveChild(CurrentMap); | ||||
|             root.RemoveChild(CurrentMap); | ||||
|             CurrentMap.Active = false; | ||||
|         } | ||||
| 
 | ||||
|         GetTree().Root.AddChild(map); | ||||
|         root.AddChild(map); | ||||
|         InitTilemap(map); | ||||
| 
 | ||||
|         CurrentMap = map; | ||||
|  | @ -168,11 +171,6 @@ public partial class World : Node | |||
| 
 | ||||
|     public void LoadScene(PackedScene scene) | ||||
|     { | ||||
|         if (CurrentMap is not null) | ||||
|         { | ||||
|             _maps.Update(CurrentMap.SceneFilePath); | ||||
|         } | ||||
| 
 | ||||
|         Map map; | ||||
|         string path = scene.ResourcePath; | ||||
| 
 | ||||
|  | @ -251,19 +249,8 @@ public partial class World : Node | |||
| 
 | ||||
|     private void MovePlayerToConnector(string name) | ||||
|     { | ||||
|         // find the first connector with the specified name | ||||
|         // TODO: replace this with event buses | ||||
|         //var connector = CurrentMap.Areas.GetChildren().First((child) => | ||||
|         //{ | ||||
|         //    if (child is BoundingBoxes.ConnectorBox connector) | ||||
|         //    { | ||||
|         //        return connector.Identifier == name; | ||||
|         //    } | ||||
|         //    return false; | ||||
|         //}) as BoundingBoxes.ConnectorBox; | ||||
| 
 | ||||
|         //CurrentPlayer.GlobalPosition = connector.GlobalPosition; | ||||
|         CurrentPlayer.GlobalPosition = Vector2.Zero; | ||||
|         var marker = CurrentMap.Markers.GetNode<Marker2D>(name); | ||||
|         CurrentPlayer.GlobalPosition = marker?.GlobalPosition ?? Vector2.Zero; | ||||
|     } | ||||
| 
 | ||||
|     public void MoveToArea(string path, string connector) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue