Exemplo n.º 1
0
        private void RefreshState()
        {
            if (State == LevelState.None)
            {
                if (IsLevelLoaded)
                {
                    State = LevelState.Playing;
                }

                return;
            }

            if (State == LevelState.Playing)
            {
                if (!IsLevelLoaded)
                {
                    State = LevelState.None;
                    return;
                }

                if (Emitters.Any((e) => e.LitAbsorber != null) && Entities.All((e) => e.IsStationary))
                {
                    State = LevelState.Won;
                }
            }
        }
Exemplo n.º 2
0
        public void Update(float frameTime)
        {
            foreach (var emitter in Emitters)
            {
                emitter.Update(frameTime);
            }

            foreach (var particleOperator in Operators)
            {
                particleOperator.Update(particles, frameTime);
            }

            // Remove all dead particles
            particles = particles.Where(p => p.Lifetime > 0).ToList();

            foreach (var childParticleRenderer in childParticleRenderers)
            {
                childParticleRenderer.Update(frameTime);
            }

            // Restart if all emitters are done and all particles expired
            if (Emitters.All(e => e.IsFinished) && particles.Count == 0)
            {
                Restart();
            }
        }
Exemplo n.º 3
0
 public Shotgun(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 96, 96, 12, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X - EMITTERS_OFFSET, Sprite.Position.Y)));
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X + EMITTERS_OFFSET, Sprite.Position.Y)));
     ShotgunPump = game.SfxMgr.Find("ShotgunPump");
 }
        public RobustXamlILCompiler(TransformerConfiguration configuration, XamlLanguageEmitMappings <IXamlILEmitter, XamlILNodeEmitResult> emitMappings, bool fillWithDefaults) : base(configuration, emitMappings, fillWithDefaults)
        {
            Transformers.Add(new AddNameScopeRegistration());
            Transformers.Add(new RobustMarkRootObjectScopeNode());

            Emitters.Add(new AddNameScopeRegistration.Emitter());
            Emitters.Add(new RobustMarkRootObjectScopeNode.Emitter());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Register an event with an action
        /// </summary>
        /// <param name="event"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public Emitter On(string @event, Action body)
        {
            var e = new Emitter(@event, body);

            Emitters.TryAdd(e.Event, e);

            return(e);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Register an event with an action with a paramter
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="event"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public Emitter <T> On <T>(string @event, Action <T> body)
        {
            var e = new Emitter <T>(@event, body);

            Emitters.TryAdd(e.Event, e);

            return(e);
        }
Exemplo n.º 7
0
        private void SetAlarm()
        {
            NWCreature self = ((NWCreature)fSelf);

            if ((Townsman) && !self.Mercenary)
            {
                Emitters.AddEmitter(EmitterKind.ek_GuardAlarm, self.UID_Renamed, self.Location, 10f, 2, true);
            }
        }
Exemplo n.º 8
0
        public WinUIXamlILCompiler(TransformerConfiguration configuration, XamlLanguageEmitMappings <IXamlILEmitter, XamlILNodeEmitResult> emitMappings) : base(configuration, emitMappings, true)
        {
            this.AddWinUIPhases();

            Emitters.Add(new XamlDirectConversionEmitter());
            Emitters.Add(new XamlDirectNewObjectEmitter());
            Emitters.Add(new XamlDirectSetterEmitter());
            Emitters.Add(new XamlDirectAdderSetterEmitter());
            Emitters.Add(new XamlDirectEventSetterEmitter());
        }
        private AvaloniaXamlIlCompiler(TransformerConfiguration configuration, XamlLanguageEmitMappings <IXamlILEmitter, XamlILNodeEmitResult> emitMappings)
            : base(configuration, emitMappings, true)
        {
            _configuration = configuration;

            void InsertAfter <T>(params IXamlAstTransformer[] t)
            => Transformers.InsertRange(Transformers.FindIndex(x => x is T) + 1, t);

            void InsertBefore <T>(params IXamlAstTransformer[] t)
            => Transformers.InsertRange(Transformers.FindIndex(x => x is T), t);


            // Before everything else

            Transformers.Insert(0, new XNameTransformer());
            Transformers.Insert(1, new IgnoredDirectivesTransformer());
            Transformers.Insert(2, _designTransformer  = new AvaloniaXamlIlDesignPropertiesTransformer());
            Transformers.Insert(3, _bindingTransformer = new AvaloniaBindingExtensionTransformer());


            // Targeted
            InsertBefore <PropertyReferenceResolver>(
                new AvaloniaXamlIlResolveClassesPropertiesTransformer(),
                new AvaloniaXamlIlTransformInstanceAttachedProperties(),
                new AvaloniaXamlIlTransformSyntheticCompiledBindingMembers());
            InsertAfter <PropertyReferenceResolver>(
                new AvaloniaXamlIlAvaloniaPropertyResolver(),
                new AvaloniaXamlIlReorderClassesPropertiesTransformer()
                );

            InsertBefore <ContentConvertTransformer>(
                new AvaloniaXamlIlBindingPathParser(),
                new AvaloniaXamlIlSelectorTransformer(),
                new AvaloniaXamlIlControlTemplateTargetTypeMetadataTransformer(),
                new AvaloniaXamlIlPropertyPathTransformer(),
                new AvaloniaXamlIlSetterTransformer(),
                new AvaloniaXamlIlConstructorServiceProviderTransformer(),
                new AvaloniaXamlIlTransitionsTypeMetadataTransformer(),
                new AvaloniaXamlIlResolveByNameMarkupExtensionReplacer()
                );

            // After everything else
            InsertBefore <NewObjectTransformer>(
                new AddNameScopeRegistration(),
                new AvaloniaXamlIlDataContextTypeTransformer(),
                new AvaloniaXamlIlBindingPathTransformer(),
                new AvaloniaXamlIlCompiledBindingsMetadataRemover()
                );

            Transformers.Add(new AvaloniaXamlIlMetadataRemover());
            Transformers.Add(new AvaloniaXamlIlRootObjectScope());

            Emitters.Add(new AvaloniaNameScopeRegistrationXamlIlNodeEmitter());
            Emitters.Add(new AvaloniaXamlIlRootObjectScope.Emitter());
        }
Exemplo n.º 10
0
        public static void SetEmitterSignal(int emitterId, int signal)
        {
            var emitter = Emitters.FirstOrDefault(e => e.Id == emitterId);

            if (emitter == null)
            {
                return;
            }

            emitter.Signal = signal;
            NotifyReceivers(emitter.EmitChannel, signal);
        }
Exemplo n.º 11
0
        public static int RegisterEmitter(SignalEmitter emitter)
        {
            var newId = 0;

            if (Emitters.Count > 0)
            {
                newId = Emitters.Max(e => e.Id) + 1;
            }

            emitter.Id = newId;
            Emitters.Add(emitter);

            return(emitter.Id);
        }
Exemplo n.º 12
0
        internal void HandleMessage(byte[] message, IPAddress endpoint)
        {
            SocketMessage msg    = Serializer.Deserialize <SocketMessage>(message);
            IPEndPoint    ipPort = new IPEndPoint(endpoint, msg.CallbackPort);

            if (Emitters.ContainsKey(msg.Event))
            {
                lock (_lockEmitter)
                {
                    CurrentEmitter = Emitters[msg.Event];
                    CurrentEmitter.Invoke(msg, ipPort);
                    CurrentEmitter = null;
                }
            }
        }
Exemplo n.º 13
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _particle.ReadString(reader);
                for (x = 0; (x < _emitters.Count); x = (x + 1))
                {
                    Emitters.Add(new ParticleSystemEmitterDefinitionBlockBlock());
                    Emitters[x].Read(reader);
                }
                for (x = 0; (x < _emitters.Count); x = (x + 1))
                {
                    Emitters[x].ReadChildData(reader);
                }
            }
Exemplo n.º 14
0
        internal void HandleMessage(string message, IPAddress endpoint)
        {
            var           bytes  = System.Text.Encoding.UTF8.GetBytes(message);
            SocketMessage msg    = Serializer.Deserialize <SocketMessage>(bytes);
            IPEndPoint    ipPort = new IPEndPoint(endpoint, msg.CallbackPort);

            if (Emitters.ContainsKey(msg.Event))
            {
                lock (_lockEmitter)
                {
                    CurrentEmitter = Emitters[msg.Event];
                    CurrentEmitter.Invoke(msg, ipPort);
                    CurrentEmitter = null;
                }
            }
        }
Exemplo n.º 15
0
        internal static ParticleEmitter TryGet(IntPtr handle)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (handle == IntPtr.Zero)
            {
                throw new NullPointerException();
            }
#endif

            var particleEmitter = Emitters.FirstOrDefault(x => x.Handle == handle);
            if (particleEmitter == null)
            {
                particleEmitter = new ParticleEmitter(handle);
                Emitters.Add(particleEmitter);
            }

            return(particleEmitter);
        }
Exemplo n.º 16
0
        public virtual void Emit(IEmitContext context, IProject project)
        {
            if (Configuration.GetBool(Constants.Configuration.InstallPackage.ShowDiagnostics))
            {
                var treatWarningsAsErrors = Configuration.GetBool(Constants.Configuration.CheckProject.TreatWarningsAsErrors);
                Trace.TraceDiagnostics(project.Diagnostics, treatWarningsAsErrors);
            }

            project.Lock(Locking.ReadOnly);

            var emitters = Emitters.OrderBy(e => e.Sortorder).ToList();
            var retries  = new List <Tuple <IProjectItem, Exception> >();

            Emit(context, project, emitters, retries);
            EmitRetry(context, emitters, retries);

            project.Lock(Locking.ReadWrite);
        }
Exemplo n.º 17
0
        public static void ChangeReceiverChannel(int receiverId, int channel)
        {
            var receiver = Receivers.FirstOrDefault(r => r.Id == receiverId);

            if (receiver == null)
            {
                return;
            }

            var emittersOnChannel =
                Emitters.Where(e => e.EmitChannel == channel).ToList();

            var signal = emittersOnChannel.Any() ? emittersOnChannel.First().Signal : 0;

            NotifyReceivers(channel, signal);

            receiver.Channel = channel;
        }
Exemplo n.º 18
0
        public static void ChangeEmitterChannel(int emitterId, int channel)
        {
            var emitter = Emitters.FirstOrDefault(e => e.Id == emitterId);

            if (emitter == null)
            {
                return;
            }

            var othersOnChannel =
                Emitters.Where(e => e.Id != emitterId && e.EmitChannel == emitter.EmitChannel).ToList();

            var leaveSignal = othersOnChannel.Any() ? othersOnChannel.First().Signal : 0;

            NotifyReceivers(emitter.EmitChannel, leaveSignal);

            emitter.EmitChannel = channel;
            NotifyReceivers(emitter.EmitChannel, emitter.Signal);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Closes the socket and all emitters.
 /// </summary>
 public void Close()
 {
     Emitters.Clear();
     Handler.Close();
 }
Exemplo n.º 20
0
 public void OnDestroy()
 {
     Emitters.Remove(this);
 }
Exemplo n.º 21
0
 public SMG(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 1000, 320, 32, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, Sprite.Position));
 }
Exemplo n.º 22
0
        public static void ProcessActions(RenderTime elapsedTime)
        {
            TotalTick += (ulong)elapsedTime.Ticks;

            outContainer.ProcessDelay(elapsedTime);

            //update music
            if (NextSong != null)
            {
                MusicFadeTime -= elapsedTime;
                if (MusicFadeTime.Ticks <= 0)
                {
                    AudioManager.BGM.Stop();
                    if (System.IO.File.Exists(NextSong))
                    {
                        Song = NextSong;
                        AudioManager.BGM.SetBGM(Song);
                        AudioManager.BGM.Play();
                        NextSong = null;
                    }
                    else
                    {
                        Song = "";
                    }
                }
                else
                {
                    AudioManager.BGM.SetVolume((float)MusicFadeTime.Ticks / (float)MUSIC_FADE_TOTAL.Ticks);
                }
            }

            //update fade
            if (CurrentFade != FadeType.None)
            {
                FadeTime -= elapsedTime;
                if (FadeTime.Ticks <= 0)
                {
                    CurrentFade = FadeType.None;
                }
            }

            //update the player
            foreach (PlayerSprite player in Players)
            {
                player.Process(elapsedTime);
            }

            //update Items
            foreach (ItemAnim item in Items)
            {
                item.Process(elapsedTime);
            }

            //update Npcs
            foreach (NpcSprite npc in Npcs)
            {
                npc.Process(elapsedTime);
            }

            for (int n = (int)EffectPriority.Ground; n <= (int)EffectPriority.Overlay; n++)
            {
                for (int i = Effects[(EffectPriority)n].Count - 1; i >= 0; i--)
                {
                    Effects[(EffectPriority)n][i].Process(elapsedTime);
                    if (Effects[(EffectPriority)n][i].ActionDone)
                    {
                        Effects[(EffectPriority)n].RemoveAt(i);
                    }
                }
            }

            for (int i = Emitters.Count - 1; i >= 0; i--)
            {
                Emitters[i].Process(elapsedTime);
                if (Emitters[i].ActionDone)
                {
                    Emitters.RemoveAt(i);
                }
            }


            //update the camera, reliant on the player
            CamOffset = FocusedCharacter.TileOffset;
        }
Exemplo n.º 23
0
 public bool IsFinished()
 => Emitters.All(e => e.IsFinished) &&
 particles.Count == 0 &&
 childParticleRenderers.All(r => r.IsFinished());
Exemplo n.º 24
0
 public static void ResetEmittersList()
 {
     Emitters.Clear();
 }
Exemplo n.º 25
0
 public void Awake()
 {
     Emitters.Add(this);
     Source.spatialBlend = 0.0f;
 }
Exemplo n.º 26
0
        internal void PurgeAll()
        {
            PurgedAll = true;
            FutureEvents.Purge((int)Tick);


            foreach (var comp in CompsToStart)
            {
                if (comp?.Platform != null)
                {
                    CloseComps(comp.MyCube);
                }
            }

            foreach (var readd in CompReAdds)
            {
                if (!readd.Ai.Closed)
                {
                    readd.Ai.AiForceClose();
                }
                if (readd.Comp?.Platform != null)
                {
                    CloseComps(readd.Comp.MyCube);
                }
            }

            foreach (var comp in CompsDelayed)
            {
                if (comp?.Platform != null)
                {
                    CloseComps(comp.MyCube);
                }
            }

            foreach (var gridAi in DelayedAiClean)
            {
                if (!gridAi.Closed)
                {
                    gridAi.AiForceClose();
                }
            }

            PlatFormPool.Clean();
            CompsToStart.ClearImmediate();
            DelayedAiClean.ClearImmediate();

            CompsDelayed.Clear();
            CompReAdds.Clear();
            GridAiPool.Clean();


            PurgeTerminalSystem(this);
            HudUi.Purge();
            TerminalMon.Purge();
            foreach (var reports in Reporter.ReportData.Values)
            {
                foreach (var report in reports)
                {
                    report.Clean();
                    Reporter.ReportPool.Return(report);
                }
                reports.Clear();
            }
            Reporter.ReportData.Clear();
            Reporter.ReportPool.Clean();

            PacketsToClient.Clear();
            PacketsToServer.Clear();

            AcqManager.Clean();

            CleanSounds(true);

            foreach (var e in Emitters)
            {
                e.StopSound(true);
            }
            foreach (var e in Av.HitEmitters)
            {
                e.StopSound(true);
            }
            foreach (var e in Av.FireEmitters)
            {
                e.StopSound(true);
            }
            foreach (var e in Av.TravelEmitters)
            {
                e.StopSound(true);
            }

            Emitters.Clear();
            Av.HitEmitters.Clear();
            Av.FireEmitters.Clear();
            Av.TravelEmitters.Clear();

            foreach (var item in EffectedCubes)
            {
                var cubeid     = item.Key;
                var blockInfo  = item.Value;
                var functBlock = blockInfo.FunctBlock;

                if (functBlock == null || functBlock.MarkedForClose)
                {
                    _effectPurge.Enqueue(cubeid);
                    continue;
                }

                functBlock.EnabledChanged -= ForceDisable;
                functBlock.Enabled         = blockInfo.FirstState;
                functBlock.SetDamageEffect(false);
                if (HandlesInput)
                {
                    functBlock.AppendingCustomInfo -= blockInfo.AppendCustomInfo;
                }
                _effectPurge.Enqueue(cubeid);
            }

            while (_effectPurge.Count != 0)
            {
                EffectedCubes.Remove(_effectPurge.Dequeue());
            }

            Av.Glows.Clear();
            Av.AvShotPool.Clean();

            DeferedUpBlockTypeCleanUp(true);
            BlockTypeCleanUp.Clear();

            foreach (var map in GridToInfoMap.Keys)
            {
                RemoveGridFromMap(map);
            }

            GridToInfoMap.Clear();
            GridMapPool.Clean();

            DirtyGridsTmp.Clear();

            foreach (var structure in WeaponPlatforms.Values)
            {
                foreach (var system in structure.WeaponSystems)
                {
                    system.Value.PreFirePairs.Clear();
                    system.Value.FireWhenDonePairs.Clear();
                    system.Value.FirePerShotPairs.Clear();
                    system.Value.RotatePairs.Clear();
                    system.Value.ReloadPairs.Clear();
                    foreach (var ammo in system.Value.AmmoTypes)
                    {
                        ammo.AmmoDef.Const.PrimeEntityPool?.Clean();
                        ammo.AmmoDef.Const.HitDefaultSoundPairs.Clear();
                        ammo.AmmoDef.Const.HitVoxelSoundPairs.Clear();
                        ammo.AmmoDef.Const.HitShieldSoundPairs.Clear();
                        ammo.AmmoDef.Const.HitFloatingSoundPairs.Clear();
                        ammo.AmmoDef.Const.HitPlayerSoundPairs.Clear();
                        ammo.AmmoDef.Const.TravelSoundPairs.Clear();
                        ammo.AmmoDef.Const.CustomSoundPairs.Clear();
                    }
                }

                structure.WeaponSystems.Clear();
            }
            WeaponPlatforms.Clear();

            foreach (var gridToMap in GridToBlockTypeMap)
            {
                foreach (var map in gridToMap.Value)
                {
                    ConcurrentListPool.Return(map.Value);
                }
                gridToMap.Value.Clear();
                BlockTypePool.Return(gridToMap.Value);
            }
            GridToBlockTypeMap.Clear();

            foreach (var playerGrids in PlayerEntityIdInRange)
            {
                playerGrids.Value.Clear();
            }

            PlayerEntityIdInRange.Clear();
            DirtyGridInfos.Clear();

            DsUtil.Purge();
            DsUtil2.Purge();

            ShootingWeapons.Clear();
            WeaponToPullAmmo.Clear();
            AmmoToPullQueue.Clear();
            ChargingWeaponsIndexer.Clear();
            WeaponsToRemoveAmmoIndexer.Clear();
            ChargingWeapons.Clear();
            Hits.Clear();
            HomingWeapons.Clear();
            GridToMasterAi.Clear();
            Players.Clear();
            IdToCompMap.Clear();
            AllArmorBaseDefinitions.Clear();
            HeavyArmorBaseDefinitions.Clear();
            AllArmorBaseDefinitions.Clear();
            AcquireTargets.Clear();
            LargeBlockSphereDb.Clear();
            SmallBlockSphereDb.Clear();
            AnimationsToProcess.Clear();
            _subTypeIdToWeaponDefs.Clear();
            WeaponDefinitions.Clear();
            SlimsSortedList.Clear();
            _destroyedSlims.Clear();
            _destroyedSlimsClient.Clear();
            _slimHealthClient.Clear();
            _slimsSet.Clear();
            _turretDefinitions.Clear();
            _tmpNearByBlocks.Clear();

            foreach (var av in Av.AvShots)
            {
                av.GlowSteps.Clear();
                Av.AvShotPool.Return(av);
            }
            Av.AvShotPool.Clean();
            Av.AvBarrels1.Clear();
            Av.AvBarrels2.Clear();
            Av.AvShots.Clear();
            Av.HitSounds.Clear();

            foreach (var errorpkt in ClientSideErrorPkt)
            {
                errorpkt.Packet.CleanUp();
            }
            ClientSideErrorPkt.Clear();

            GridEffectPool.Clean();
            GridEffectsPool.Clean();
            BlockTypePool.Clean();
            ConcurrentListPool.Clean();

            TargetInfoPool.Clean();
            PacketObjPool.Clean();

            InventoryMoveRequestPool.Clean();
            WeaponCoreBlockDefs.Clear();
            VanillaIds.Clear();
            VanillaCoreIds.Clear();
            WeaponCoreFixedBlockDefs.Clear();
            WeaponCoreTurretBlockDefs.Clear();
            VoxelCaches.Clear();
            ArmorCubes.Clear();

            foreach (var p in Projectiles.ProjectilePool)
            {
                p.Info?.AvShot?.AmmoEffect?.Stop();
            }

            Projectiles.ShrapnelToSpawn.Clear();
            Projectiles.ShrapnelPool.Clean();
            Projectiles.FragmentPool.Clean();
            Projectiles.ActiveProjetiles.Clear();
            Projectiles.ProjectilePool.Clear();
            Projectiles.HitEntityPool.Clean();
            Projectiles.VirtInfoPool.Clean();

            DbsToUpdate.Clear();
            GridTargetingAIs.Clear();

            DsUtil          = null;
            DsUtil2         = null;
            SlimsSortedList = null;
            Settings        = null;
            StallReporter   = null;
            TerminalMon     = null;
            Physics         = null;
            Camera          = null;
            Projectiles     = null;
            TrackingAi      = null;
            UiInput         = null;
            TargetUi        = null;
            Placer          = null;
            TargetGps       = null;
            SApi.Unload();
            SApi                = null;
            Api                 = null;
            ApiServer           = null;
            Reporter            = null;
            WeaponDefinitions   = null;
            AnimationsToProcess = null;
            ProjectileTree.Clear();
            ProjectileTree     = null;
            Av                 = null;
            HudUi              = null;
            AllDefinitions     = null;
            SoundDefinitions   = null;
            ActiveCockPit      = null;
            ActiveControlBlock = null;
            ControlledEntity   = null;
            TmpStorage         = null;
        }
Exemplo n.º 27
0
        public static void UnregisterEmitter(int emitterId)
        {
            var emitter = Emitters.FirstOrDefault(e => e.Id == emitterId);

            Emitters.Remove(emitter);
        }