Beispiel #1
0
        public GameObject Spawn()
        {
            var obj = GenerateSpawnObject();

            Start(obj);

            GameObject.Construct(obj);

            ActiveSpawns.Add(obj);

            Listen(obj.OnDestroyed, () =>
            {
                ActiveSpawns.Remove(obj);
            });

            if (obj.TryGetComponent <DestructibleComponent>(out var destructibleComponent))
            {
                Listen(destructibleComponent.OnSmashed, async(smasher, lootOwner) =>
                {
                    Destroy(obj);

                    await Task.Delay(RespawnTime);

                    Spawn();
                });
            }

            return(obj);
        }
Beispiel #2
0
        public GameObject Spawn()
        {
            var obj = GetSpawnObject();

            Start(obj);

            ActiveSpawns.Add(obj);

            Listen(obj.OnDestroyed, () => { ActiveSpawns.Remove(obj); });

            return(obj);
        }