Exemplo n.º 1
0
        public void OnMessage(NetMessage m)
        {
            switch (m)
            {
            case NMRemovedParticles _:
                NMRemovedParticles removedParticles = m as NMRemovedParticles;
                for (int index = 0; index < removedParticles.count; ++index)
                {
                    ushort          key             = removedParticles.data.ReadUShort();
                    PhysicsParticle physicsParticle = (PhysicsParticle)null;
                    if (this._particles.TryGetValue(key, out physicsParticle))
                    {
                        this.removedParticles.Add(physicsParticle);
                        this.removedParticleIndexes.Add(physicsParticle.netIndex);
                    }
                }
                break;

            case NMParticles _:
                NMParticles nmParticles = m as NMParticles;
                if ((int)nmParticles.levelIndex != (int)DuckNetwork.levelIndex)
                {
                    break;
                }
                for (int index = 0; index < nmParticles.count; ++index)
                {
                    System.Type     type            = nmParticles.type;
                    ushort          key             = nmParticles.data.ReadUShort();
                    PhysicsParticle physicsParticle = (PhysicsParticle)null;
                    if (!this._particles.TryGetValue(key, out physicsParticle))
                    {
                        if (type == typeof(SmallFire))
                        {
                            physicsParticle = (PhysicsParticle)SmallFire.New(-999f, -999f, 0.0f, 0.0f, canMultiply: false, network: true);
                        }
                        else if (type == typeof(ExtinguisherSmoke))
                        {
                            physicsParticle = (PhysicsParticle) new ExtinguisherSmoke(-999f, -999f, true);
                        }
                        physicsParticle.netIndex = key;
                        physicsParticle.isLocal  = false;
                        if (!this.removedParticleIndexes.Contains(key))
                        {
                            this._particles[key] = physicsParticle;
                            Level.Add((Thing)physicsParticle);
                        }
                    }
                    physicsParticle.NetDeserialize(nmParticles.data);
                }
                break;
            }
        }
Exemplo n.º 2
0
        public List <ushort> GetSendRemoveList(NetworkConnection c)
        {
            List <NMRemovedParticles> removedParticlesList = (List <NMRemovedParticles>)null;

            if (!this._pendingParticleRemoveSends.TryGetValue(c, out removedParticlesList))
            {
                removedParticlesList = new List <NMRemovedParticles>();
                this._pendingParticleRemoveSends[c] = removedParticlesList;
            }
            if (removedParticlesList.Count == 0 || removedParticlesList[removedParticlesList.Count - 1].GetParticles().Count > 30)
            {
                NMRemovedParticles removedParticles = new NMRemovedParticles();
                removedParticlesList.Add(removedParticles);
            }
            return(removedParticlesList[removedParticlesList.Count - 1].GetParticles());
        }