Come collision stuff and stuff aand stuff hahahah

This commit is contained in:
Victor Turgeon
2023-06-11 12:54:09 -04:00
parent 004ba54cc0
commit 5ccf6a12ea
8 changed files with 74 additions and 91 deletions

View File

@@ -1,31 +1,57 @@
using Godot;
using System.Collections.Generic;
public partial class base_building : Node3D
{
[Export]
public Node3D BlocksNode { get; set; } = null;
private building_block[] _blocks = null;
private List<building_block> _blocks = null;
[Export]
public string DisplayName { get; set; } = "base_building";
[Export]
public int KashCost { get; set; } = 1;
public bool IsPlaced { get; set; } = false;
public bool IsPlaceable
{
get
{
return false;
if (_blocks == null || _blocks.Count < 1)
return false;
foreach (building_block block in _blocks)
if (!block.IsPlaceable)
return false;
return true;
}
}
public override void _Ready()
{
if (BlocksNode != null)
{
_blocks = new List<building_block>();
foreach (Node child in BlocksNode.GetChildren())
{
_blocks.Add((building_block)child);
}
}
}
public override void _Process(double delta)
{
// if (!IsPlaced)
//{
//if (IsPlaceable)
//{
////show green highlight
//}
//else
//{
////show red highlight
//}
//}
}
}

View File

@@ -1,34 +1,18 @@
using Godot;
public enum TileTypes
{
NONE,
Grass,
Sand,
Water,
}
public partial class building_block : Node3D
{
[Export]
public RayCast3D _ray = null;
private RayCast3D _ground_ray;
[Export]
private TileTypes _compatible_tile = TileTypes.NONE;
private RayCast3D _collision_ray;
public bool IsPlaceable
{
get
{
if (_ray == null || _compatible_tile == TileTypes.NONE)
return false;
GodotObject collider = _ray.GetCollider();
GD.Print(collider);
if (collider == null)
return false;
return false;
return _collision_ray.GetCollider() == null && _ground_ray.GetCollider() != null && _ground_ray.GetCollider().GetType() == typeof(GridMap);
}
}
}

View File

@@ -1,13 +1,34 @@
[gd_scene load_steps=3 format=3 uid="uid://m3lrwoup4i4r"]
[gd_scene load_steps=4 format=3 uid="uid://m3lrwoup4i4r"]
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_3ht4p"]
[ext_resource type="PackedScene" uid="uid://cdakee12nn8un" path="res://assets/meshes/highlights_grass.tscn" id="2_m6bs4"]
[node name="grass_block" type="Node3D" node_paths=PackedStringArray("_ray")]
[sub_resource type="BoxShape3D" id="BoxShape3D_gr51o"]
size = Vector3(1.8, 2, 1.8)
[node name="grass_block" type="Node3D" node_paths=PackedStringArray("_ground_ray", "_collision_ray")]
script = ExtResource("1_3ht4p")
_ray = NodePath("RayCast3D")
_compatible_tile = 1
_ground_ray = NodePath("Area3D/GroundCheck")
_collision_ray = NodePath("Area3D/AreaCast")
[node name="highlights-grass" parent="." instance=ExtResource("2_m6bs4")]
visible = false
[node name="RayCast3D" type="RayCast3D" parent="."]
[node name="Area3D" type="Area3D" parent="."]
collision_layer = 2
collision_mask = 0
monitoring = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("BoxShape3D_gr51o")
[node name="GroundCheck" type="RayCast3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.693845, 0)
[node name="AreaCast" type="RayCast3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.23187, 0)
collision_mask = 2
hit_from_inside = true
collide_with_areas = true
collide_with_bodies = false

View File

@@ -1,13 +0,0 @@
[gd_scene load_steps=3 format=3 uid="uid://dffhktks7ro6y"]
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_xuxw4"]
[ext_resource type="PackedScene" uid="uid://bea5tpiqs0m4b" path="res://assets/meshes/highlights_sand.tscn" id="2_pmjbb"]
[node name="sand_block" type="Node3D" node_paths=PackedStringArray("_ray")]
script = ExtResource("1_xuxw4")
_ray = NodePath("RayCast3D")
_compatible_tile = 2
[node name="highlights-sand" parent="." instance=ExtResource("2_pmjbb")]
[node name="RayCast3D" type="RayCast3D" parent="."]

View File

@@ -1,13 +0,0 @@
[gd_scene load_steps=3 format=3 uid="uid://b3jpnuj1suvcj"]
[ext_resource type="Script" path="res://buildings/building_block.cs" id="1_p3ylt"]
[ext_resource type="PackedScene" uid="uid://ds0lxspxtnkcp" path="res://assets/meshes/highlights-water.glb" id="2_53d7w"]
[node name="water_block" type="Node3D" node_paths=PackedStringArray("_ray")]
script = ExtResource("1_p3ylt")
_ray = NodePath("RayCast3D")
_compatible_tile = 3
[node name="highlights-water" parent="." instance=ExtResource("2_53d7w")]
[node name="RayCast3D" type="RayCast3D" parent="."]