public override void Update()
 {
     if (this.activated && this._sprite.currentAnimation != "activate")
     {
         this._sprite.SetAnimation("activate");
     }
     if (this._sprite.imageIndex == 6 && this._beeps == (byte)0)
     {
         SFX.Play("singleBeep");
         ++this._beeps;
     }
     if (this._sprite.imageIndex == 7 && this._beeps == (byte)1)
     {
         SFX.Play("singleBeep");
         ++this._beeps;
     }
     if (this._sprite.imageIndex == 8 && this._beeps == (byte)2)
     {
         SFX.Play("singleBeep");
         ++this._beeps;
     }
     if (this._sprite.imageIndex == 5 && this._beeps == (byte)3)
     {
         SFX.Play("doubleBeep", pitch: 0.2f);
         ++this._beeps;
     }
     if (this.isServerForObject && this._sprite.currentAnimation == "activate" && (this._sprite.finished && !this._didActivation))
     {
         this._didActivation = true;
         this.setting.Activate(this);
         Send.Message((NetMessage) new NMActivateDeathCrate(this.settingIndex, this));
     }
     base.Update();
 }
Exemple #2
0
        // Token: 0x0600254F RID: 9551
        protected bool OnDestroybam(DestroyType type = null)
        {
            if (!base.isServerForObject)
            {
                return(false);
            }
            ATRCShrapnel shrap = new ATRCShrapnel();

            shrap.MakeNetEffect(this.position, false);
            List <Bullet> firedBullets = new List <Bullet>();

            for (int i = 0; i < 20; i++)
            {
                float dir = (float)i * 18f - 5f + Rando.Float(10f);
                shrap       = new ATRCShrapnel();
                shrap.range = 55f + Rando.Float(14f);
                Bullet bullet = new Bullet(base.x + (float)(Math.Cos((double)Maths.DegToRad(dir)) * 6.0), base.y - (float)(Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true);
                bullet.firedFrom = this;
                firedBullets.Add(bullet);
                Level.Add(bullet);
            }
            if (Network.isActive)
            {
                Send.Message(new NMFireGun(null, firedBullets, 0, false, 4, false), NetMessagePriority.ReliableOrdered, null);
                firedBullets.Clear();
            }
            Level.Remove(this);
            return(true);
        }
 protected override void OnAllClientsReady()
 {
     if (Network.isServer)
     {
         Send.Message((NetMessage) new NMBeginLevel());
     }
     base.OnAllClientsReady();
 }
 public override void Update()
 {
     if (this._explodeFrames < 0)
     {
         float x    = this.x;
         float ypos = this.y - 2f;
         Level.Add((Thing) new ExplosionPart(x, ypos));
         int num1 = 6;
         if (Graphics.effectsLevel < 2)
         {
             num1 = 3;
         }
         for (int index = 0; index < num1; ++index)
         {
             float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
             float num2 = Rando.Float(12f, 20f);
             Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
         }
         this._explodeFrames = 4;
     }
     else
     {
         --this._explodeFrames;
         if (this._explodeFrames != 0)
         {
             return;
         }
         float         x          = this.x;
         float         num1       = this.y - 2f;
         List <Bullet> varBullets = new List <Bullet>();
         for (int index = 0; index < 20; ++index)
         {
             float           num2            = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
             ATPropExplosion atPropExplosion = new ATPropExplosion();
             atPropExplosion.range = 60f + Rando.Float(18f);
             Bullet bullet = new Bullet(x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 6.0), num1 - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 6.0), (AmmoType)atPropExplosion, num2);
             bullet.firedFrom = (Thing)this;
             varBullets.Add(bullet);
             Level.Add((Thing)bullet);
         }
         if (Network.isActive)
         {
             Send.Message((NetMessage) new NMExplodingProp(varBullets), NetMessagePriority.ReliableOrdered);
             varBullets.Clear();
         }
         Graphics.flashAdd = 1.3f;
         Layer.Game.darken = 1.3f;
         foreach (Window window in Level.CheckCircleAll <Window>(this.position, 40f))
         {
             if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
             {
                 window.Destroy((DestroyType) new DTImpact((Thing)this));
             }
         }
         SFX.Play("explode");
         Level.Remove((Thing)this);
     }
 }
Exemple #5
0
        public void Update(NetworkConnection c)
        {
            foreach (KeyValuePair <ushort, PhysicsParticle> particle in this._particles)
            {
                PhysicsParticle physicsParticle = particle.Value;
                if (physicsParticle.isLocal)
                {
                    this.GetSendList(c, physicsParticle.GetType()).Add(physicsParticle);
                }
            }
            if (this.removedParticles.Count > 0)
            {
                for (int index = 0; index < this.removedParticles.Count; ++index)
                {
                    foreach (NetworkConnection connection in Network.connections)
                    {
                        if (this.removedParticles[index].isLocal)
                        {
                            this.GetSendRemoveList(connection).Add(this.removedParticles[index].netIndex);
                        }
                    }
                    this._particles.Remove(this.removedParticles[index].netIndex);
                    Level.Remove((Thing)this.removedParticles[index]);
                }
                this.removedParticles.Clear();
            }
            using (Dictionary <System.Type, List <NMParticles> > .Enumerator enumerator = this.GetParticlePairs(c).GetEnumerator())
            {
label_22:
                while (enumerator.MoveNext())
                {
                    KeyValuePair <System.Type, List <NMParticles> > current = enumerator.Current;
                    int num = 0;
                    while (true)
                    {
                        if (num < 3 && current.Value.Count > 0)
                        {
                            Send.Message((NetMessage)current.Value[0], NetMessagePriority.UnreliableUnordered, c);
                            current.Value.RemoveAt(0);
                            ++num;
                        }
                        else
                        {
                            goto label_22;
                        }
                    }
                }
            }
            List <NMRemovedParticles> particleRemoveList = this.GetParticleRemoveList(c);

            for (int index = 0; index < Math.Min(particleRemoveList.Count, 3); index = index - 1 + 1)
            {
                Send.Message((NetMessage)particleRemoveList[index], NetMessagePriority.Volatile, c);
                particleRemoveList.RemoveAt(index);
            }
        }
        public void BlowUp()
        {
            if (this.blownUp)
            {
                return;
            }
            this.MakeBlowUpHappen(this.position);
            this.blownUp = true;
            foreach (PhysicsObject physicsObject in Level.CheckCircleAll <PhysicsObject>(this.position, 22f))
            {
                if (physicsObject != this)
                {
                    Vec2  vec2 = physicsObject.position - this.position;
                    float num1 = (float)(1.0 - (double)Math.Min(vec2.length, 22f) / 22.0);
                    float num2 = num1 * 4f;
                    vec2.Normalize();
                    physicsObject.hSpeed  += num2 * vec2.x;
                    physicsObject.vSpeed  += -5f * num1;
                    physicsObject.sleeping = false;
                    this.Fondle((Thing)physicsObject);
                }
            }
            float x = this.position.x;
            float y = this.position.y;

            for (int index = 0; index < 20; ++index)
            {
                float      ang        = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
                ATShrapnel atShrapnel = new ATShrapnel();
                atShrapnel.range = 60f + Rando.Float(18f);
                Bullet bullet = new Bullet(x, y, (AmmoType)atShrapnel, ang);
                bullet.firedFrom = (Thing)this;
                this.firedBullets.Add(bullet);
                Level.Add((Thing)bullet);
            }
            this.bulletFireIndex += (byte)20;
            if (Network.isActive && this.isServerForObject)
            {
                Send.Message((NetMessage) new NMFireGun((Gun)this, this.firedBullets, this.bulletFireIndex, false), NetMessagePriority.ReliableOrdered);
                this.firedBullets.Clear();
            }
            if (Recorder.currentRecording != null)
            {
                Recorder.currentRecording.LogBonus();
            }
            Level.Remove((Thing)this);
        }
Exemple #7
0
        protected override void OnHit(bool destroyed)
        {
            if (!destroyed || !this.isLocal)
            {
                return;
            }
            for (int index = 0; index < 1; ++index)
            {
                ExplosionPart explosionPart = new ExplosionPart(this.x - 8f + Rando.Float(16f), this.y - 8f + Rando.Float(16f));
                explosionPart.xscale *= 0.7f;
                explosionPart.yscale *= 0.7f;
                Level.Add((Thing)explosionPart);
            }
            SFX.Play("explode");
            List <Bullet> varBullets = new List <Bullet>();
            Vec2          vec2       = this.position - this.travelDirNormalized;

            for (int index = 0; index < 12; ++index)
            {
                float ang = (float)((double)index * 30.0 - 10.0) + Rando.Float(20f);
                ATGrenadeLauncherShrapnel launcherShrapnel = new ATGrenadeLauncherShrapnel();
                launcherShrapnel.range = 25f + Rando.Float(10f);
                Bullet bullet = new Bullet(vec2.x, vec2.y, (AmmoType)launcherShrapnel, ang);
                bullet.firedFrom = (Thing)this;
                varBullets.Add(bullet);
                Level.Add((Thing)bullet);
            }
            if (Network.isActive && this.isLocal)
            {
                Send.Message((NetMessage) new NMFireGun((Gun)null, varBullets, (byte)0, false), NetMessagePriority.ReliableOrdered);
                varBullets.Clear();
            }
            foreach (Window window in Level.CheckCircleAll <Window>(this.position, 20f))
            {
                if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
                {
                    window.Destroy((DestroyType) new DTImpact((Thing)this));
                }
            }
        }
Exemple #8
0
        // Token: 0x06001988 RID: 6536
        protected override bool OnDestroy(DestroyType type = null)
        {
            if (!base.isServerForObject)
            {
                return(false);
            }
            ATRCShrapnel atrcshrapnel = new ATRCShrapnel();

            atrcshrapnel.MakeNetEffect(this.position, false);
            List <Bullet> list = new List <Bullet>();

            for (int i = 0; i < 20; i++)
            {
                float num = (float)i * 18f - 5f + Rando.Float(10f);
                atrcshrapnel       = new ATRCShrapnel();
                atrcshrapnel.range = 55f + Rando.Float(14f);
                Bullet bullet = new Bullet(base.x + (float)(Math.Cos((double)Maths.DegToRad(num)) * 6.0), base.y - (float)(Math.Sin((double)Maths.DegToRad(num)) * 6.0), atrcshrapnel, num, null, false, -1f, false, true);
                bullet.firedFrom = this;
                list.Add(bullet);
                Level.Add(bullet);
            }
            if (Network.isActive)
            {
                Send.Message(new NMFireGun(null, list, 0, false, 4, false), NetMessagePriority.ReliableOrdered, null);
                list.Clear();
            }
            Level.Remove(this);
            FollowCam followCam = Level.current.camera as FollowCam;

            if (followCam != null)
            {
                followCam.Remove(this);
            }
            if (Recorder.currentRecording != null)
            {
                Recorder.currentRecording.LogBonus();
            }
            return(true);
        }
Exemple #9
0
        public static void SendLotsOfData(byte[] bytes, string type, NetworkConnection connection)
        {
            currentSession++;
            byte[] data = new byte[bytes.Length + 1];
            if (!dataTypes.ContainsValue(type))
            {
                type = "undefined";
            }

            data[0] = dataTypes.FirstOrDefault(x => x.Value == type).Key;
            bytes.CopyTo(data, 1);

            var compressedData = compress(data);

            byte      index    = 0;
            int       position = 0;
            BitBuffer bit      = new BitBuffer();

            for (;;)
            {
                bit.Write(compressedData[position]);
                position++;

                bool flag = position == compressedData.Length;
                if (position % SliceSize == 0 || flag)
                {
                    Send.Message(new NMDataSlice(bit, currentSession, flag, index++), connection);
                    if (flag)
                    {
                        break;
                    }

                    bit = new BitBuffer();
                }
            }
        }
Exemple #10
0
        protected override List <Profile> AddPoints()
        {
            List <Profile> profileList = new List <Profile>();
            List <Team>    teamList    = new List <Team>();
            List <Team>    source      = new List <Team>();

            foreach (Team team in Teams.all)
            {
                foreach (Profile activeProfile in team.activeProfiles)
                {
                    if (activeProfile.duck != null && !activeProfile.duck.dead)
                    {
                        if (activeProfile.duck.converted != null && activeProfile.duck.converted.profile.team != activeProfile.team)
                        {
                            if (!source.Contains(activeProfile.duck.converted.profile.team))
                            {
                                source.Add(activeProfile.duck.converted.profile.team);
                            }
                            if (!teamList.Contains(activeProfile.duck.profile.team))
                            {
                                teamList.Add(activeProfile.duck.profile.team);
                                break;
                            }
                            break;
                        }
                        if (!source.Contains(team))
                        {
                            source.Add(team);
                            break;
                        }
                        break;
                    }
                }
            }
            if (source.Count <= 1 && source.Count > 0)
            {
                source.AddRange((IEnumerable <Team>)teamList);
                byte       winteam = 4;
                List <int> idxs    = new List <int>();
                GameMode.lastWinners.Clear();
                foreach (Team team in source)
                {
                    foreach (Profile activeProfile in team.activeProfiles)
                    {
                        if (activeProfile.duck != null && !activeProfile.duck.dead)
                        {
                            if (!this._editorTestMode)
                            {
                                if (Teams.active.Count > 1 && Network.isActive && activeProfile.connection == DuckNetwork.localConnection)
                                {
                                    DuckNetwork.GiveXP("Rounds Won", 1, 4, firstCap: 10, secondCap: 20);
                                }
                                activeProfile.stats.lastWon = DateTime.Now;
                                ++activeProfile.stats.matchesWon;
                            }
                            profileList.Add(activeProfile);
                            Profile p = activeProfile;
                            if (activeProfile.duck.converted != null)
                            {
                                p       = activeProfile.duck.converted.profile;
                                winteam = p.networkIndex;
                            }
                            GameMode.lastWinners.Add(activeProfile);
                            PlusOne plusOne = new PlusOne(0.0f, 0.0f, p);
                            plusOne.anchor        = (Anchor)(Thing)activeProfile.duck;
                            plusOne.anchor.offset = new Vec2(0.0f, -16f);
                            idxs.Add((int)activeProfile.duck.netProfileIndex);
                            Level.Add((Thing)plusOne);
                        }
                    }
                }
                if (Network.isActive && Network.isServer)
                {
                    Send.Message((NetMessage) new NMAssignWin(idxs, winteam));
                }
                ++source.First <Team>().score;
            }
            return(profileList);
        }
        public override void OnHit(bool destroyed, Bullet b)
        {
            if (!b.isLocal)
            {
                return;
            }
            if (destroyed)
            {
                new ATMissileShrapnel().MakeNetEffect(b.position, false);
                Random random = (Random)null;
                if (Network.isActive && b.isLocal)
                {
                    random          = Rando.generator;
                    Rando.generator = new Random(NetRand.currentSeed);
                }
                List <Bullet> varBullets = new List <Bullet>();
                for (int index = 0; index < 12; ++index)
                {
                    float             num = (float)((double)index * 30.0 - 10.0) + Rando.Float(20f);
                    ATMissileShrapnel atMissileShrapnel = new ATMissileShrapnel();
                    atMissileShrapnel.range = 15f + Rando.Float(5f);
                    Vec2   vec2   = new Vec2((float)Math.Cos((double)Maths.DegToRad(num)), (float)Math.Sin((double)Maths.DegToRad(num)));
                    Bullet bullet = new Bullet(b.x + vec2.x * 8f, b.y - vec2.y * 8f, (AmmoType)atMissileShrapnel, num);
                    bullet.firedFrom = (Thing)b;
                    varBullets.Add(bullet);
                    Level.Add((Thing)bullet);
                    Level.Add((Thing)Spark.New(b.x + Rando.Float(-8f, 8f), b.y + Rando.Float(-8f, 8f), vec2 + new Vec2(Rando.Float(-0.1f, 0.1f), Rando.Float(-0.1f, 0.1f))));
                    Level.Add((Thing)SmallSmoke.New(b.x + vec2.x * 8f + Rando.Float(-8f, 8f), b.y + vec2.y * 8f + Rando.Float(-8f, 8f)));
                }
                if (Network.isActive && b.isLocal)
                {
                    Send.Message((NetMessage) new NMFireGun((Gun)null, varBullets, (byte)0, false), NetMessagePriority.ReliableOrdered);
                    varBullets.Clear();
                }
                if (Network.isActive && b.isLocal)
                {
                    Rando.generator = random;
                }
                foreach (Window window in Level.CheckCircleAll <Window>(b.position, 30f))
                {
                    if (b.isLocal)
                    {
                        Thing.Fondle((Thing)window, DuckNetwork.localConnection);
                    }
                    if (Level.CheckLine <Block>(b.position, window.position, (Thing)window) == null)
                    {
                        window.Destroy((DestroyType) new DTImpact((Thing)b));
                    }
                }
                foreach (PhysicsObject physicsObject in Level.CheckCircleAll <PhysicsObject>(b.position, 70f))
                {
                    if (b.isLocal && b.owner == null)
                    {
                        Thing.Fondle((Thing)physicsObject, DuckNetwork.localConnection);
                    }
                    if ((double)(physicsObject.position - b.position).length < 30.0)
                    {
                        physicsObject.Destroy((DestroyType) new DTImpact((Thing)b));
                    }
                    physicsObject.sleeping = false;
                    physicsObject.vSpeed   = -2f;
                }
                HashSet <ushort> varBlocks = new HashSet <ushort>();
                foreach (BlockGroup blockGroup1 in Level.CheckCircleAll <BlockGroup>(b.position, 50f))
                {
                    if (blockGroup1 != null)
                    {
                        BlockGroup   blockGroup2 = blockGroup1;
                        List <Block> blockList   = new List <Block>();
                        foreach (Block block in blockGroup2.blocks)
                        {
                            if (Collision.Circle(b.position, 28f, block.rectangle))
                            {
                                block.shouldWreck = true;
                                if (block is AutoBlock)
                                {
                                    varBlocks.Add((block as AutoBlock).blockIndex);
                                }
                            }
                        }
                        blockGroup2.Wreck();
                    }
                }
                foreach (Block block in Level.CheckCircleAll <Block>(b.position, 28f))
                {
                    switch (block)
                    {
                    case AutoBlock _:
                        block.skipWreck   = true;
                        block.shouldWreck = true;
                        if (block is AutoBlock)
                        {
                            varBlocks.Add((block as AutoBlock).blockIndex);
                            continue;
                        }
                        continue;

                    case Door _:
                    case VerticalDoor _:
                        Level.Remove((Thing)block);
                        block.Destroy((DestroyType) new DTRocketExplosion((Thing)null));
                        continue;

                    default:
                        continue;
                    }
                }
                if (Network.isActive && b.isLocal && varBlocks.Count > 0)
                {
                    Send.Message((NetMessage) new NMDestroyBlocks(varBlocks));
                }
            }
            base.OnHit(destroyed, b);
        }
Exemple #12
0
 void requestReskin(Profile pro, string md5)
 {
     Send.Message(new NMRequestReskin(pro.networkIndex, md5), pro.connection);
 }
 public override void Update()
 {
     base.Update();
     if (!this._pin)
     {
         this._timer -= 0.01f;
     }
     if ((double)this._timer < 0.5 && this.owner == null && !this._didBonus)
     {
         this._didBonus = true;
         if (Recorder.currentRecording != null)
         {
             Recorder.currentRecording.LogBonus();
         }
     }
     if (!this._localDidExplode && (double)this._timer < 0.0)
     {
         if (this._explodeFrames < 0)
         {
             this.CreateExplosion(this.position);
             this._explodeFrames = 4;
         }
         else
         {
             --this._explodeFrames;
             if (this._explodeFrames == 0)
             {
                 float x    = this.x;
                 float num1 = this.y - 2f;
                 Graphics.FlashScreen();
                 if (this.isServerForObject)
                 {
                     for (int index = 0; index < 20; ++index)
                     {
                         float      num2       = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
                         ATShrapnel atShrapnel = new ATShrapnel();
                         atShrapnel.range = 60f + Rando.Float(18f);
                         Bullet bullet = new Bullet(x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 6.0), num1 - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 6.0), (AmmoType)atShrapnel, num2);
                         bullet.firedFrom = (Thing)this;
                         this.firedBullets.Add(bullet);
                         Level.Add((Thing)bullet);
                     }
                     foreach (Window window in Level.CheckCircleAll <Window>(this.position, 40f))
                     {
                         if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
                         {
                             window.Destroy((DestroyType) new DTImpact((Thing)this));
                         }
                     }
                     this.bulletFireIndex += (byte)20;
                     if (Network.isActive)
                     {
                         Send.Message((NetMessage) new NMFireGun((Gun)this, this.firedBullets, this.bulletFireIndex, false), NetMessagePriority.ReliableOrdered);
                         this.firedBullets.Clear();
                     }
                 }
                 Level.Remove((Thing)this);
                 this._destroyed     = true;
                 this._explodeFrames = -1;
             }
         }
     }
     if (this.prevOwner != null && this._cookThrower == null)
     {
         this._cookThrower     = this.prevOwner as Duck;
         this._cookTimeOnThrow = this._timer;
     }
     this._sprite.frame = this._pin ? 0 : 1;
 }
Exemple #14
0
        public override void Activate()
        {
            DuckNetwork.levelIndex = this.levelIndex;
            GhostManager.context.SetGhostIndex((NetIndex16)(int)this.predictionIndex);
            if (this.level == "@TEAMSELECT")
            {
                this._lev = (Level) new TeamSelect2();
            }
            else if (this.level == "@ROCKINTRO")
            {
                this._lev = (Level) new RockIntro((Level)null);
            }
            else if (this.level == "@ROCKTHROW|SHOWSCORE")
            {
                this._lev = (Level) new RockScoreboard();
            }
            else if (this.level == "@ROCKTHROW|SHOWWINNER")
            {
                this._lev = (Level) new RockScoreboard(mode: ScoreBoardMode.ShowWinner);
            }
            else if (this.level == "@ROCKTHROW|SHOWEND")
            {
                this._lev = (Level) new RockScoreboard(mode: ScoreBoardMode.ShowWinner, afterHighlights: true);
            }
            else
            {
                int seedVal = 0;
                if (this is NMSwitchLevelRandom)
                {
                    seedVal = (this as NMSwitchLevelRandom).seed;
                }
                if (this.needsChecksum)
                {
                    GameLevel        gameLevel  = new GameLevel(this.level, seedVal);
                    List <LevelData> allLevels  = Content.GetAllLevels(this.level);
                    LevelData        levelData1 = (LevelData)null;
                    foreach (LevelData levelData2 in allLevels)
                    {
                        if ((int)levelData2.GetChecksum() == (int)this.checksum)
                        {
                            levelData1 = levelData2;
                            break;
                        }
                    }
                    if (levelData1 == null)
                    {
                        ++DuckNetwork.core.levelTransferSession;
                        DuckNetwork.core.compressedLevelData   = (MemoryStream)null;
                        DuckNetwork.core.levelTransferSize     = 0;
                        DuckNetwork.core.levelTransferProgress = 0;
                        Send.Message((NetMessage) new NMClientNeedsLevelData(this.levelIndex, DuckNetwork.core.levelTransferSession), this.connection);
                        gameLevel.waitingOnNewData = true;
                        gameLevel.networkIndex     = this.levelIndex;
                    }
                    else
                    {
                        gameLevel.data = levelData1;
                    }
                    this._lev = (Level)gameLevel;
                }
                else
                {
                    this._lev = (Level) new GameLevel(this.level, seedVal);
                }
            }
            switch (Level.current)
            {
            case TeamSelect2 _:
label_26:
                Music.Stop();
                break;

            case RockScoreboard _:
                if (this._lev is RockScoreboard)
                {
                    break;
                }
                goto label_26;
            }
            Level.current = this._lev;
        }
        protected override List <Profile> AddPoints()
        {
            List <Profile> profileList = new List <Profile>();
            List <Team>    teamList    = new List <Team>();
            List <Team>    source      = new List <Team>();
            int            num1        = CTF.winner ? 0 : 1;
            int            num2        = 0;

            foreach (Team team in Teams.all)
            {
                if (team.activeProfiles.Count <Profile>() != 0)
                {
                    foreach (Profile activeProfile in team.activeProfiles)
                    {
                        if (activeProfile.duck != null && num2 == num1)
                        {
                            if (activeProfile.duck.converted != null && activeProfile.duck.converted.profile.team != activeProfile.team)
                            {
                                if (!source.Contains(activeProfile.duck.converted.profile.team))
                                {
                                    source.Add(activeProfile.duck.converted.profile.team);
                                }
                                if (!teamList.Contains(activeProfile.duck.profile.team))
                                {
                                    teamList.Add(activeProfile.duck.profile.team);
                                    break;
                                }
                                break;
                            }
                            if (!source.Contains(team))
                            {
                                source.Add(team);
                                break;
                            }
                            break;
                        }
                    }
                    ++num2;
                }
            }
            if (source.Count <= 1 && source.Count > 0)
            {
                source.AddRange((IEnumerable <Team>)teamList);
                List <int> idxs = new List <int>();
                foreach (Team team in source)
                {
                    foreach (Profile activeProfile in team.activeProfiles)
                    {
                        if (activeProfile.duck != null && !activeProfile.duck.dead)
                        {
                            profileList.Add(activeProfile);
                            activeProfile.stats.lastWon = DateTime.Now;
                            ++activeProfile.stats.matchesWon;
                            Profile p = activeProfile;
                            if (activeProfile.duck.converted != null)
                            {
                                p = activeProfile.duck.converted.profile;
                            }
                            PlusOne plusOne = new PlusOne(0.0f, 0.0f, p);
                            plusOne.anchor        = (Anchor)(Thing)activeProfile.duck;
                            plusOne.anchor.offset = new Vec2(0.0f, -16f);
                            idxs.Add((int)activeProfile.duck.netProfileIndex);
                            Level.Add((Thing)plusOne);
                        }
                    }
                }
                if (Network.isActive && Network.isServer)
                {
                    Send.Message((NetMessage) new NMAssignWin(idxs, (byte)4));
                }
                ++source.First <Team>().score;
            }
            return(profileList);
        }
 public override void Update()
 {
     base.Update();
     this._sprite.frame = this._owner == null || this._raised ? 0 : 1;
     this._raiseArm     = Lerp.Float(this._raiseArm, 0.0f, 0.05f);
     this._preachWait   = Lerp.Float(this._preachWait, 0.0f, 0.06f);
     this._ringPulse    = Lerp.Float(this._ringPulse, 0.0f, 0.05f);
     if (Network.isActive)
     {
         if (this.isServerForObject)
         {
             if (this.controlling1)
             {
                 Duck duck = this.GetDuck(0);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling1 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling2)
             {
                 Duck duck = this.GetDuck(1);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling2 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling3)
             {
                 Duck duck = this.GetDuck(2);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling3 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
             if (this.controlling4)
             {
                 Duck duck = this.GetDuck(3);
                 if (duck != null)
                 {
                     if (duck.listenTime <= 0)
                     {
                         this.controlling4 = false;
                     }
                     else
                     {
                         this.Fondle((Thing)duck);
                         this.Fondle((Thing)duck.holdObject);
                         foreach (Thing t in duck._equipment)
                         {
                             this.Fondle(t);
                         }
                         this.Fondle((Thing)duck._ragdollInstance);
                         this.Fondle((Thing)duck._trappedInstance);
                         this.Fondle((Thing)duck._cookedInstance);
                     }
                 }
             }
         }
         else
         {
             Duck duck1 = this.GetDuck(0);
             if (duck1 != null)
             {
                 if (this.controlling1)
                 {
                     duck1.listening = true;
                     duck1.Fondle((Thing)duck1.holdObject);
                     foreach (Equipment equipment in duck1._equipment)
                     {
                         duck1.Fondle((Thing)equipment);
                     }
                     duck1.Fondle((Thing)duck1._ragdollInstance);
                     duck1.Fondle((Thing)duck1._trappedInstance);
                     duck1.Fondle((Thing)duck1._cookedInstance);
                 }
                 if (!this.controlling1 && this.prevControlling1)
                 {
                     duck1.listening = false;
                 }
                 this.prevControlling1 = this.controlling1;
             }
             Duck duck2 = this.GetDuck(1);
             if (duck2 != null)
             {
                 if (this.controlling2)
                 {
                     duck2.listening = true;
                     duck2.Fondle((Thing)duck2.holdObject);
                     foreach (Equipment equipment in duck2._equipment)
                     {
                         duck2.Fondle((Thing)equipment);
                     }
                     duck2.Fondle((Thing)duck2._ragdollInstance);
                     duck2.Fondle((Thing)duck2._trappedInstance);
                     duck2.Fondle((Thing)duck2._cookedInstance);
                 }
                 if (!this.controlling2 && this.prevControlling2)
                 {
                     duck2.listening = false;
                 }
                 this.prevControlling2 = this.controlling2;
             }
             Duck duck3 = this.GetDuck(2);
             if (duck3 != null)
             {
                 if (this.controlling3)
                 {
                     duck3.listening = true;
                     duck3.Fondle((Thing)duck3.holdObject);
                     foreach (Equipment equipment in duck3._equipment)
                     {
                         duck3.Fondle((Thing)equipment);
                     }
                     duck3.Fondle((Thing)duck3._ragdollInstance);
                     duck3.Fondle((Thing)duck3._trappedInstance);
                     duck3.Fondle((Thing)duck3._cookedInstance);
                 }
                 if (!this.controlling3 && this.prevControlling3)
                 {
                     duck3.listening = false;
                 }
                 this.prevControlling3 = this.controlling3;
             }
             Duck duck4 = this.GetDuck(3);
             if (duck4 != null)
             {
                 if (this.controlling4)
                 {
                     duck4.listening = true;
                     duck4.Fondle((Thing)duck4.holdObject);
                     foreach (Equipment equipment in duck4._equipment)
                     {
                         duck4.Fondle((Thing)equipment);
                     }
                     duck4.Fondle((Thing)duck4._ragdollInstance);
                     duck4.Fondle((Thing)duck4._trappedInstance);
                     duck4.Fondle((Thing)duck4._cookedInstance);
                 }
                 if (!this.controlling4 && this.prevControlling4)
                 {
                     duck4.listening = false;
                 }
                 this.prevControlling4 = this.controlling4;
             }
         }
     }
     if (this._triggerHeld && this.isServerForObject && (this.duck != null && (double)this._preachWait <= 0.0 & this.duck.quack < 1) && this.duck.grounded)
     {
         if (Network.isActive)
         {
             this._netPreach.Play();
         }
         else
         {
             SFX.Play("preach" + (object)Rando.Int(5), Rando.Float(0.8f, 1f), Rando.Float(-0.2f, -0.3f));
         }
         this.duck.quack = (int)(byte)Rando.Int(12, 30);
         this.duck.profile.stats.timePreaching += (float)this.duck.quack / 0.1f * Maths.IncFrameTimer();
         this._preachWait = Rando.Float(1.8f, 2.5f);
         this._ringPulse  = 1f;
         if (Rando.Int(1) == 0)
         {
             this._raiseArm = Rando.Float(1.2f, 2f);
         }
         Ragdoll ragdoll = Level.Nearest <Ragdoll>(this.x, this.y, (Thing)this);
         if (ragdoll != null && ragdoll.captureDuck != null && (ragdoll.captureDuck.dead && Level.CheckLine <Block>(this.duck.position, ragdoll.position) == null) && (double)(ragdoll.position - this.duck.position).length < (double)this._ammoType.range)
         {
             if (Network.isActive)
             {
                 this.Fondle((Thing)ragdoll.captureDuck);
                 this.Fondle((Thing)ragdoll);
                 Send.Message((NetMessage) new NMLayToRest(ragdoll.captureDuck.profile.networkIndex));
             }
             ragdoll.captureDuck.LayToRest(this.duck.profile);
         }
         foreach (Duck duck in Level.current.things[typeof(Duck)])
         {
             if (duck != this.duck && duck.grounded && (!(duck.holdObject is GoodBook) && Level.CheckLine <Block>(this.duck.position, duck.position) == null) && (double)(duck.position - this.duck.position).length < (double)this._ammoType.range)
             {
                 if (duck.dead)
                 {
                     this.Fondle((Thing)duck);
                     duck.LayToRest(this.duck.profile);
                 }
                 else if (duck.converted != this.duck && this.duck.converted != duck && duck.profile.team != this.duck.profile.team)
                 {
                     if (Network.isActive)
                     {
                         if (duck.profile.networkIndex == (byte)0)
                         {
                             this.controlling1 = true;
                         }
                         if (duck.profile.networkIndex == (byte)1)
                         {
                             this.controlling2 = true;
                         }
                         if (duck.profile.networkIndex == (byte)2)
                         {
                             this.controlling3 = true;
                         }
                         if (duck.profile.networkIndex == (byte)3)
                         {
                             this.controlling4 = true;
                         }
                     }
                     duck.listening = true;
                     this.Fondle((Thing)duck);
                     this.Fondle((Thing)duck.holdObject);
                     foreach (Thing t in duck._equipment)
                     {
                         this.Fondle(t);
                     }
                     this.Fondle((Thing)duck._ragdollInstance);
                     this.Fondle((Thing)duck._trappedInstance);
                     this.Fondle((Thing)duck._cookedInstance);
                     duck.listenTime = 80;
                     if ((double)this.owner.x < (double)duck.x)
                     {
                         duck.offDir = (sbyte)-1;
                     }
                     else
                     {
                         duck.offDir = (sbyte)1;
                     }
                     duck.ThrowItem(false);
                     duck.conversionResistance -= 30;
                     if (duck.conversionResistance <= 0)
                     {
                         duck.ConvertDuck(this.duck.converted != null ? this.duck.converted : this.duck);
                         if (Network.isActive)
                         {
                             Send.Message((NetMessage) new NMConversion(duck.profile.networkIndex, this.duck.profile.networkIndex));
                         }
                         duck.conversionResistance = 50;
                     }
                 }
             }
         }
     }
     this._haloAlpha = Lerp.Float(this._haloAlpha, !this._triggerHeld || this.duck == null || !this.duck.grounded ? 0.0f : 1f, 0.05f);
 }
        public override void Update()
        {
            if (RockWeather.alwaysRainbow)
            {
                RockWeather.rainbowFade = 1f;
                RockWeather.rainbowTime = 1f;
            }
            RockWeather.rainbowFade  = Lerp.Float(RockWeather.rainbowFade, (double)RockWeather.rainbowTime > 0.0 ? 1f : 0.0f, 1f / 1000f);
            RockWeather.rainbowTime -= Maths.IncFrameTimer();
            if (RockWeather._weather != Weather.Sunny)
            {
                RockWeather.rainbowTime -= Maths.IncFrameTimer() * 8f;
            }
            if ((double)RockWeather.rainbowTime < 0.0)
            {
                RockWeather.rainbowTime = 0.0f;
            }
            if (RockWeather.neverRainbow)
            {
                RockWeather.rainbowFade = 0.0f;
            }
            RockWeatherState weatherState = this.GetWeatherState(RockWeather._timeOfDay);

            this.rainbowLight  = weatherState.rainbowLight * RockWeather.rainbowFade;
            this.rainbowLight2 = weatherState.rainbowLight2 * RockWeather.rainbowFade;
            this.ApplyWeatherState(weatherState);
            RockWeather._prevWeatherLerp = Lerp.Float(RockWeather._prevWeatherLerp, 0.0f, 0.05f);
            if (Network.isServer)
            {
                this.wait += 3f / 1000f;
                if ((double)this.wait > 1.0)
                {
                    this.wait = 0.0f;
                    if ((double)RockWeather._weatherTime > 0.100000001490116)
                    {
                        if ((double)RockWeather.snowChance > 0.0 && RockWeather._weather != Weather.Snowing && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.snowChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Snowing;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if ((double)RockWeather.rainChance > 0.0 && RockWeather._weather != Weather.Raining && (double)Rando.Float(1f) > 1.0 - (double)RockWeather.rainChance)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            RockWeather.sunshowers       = 0.0f;
                            RockWeather._prevWeather     = RockWeather._weather;
                            RockWeather._weather         = Weather.Raining;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                        if (RockWeather._weather != Weather.Sunny && (double)Rando.Float(1f) > 0.980000019073486)
                        {
                            RockWeather._prevWeatherLerp = 1f;
                            if (RockWeather._weather == Weather.Raining)
                            {
                                if ((double)RockWeather._timeRaining > 900.0 && (double)Rando.Float(1f) > 0.850000023841858 || (double)Rando.Float(1f) > 0.949999988079071)
                                {
                                    RockWeather.rainbowTime = Rando.Float(30f, 240f);
                                }
                                if ((double)Rando.Float(1f) > 0.300000011920929)
                                {
                                    RockWeather.sunshowers = Rando.Float(0.1f, 60f);
                                }
                            }
                            RockWeather._timeRaining = 0.0f;
                            RockWeather._prevWeather = RockWeather._weather;
                            RockWeather._weather     = Weather.Sunny;
                            if (Network.isActive)
                            {
                                Send.Message((NetMessage) new NMChangeWeather((byte)RockWeather._weather));
                            }
                            RockWeather._weatherTime = 0.0f;
                        }
                    }
                }
            }
            RockWeather.sunshowers -= Maths.IncFrameTimer();
            if ((double)RockWeather.sunshowers <= 0.0)
            {
                RockWeather.sunshowers = 0.0f;
            }
            switch (RockWeather._weather)
            {
            case Weather.Snowing:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    SnowParticle snowParticle = new SnowParticle(new Vec2(Rando.Float(-100f, 400f), Rando.Float(-500f, -550f)));
                    snowParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)snowParticle);
                }
                this._particleWait -= 0.5f;
                break;

            case Weather.Raining:
                while ((double)this._particleWait <= 0.0)
                {
                    ++this._particleWait;
                    RainParticle rainParticle = new RainParticle(new Vec2(Rando.Float(-100f, 900f), Rando.Float(-500f, -550f)));
                    rainParticle.z = Rando.Float(0.0f, 200f);
                    this._particles.Add((WeatherParticle)rainParticle);
                }
                --this._particleWait;
                break;

            default:
                if ((double)RockWeather.sunshowers <= 0.0)
                {
                    break;
                }
                goto case Weather.Raining;
            }
            List <WeatherParticle> weatherParticleList = new List <WeatherParticle>();

            foreach (WeatherParticle particle in this._particles)
            {
                particle.Update();
                if ((double)particle.position.y > 0.0)
                {
                    particle.die = true;
                }
                switch (particle)
                {
                case RainParticle _ when(double) particle.z <70.0 && (double)particle.position.y> -62.0:
                    particle.die = true;

                    particle.position.y = -58f;
                    break;

                case RainParticle _ when(double) particle.z <40.0 && (double)particle.position.y> -98.0:
                    particle.die = true;

                    particle.position.y = -98f;
                    break;

                case RainParticle _ when(double) particle.z < 25.0 && ((double)particle.position.x > 175.0 && (double)particle.position.x < 430.0) && ((double)particle.position.y > -362.0 && (double)particle.position.y < -352.0):
                    particle.die = true;

                    particle.position.y = -362f;
                    break;
                }
                if ((double)particle.alpha < 0.00999999977648258)
                {
                    weatherParticleList.Add(particle);
                }
            }
            foreach (WeatherParticle weatherParticle in weatherParticleList)
            {
                this._particles.Remove(weatherParticle);
            }
        }