Example #1
0
    public override void _Ready()
    {
        SpatialControl parent = (SpatialControl)GetParent();

        parent.Connect(nameof(SpatialControl.SizeChanged), this, nameof(OnSizeChanged),
                       new Godot.Collections.Array {
            parent
        });

        shape = GetNode <CollisionShape>("CollisionShape");
    }
Example #2
0
 //NOT an override of Godot.Object._init
 //That doesn't take arguments and this thing needs a reference to its owner.
 public void Init(SpatialControl o)
 {
     owner = o;
     owner.Connect(nameof(SpatialControl.OnPredelete), this, nameof(OnOwnerDelete));
     // p.GetTree().GetEditedSceneRoot();
     if (owner.GetParent() is SpatialControl p)
     {
         parent = p;
         parent.Connect(nameof(SpatialControl.SizeChanged), this, nameof(OnReferenceSizeChanged),
                        new Godot.Collections.Array {
             parent
         });
         OnReferenceSizeChanged(parent.Size, parent);
     }
 }
Example #3
0
 private void RegisterChild(SpatialControl child)
 {
     GD.Print("Registering: ", child.Name, "; ", child.GetIndex());
     if (child.GetIndex() == 0)
     {
         child.Translation = new Vector3(child.Translation.x, 0, child.Translation.z);
     }
     else
     {
         var previousSC = (SpatialControl)GetChild(child.GetIndex() - 1);
         SetBelow(previousSC, child);
     }
     child.Connect(nameof(SizeChanged), this, nameof(OnChildSizeChanged),
                   new Godot.Collections.Array {
         child
     });
     OnChildSizeChanged(Vector2.Zero, child);
 }