using Godot; using System.Collections; using System.Collections.Generic; using Godot.Collections; namespace Rokojori { [GlobalClass,Tool] public partial class Shooter:Action { [Export] public Node pigContainer; [Export] public float startChance = 10; [Export] public float endChance = 80; [Export] public float duration = 60; [Export] public Node3D bulletsContainer; protected override void _OnTrigger() { var random = GodotRandom.Get(); var edr = Unique.Get(); var chance = MathX.MapClamped( edr.secondsPlaying, 0, duration, startChance, endChance ); if ( ! random.Chance( chance ) ) { return; } var pigContainers = pigContainer.GetDirectChildren(); var selected = GodotRandom.Get().From( pigContainers ); if ( selected == null ) { return; } var pig = selected.Get(); pig.Shoot( bulletsContainer ); } } }