Beispiel #1
0
        public override PhysicsObject GetSpawnItem()
        {
            if (!(this.contains == typeof(RagdollPart)))
            {
                return(base.GetSpawnItem());
            }
            if (!(this._contextThing is SpriteThing contextThing))
            {
                return((PhysicsObject)null);
            }
            Ragdoll ragdoll = new Ragdoll(this.x, this.y, (Duck)null, false, 0.0f, 0, Vec2.Zero, contextThing.persona);

            Level.Add((Thing)ragdoll);
            ragdoll.RunInit();
            foreach (PhysicsObject above in this._aboveList)
            {
                ragdoll.part1.clip.Add((MaterialThing)above);
                ragdoll.part2.clip.Add((MaterialThing)above);
                ragdoll.part3.clip.Add((MaterialThing)above);
            }
            ragdoll.part1.vSpeed = -3.5f;
            ragdoll.part2.vSpeed = -3.5f;
            ragdoll.part3.vSpeed = -3.5f;
            ragdoll.part1.clip.Add((MaterialThing)this);
            ragdoll.part2.clip.Add((MaterialThing)this);
            ragdoll.part3.clip.Add((MaterialThing)this);
            Block block1 = Level.CheckPoint <Block>(this.position + new Vec2(-16f, 0.0f));

            if (block1 != null)
            {
                ragdoll.part1.clip.Add((MaterialThing)block1);
                ragdoll.part2.clip.Add((MaterialThing)block1);
                ragdoll.part3.clip.Add((MaterialThing)block1);
            }
            Block block2 = Level.CheckPoint <Block>(this.position + new Vec2(16f, 0.0f));

            if (block2 != null)
            {
                ragdoll.part1.clip.Add((MaterialThing)block2);
                ragdoll.part2.clip.Add((MaterialThing)block2);
                ragdoll.part3.clip.Add((MaterialThing)block2);
            }
            SFX.Play("hitBox");
            this.containedObject = (PhysicsObject)null;
            return((PhysicsObject)null);
        }
 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);
 }