Beispiel #1
0
        public static void SpawnFoam(string entityPrototype, EntityCoordinates coords, Solution?contents, int amount, float duration, float spreadDelay,
                                     float removeDelay, SoundSpecifier sound, IEntityManager?entityManager = null)
        {
            entityManager ??= IoCManager.Resolve <IEntityManager>();
            var ent = entityManager.SpawnEntity(entityPrototype, coords.SnapToGrid());

            var areaEffectComponent = entityManager.GetComponentOrNull <FoamSolutionAreaEffectComponent>(ent);

            if (areaEffectComponent == null)
            {
                Logger.Error("Couldn't get AreaEffectComponent from " + entityPrototype);
                IoCManager.Resolve <IEntityManager>().QueueDeleteEntity(ent);
                return;
            }

            if (contents != null)
            {
                areaEffectComponent.TryAddSolution(contents);
            }
            areaEffectComponent.Start(amount, duration, spreadDelay, removeDelay);

            SoundSystem.Play(sound.GetSound(), Filter.Pvs(ent), ent, AudioHelpers.WithVariation(0.125f));
        }