protected override void PerformingTick()
        {
            base.PerformingTick();

            bool firstTime = false;
            if (region == null)
            {
                region = Game.Instance.Map.GetRegion(Region);
                firstTime = true;
            }

            bool old = IsInRegion;
            IsInRegion = region.BoundingRegion.GetNodeAt(Game.Instance.Map.MainCharacter.Translation) != null;

            if (!old && IsInRegion)
                MainCharEntersRegion();
            else if (old && !IsInRegion)
                MainCharExitsRegion();

            if (firstTime && IsNotInRegionScript != null && !IsInRegion)
                IsNotInRegionScript.TryStartPerform();
        }
        protected override void PerformingTick()
        {
            base.PerformingTick();

            for (int i = 0; i < frameSpawnN; i++)
                SpawnOneUnit();
            frameSpawnN = 0;

            if (!(SkipFirstTick && isFirstTick))
            {
                if (point == null && region == null)
                {
                    region = Game.Instance.Map.GetRegion(Point);
                    if (region == null)
                        point = Game.Instance.Scene.GetByName(Point);
                }

                if (region != null && Distribution == SpawnDistribution.GroupRandom)
                {
                    if (Distribution == SpawnDistribution.GroupRandom)
                        node = region.BoundingRegion.GetRandomNode(Game.Instance.SpawnRandomizer);
                    else
                        nodeI = 0;
                }

                int n = SpawnMinPerRound + Game.Instance.SpawnRandomizer.Next(SpawnMaxPerRound - SpawnMinPerRound);
                n = Math.Min(n, SpawnCount - spawnedCount);
                if (LimitSimultaneouslyAlive > 0)
                {
                    List<Destructible> alive=  new List<Destructible>();
                    foreach (var v in spawns)
                        if (v.State == UnitState.Alive)
                            alive.Add(v);
                    spawns = alive;
                    n = Common.Math.Clamp(n, 0, Math.Max(0, LimitSimultaneouslyAlive - alive.Count));
                }
                spawnedCount += n;
                frameSpawnN = n;

                if (n == 0 && EndPerformWhenAllUnitsHaveSpawned)
                    TryEndPerform(false);
            }
            isFirstTick = false;
            TickPeriod = MinPeriod + (float)Game.Instance.SpawnRandomizer.NextDouble() * (MaxPeriod - MinPeriod);
        }
 protected override void StartEffectivePerform()
 {
     base.StartEffectivePerform();
     region = Game.Instance.Map.GetRegion(AllowedRegion);
 }