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; [Export] public float heightOffset = 0.6094f; protected override void _OnTrigger() { if ( container.GetChildCount() >= maxPigs ) { this.LogInfo( "Too many Pigs" ); return; } // this.LogInfo( "Creating Pigs" ); var n = packedScene.Instantiate() as Node3D; if ( n == null ) { this.LogInfo( n ); return; } container.AddChild( n ); var pig = n.Get(); Trigger( pig.onSpawn ); var player = Unique.Get(); n.GlobalPosition = ( player.transformSource.GlobalPosition + GodotRandom.Get().InCube() * radius ).SetY( heightOffset ); } } }