43 lines
836 B
C#
43 lines
836 B
C#
using Godot;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Godot.Collections;
|
|
|
|
namespace Rokojori
|
|
{
|
|
[GlobalClass,Tool]
|
|
public partial class PigCreator:Action
|
|
{
|
|
[Export]
|
|
public float radius = 100;
|
|
|
|
[Export]
|
|
public PackedScene packedScene;
|
|
|
|
[Export]
|
|
public Node container;
|
|
|
|
[Export]
|
|
public int maxPigs = 10;
|
|
|
|
protected override void _OnTrigger()
|
|
{
|
|
if ( container.GetChildCount() >= maxPigs )
|
|
{
|
|
return;
|
|
}
|
|
|
|
var n = packedScene.Instantiate() as Node3D;
|
|
|
|
if ( n == null )
|
|
{
|
|
this.LogInfo( n );
|
|
return;
|
|
}
|
|
|
|
container.AddChild( n );
|
|
|
|
n.GlobalPosition = GodotRandom.Get().InCube() * new Vector3( 1, 0, 1 ) * radius + new Vector3( 0, 0.5f, 0 );
|
|
}
|
|
}
|
|
} |