public override void Update() { this._orbitInc += this._rotSpeed; this._distPulse += this._distPulseSpeed; if ((double)this._life < 0.300000011920929) { this.xscale = this.yscale = Maths.LerpTowards(this.xscale, 0.1f, 0.015f); } else if (this._grounded) { this.xscale = this.yscale = Maths.LerpTowards(this.xscale, this._fullScale, 0.01f); } else { this.xscale = this.yscale = Maths.LerpTowards(this.xscale, this._fullScale * 0.8f, 0.04f); } this.s1 = this.xscale; this.s2 = this.xscale; if (!this.isLocal) { base.Update(); } else { if (this._grounded) { this._groundedTime += 0.01f; ExtinguisherSmoke extinguisherSmoke = Level.CheckCircle <ExtinguisherSmoke>(new Vec2(this.x, this.y + 4f), 6f); if (extinguisherSmoke != null && (double)this._groundedTime < (double)extinguisherSmoke._groundedTime - 0.100000001490116) { extinguisherSmoke.y -= 0.1f; } } if ((double)this._life < 0.0 && this._sprite.currentAnimation != "puff") { this._sprite.SetAnimation("puff"); } if (this._sprite.currentAnimation == "puff" && this._sprite.finished) { Level.Remove((Thing)this); } base.Update(); } }
public override void UpdateHoldPosition(bool updateLerp = true) { if (this.holdObject == null) { return; } this.holdOffY = 0.0f; this.armOffY = 0.0f; if ((!this._up || !this._popup) && !this.editorUpdate) { return; } this.holdObject.UpdateAction(); this.holdObject.position = this.armPosition + this.holdObject.holdOffset + new Vec2(this.holdOffX, this.holdOffY) + new Vec2((float)(2 * (int)this.offDir), 0.0f); this.holdObject.offDir = this.offDir; if (this._sprite.currentAnimation == "slide") { --this.holdOffY; ++this.holdOffX; } else if (this.crouch) { if (this.holdObject != null) { this.armOffY += 4f; } } else if (this.sliding && this.holdObject != null) { this.armOffY += 6f; } if (this._stance != TargetStance.Fly) { this.holdAngleOff = Maths.LerpTowards(this.holdAngleOff, 0.0f, 0.4f); if (this.holdObject.raised) { this.holdObject.raised = false; } } this.holdObject.position = this.HoldOffset(this.holdObject.holdOffset) + new Vec2((float)((int)this.offDir * 3), 0.0f); this.holdObject.angle = this.holdObject.handAngle + this.holdAngleOff; }
public override void Update() { this._selectBeam.color = new Color(0.5f, (float)(0.200000002980232 + (double)this._wave2.normalized * 0.200000002980232), (float)(0.300000011920929 + (double)this._wave.normalized * 0.300000011920929)) * (1f + this._flash); this._flash = Maths.CountDown(this._flash, 0.1f); this._spawnWait -= 0.025f; if ((double)this._spawnWait < 0.0) { Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave.normalized, false, Color.Cyan * 0.8f)); Level.Add((Thing) new MultiBeamParticle(this.x, this.y + 190f, -0.8f - this._wave2.normalized, true, Color.LightBlue * 0.8f)); this._spawnWait = 1f; } using (IEnumerator <Duck> enumerator = Level.CheckRectAll <Duck>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y)).GetEnumerator()) { while (enumerator.MoveNext()) { Duck d = enumerator.Current; if (!this._ducks.Any <BeamDuck>((Func <BeamDuck, bool>)(t => t.duck == d))) { float num = (double)d.y >= 100.0 ? 130f : 40f; SFX.Play("stepInBeam"); d.immobilized = true; d.crouch = false; d.sliding = false; if (d.holdObject != null) { this._guns.Add((Thing)d.holdObject); } d.ThrowItem(); d.solid = false; d.grounded = false; this._ducks.Add(new BeamDuck() { duck = d, entryHeight = num, leaving = false, entryDir = (double)d.x < (double)this.x ? -1 : 1, sin = new SinWave(0.1f), sin2 = new SinWave(0.05f) }); this.entered = true; } } } foreach (Holdable holdable in Level.CheckRectAll <Holdable>(this.position - this.center, this.position - this.center + new Vec2(this._collisionSize.x, this._collisionSize.y))) { if (holdable.owner == null && !this._guns.Contains((Thing)holdable)) { this._guns.Add((Thing)holdable); } } int count = this._ducks.Count; int num1 = 0; float num2 = 150f; float num3 = (float)(((double)this._beamHeight - (double)num2 * 2.0) / (count > 1 ? (double)(count - 1) : 1.0)); for (int index = 0; index < this._ducks.Count; ++index) { BeamDuck duck = this._ducks[index]; if (duck.leaving) { duck.duck.solid = true; duck.duck.hSpeed = this._leaveLeft ? -4f : 4f; duck.duck.vSpeed = 0.0f; if ((double)Math.Abs(duck.duck.position.x - this.x) > 24.0) { duck.duck.immobilized = false; this._ducks.RemoveAt(index); --index; continue; } } else { duck.duck.position.x = Lerp.FloatSmooth(duck.duck.position.x, this.position.x + (float)duck.sin2 * 1f, 0.2f); duck.duck.position.y = Lerp.FloatSmooth(duck.duck.position.y, (float)((double)num2 + (double)num3 * (double)index + (double)(float)duck.sin * 2.0), 0.08f); duck.duck.vSpeed = 0.0f; duck.duck.hSpeed = 0.0f; } if (!TitleScreen.hasMenusOpen && duck.duck.inputProfile.Pressed("LEFT")) { duck.leaving = true; this._leaveLeft = true; duck.duck.offDir = (sbyte)-1; this.entered = false; } ++num1; } for (int index = 0; index < this._guns.Count; ++index) { Thing gun = this._guns[index]; gun.vSpeed = 0.0f; gun.hSpeed = 0.0f; if ((double)Math.Abs(this.position.x - gun.position.x) < 6.0) { gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y - 3f), 0.1f); gun.alpha = Maths.LerpTowards(gun.alpha, 0.0f, 0.1f); if ((double)gun.alpha <= 0.0) { gun.y = -200f; this._guns.RemoveAt(index); --index; } } else { gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y), 0.2f); } } base.Update(); }
public override void Update() { if (this._lastOwner != null && this.owner == null) { this._lastOwner.frictionMod = 0.0f; this._lastOwner = (PhysicsObject)null; } this.collisionOffset = new Vec2(-2f, 0.0f); this.collisionSize = new Vec2(4f, 18f); if ((double)this._swing > 0.0) { this.collisionOffset = new Vec2(-9999f, 0.0f); this.collisionSize = new Vec2(4f, 18f); } this._swingVelocity = Maths.LerpTowards(this._swingVelocity, this._swingForce, 0.1f); Duck owner = this.owner as Duck; if (this.isServerForObject) { this._swing += this._swingVelocity; float num1 = this._swing - this._swingLast; this._swingLast = this._swing; if ((double)this._swing > 1.0) { this._swing = 1f; } if ((double)this._swing < 0.0) { this._swing = 0.0f; } this._sprite.flipH = false; this._sprite.flipV = false; if ((double)this._sparkWait > 0.0) { this._sparkWait -= 0.1f; } else { this._sparkWait = 0.0f; } if (owner != null) { if ((double)this._sparkWait == 0.0 && (double)this._swing == 0.0) { if (owner.grounded && owner.offDir > (sbyte)0 && (double)owner.hSpeed > 1.0) { this._sparkWait = 0.25f; Level.Add((Thing)Spark.New(this.x - 22f, this.y + 6f, new Vec2(0.0f, 0.5f))); } else if (owner.grounded && owner.offDir < (sbyte)0 && (double)owner.hSpeed < -1.0) { this._sparkWait = 0.25f; Level.Add((Thing)Spark.New(this.x + 22f, this.y + 6f, new Vec2(0.0f, 0.5f))); } } float hSpeed = owner.hSpeed; this._hPull = Maths.LerpTowards(this._hPull, owner.hSpeed, 0.15f); if ((double)Math.Abs(owner.hSpeed) < 0.100000001490116) { this._hPull = 0.0f; } float num2 = Math.Abs(this._hPull) / 2.5f; if ((double)num2 > 1.0) { num2 = 1f; } this.weight = (float)(8.0 - (double)num2 * 3.0); if ((double)this.weight <= 5.0) { this.weight = 5.1f; } float num3 = Math.Abs(owner.hSpeed - this._hPull); owner.frictionMod = 0.0f; if ((double)owner.hSpeed > 0.0 && (double)this._hPull > (double)owner.hSpeed) { owner.frictionMod = (float)(-(double)num3 * 1.79999995231628); } if ((double)owner.hSpeed < 0.0 && (double)this._hPull < (double)owner.hSpeed) { owner.frictionMod = (float)(-(double)num3 * 1.79999995231628); } this._lastDir = (int)owner.offDir; this._lastSpeed = hSpeed; if ((double)this._swing != 0.0 && (double)num1 > 0.0) { owner.hSpeed += (float)owner.offDir * (num1 * 3f) * this.weightMultiplier; owner.vSpeed -= num1 * 2f * this.weightMultiplier; } } } if ((double)this._swing < 0.5) { float num = this._swing * 2f; this._sprite.imageIndex = (int)((double)num * 10.0); this._sprite.angle = (float)(1.20000004768372 - (double)num * 1.5); this._sprite.yscale = (float)(1.0 - (double)num * 0.100000001490116); } else if ((double)this._swing >= 0.5) { float num = (float)(((double)this._swing - 0.5) * 2.0); this._sprite.imageIndex = 10 - (int)((double)num * 10.0); this._sprite.angle = (float)(-0.300000011920929 - (double)num * 1.5); this._sprite.yscale = (float)(1.0 - (1.0 - (double)num) * 0.100000001490116); this._fullSwing += 0.16f; if (!this._swung) { this._swung = true; if (this.duck != null && this.isServerForObject) { Level.Add((Thing) new ForceWave(this.x + (float)this.offDir * 4f + this.owner.hSpeed, this.y + 8f, (int)this.offDir, 0.15f, 4f + Math.Abs(this.owner.hSpeed), this.owner.vSpeed, this.duck)); } } } if ((double)this._swing == 1.0) { this._pressed = false; } if ((double)this._swing == 1.0 && !this._pressed && (double)this._fullSwing > 1.0) { this._swingForce = -0.08f; this._fullSwing = 0.0f; } if (this._sledgeSwing.finished) { this._sledgeSwing.speed = 0.0f; } this._lastOwner = this.owner as PhysicsObject; if (this.duck != null) { if (this.duck.action && !this._held && (double)this._swing == 0.0) { this._fullSwing = 0.0f; owner._disarmDisable = 30; owner.crippleTimer = 1f; this._sledgeSwing.speed = 1f; this._sledgeSwing.frame = 0; this._swingForce = 0.6f; this._pressed = true; this._swung = false; this._held = true; } if (!this.duck.action) { this._pressed = false; this._held = false; } } base.Update(); }
public override void Update() { this._waveMult = Lerp.Float(this._waveMult, 0.0f, 0.1f); if (this.isServerForObject) { this._magnetActive = this.action; } else if (this._magnetActive) { this._waveMult = 1f; } if ((double)this._beamSound.Volume > 0.00999999977648258 && this._beamSound.State != SoundState.Playing) { this._beamSound.Play(); } else if ((double)this._beamSound.Volume < 0.00999999977648258 && this._beamSound.State == SoundState.Playing) { this._beamSound.Stop(); } this._beamSound.Volume = Maths.LerpTowards(this._beamSound.Volume, this._magnetActive ? 0.1f : 0.0f, 0.1f); Vec2 p1_1 = this.Offset(this.barrelOffset); if (this._magnetActive && this.duck != null && this.duck.holdObject == this) { foreach (MagnaLine line in this._lines) { line.Update(); line.show = true; float num = this._ammoType.range; if (this._hasRay) { num = (this.barrelPosition - this._rayHit).length; } line.dist = num; } if (this._grabbed == null && this._stuck == null) { Holdable holdable1 = (Holdable)null; float val1 = 0.0f; Vec2 normalized1 = this.barrelVector.Rotate(Maths.DegToRad(90f), Vec2.Zero).normalized; for (int index = 0; index < 3; ++index) { Vec2 p1_2 = p1_1; if (index == 0) { p1_2 += normalized1 * 8f; } else if (index == 2) { p1_2 -= normalized1 * 8f; } foreach (Holdable holdable2 in Level.CheckLineAll <Holdable>(p1_2, p1_2 + this.barrelVector * this._ammoType.range)) { if (holdable2 != this && holdable2 != this.owner && (holdable2.owner != this.owner && holdable2.physicsMaterial == PhysicsMaterial.Metal) && (holdable2.duck == null || !(holdable2.duck.holdObject is MagnetGun))) { float length = (holdable2.position - p1_1).length; if (holdable1 == null || (double)length < (double)val1) { val1 = length; holdable1 = holdable2; } } } } this._hasRay = false; if (holdable1 != null && Level.CheckLine <Block>(p1_1, holdable1.position) == null) { float num = (float)((1.0 - (double)Math.Min(val1, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929); if (holdable1.owner is Duck duck && !(duck.holdObject is MagnetGun) && (double)num > 0.300000011920929) { if (!(holdable1 is Equipment) || holdable1.equippedDuck == null) { duck.ThrowItem(false); duck = (Duck)null; } else if (holdable1 is TinfoilHat) { duck.Unequip(holdable1 as Equipment); duck = (Duck)null; } } Vec2 normalized2 = (p1_1 - holdable1.position).normalized; // TODO if (duck != null && holdable1 is Equipment) if (false) { if (duck.ragdoll != null) { duck.ragdoll.makeActive = true; return; } if (!(holdable1.owner.realObject is Duck) && Network.isActive) { return; } holdable1.owner.realObject.hSpeed += normalized2.x * num; holdable1.owner.realObject.vSpeed += (float)((double)normalized2.y * (double)num * 4.0); if ((holdable1.owner.realObject as PhysicsObject).grounded && (double)holdable1.owner.realObject.vSpeed > 0.0) { holdable1.owner.realObject.vSpeed = 0.0f; } } else { this.Fondle((Thing)holdable1); holdable1.hSpeed += normalized2.x * num; holdable1.vSpeed += (float)((double)normalized2.y * (double)num * 4.0); if (holdable1.grounded && (double)holdable1.vSpeed > 0.0) { holdable1.vSpeed = 0.0f; } } this._hasRay = true; this._rayHit = holdable1.position; if (this.isServerForObject && (double)val1 < 20.0) { if (holdable1 is Equipment && holdable1.duck != null) { this._grabbed = holdable1.owner.realObject; holdable1.duck.immobilized = true; holdable1.duck.gripped = true; holdable1.duck.ThrowItem(); if (!(holdable1.owner.realObject is Duck)) { holdable1.owner.realObject.owner = this.owner; Thing.SuperFondle(holdable1.owner.realObject, DuckNetwork.localConnection); } } else { this._grabbed = (Thing)holdable1; holdable1.owner = this.owner; if (holdable1 is Grenade) { (holdable1 as Grenade).OnPressAction(); } } this.attachIndex += 1; } } else if (this.isServerForObject && this._stuck == null && ((double)Math.Abs(this.angle) < 0.0500000007450581 || (double)Math.Abs(this.angle) > 1.5)) { Vec2 position = this.owner.position; if (this.duck.sliding) { position.y += 4f; } Vec2 hitPos; Block block = Level.CheckRay <Block>(position, position + this.barrelVector * this._ammoType.range, out hitPos); this._hasRay = true; this._rayHit = hitPos; if (block != null && block.physicsMaterial == PhysicsMaterial.Metal) { float num = (float)((1.0 - (double)Math.Min((block.position - position).length, this._ammoType.range) / (double)this._ammoType.range) * 0.800000011920929); Vec2 vec2 = hitPos - this.duck.position; float length = vec2.length; vec2.Normalize(); this.owner.hSpeed += vec2.x * num; this.owner.vSpeed += vec2.y * num; if ((double)length < 20.0) { this._stuck = block; this._stickPos = hitPos; this._stickNormal = -this.barrelVector; this.attachIndex += 1; } } } } } else { if (this.isServerForObject) { if (this._grabbed != null) { this._grabbed.angle = 0.0f; if (this._grabbed is Holdable grabbed) { grabbed.owner = (Thing)null; grabbed.ReturnToWorld(); this.ReturnItemToWorld((Thing)grabbed); } if (this._grabbed is Duck grabbed2) { grabbed2.immobilized = false; grabbed2.gripped = false; grabbed2.crippleTimer = 1f; } this._grabbed.visible = true; this._grabbed.enablePhysics = true; this._grabbed.hSpeed = this.barrelVector.x * 5f; this._grabbed.vSpeed = this.barrelVector.y * 5f; this._grabbed = (Thing)null; this._collisionSize = new Vec2(14f, this._collisionSize.y); } if (this._stuck != null) { this._stuck = (Block)null; if (this.owner != null && !this._raised) { this.duck._groundValid = 6; } } } foreach (MagnaLine line in this._lines) { line.show = false; } } if (Network.isActive) { if (this._grabbed != null) { if (this._grabbed is TrappedDuck && this._grabbed.connection != this.connection) { this._grabbed = (Thing)(this._grabbed as TrappedDuck)._duckOwner; if (this._grabbed != null) { Duck grabbed2 = this._grabbed as Duck; grabbed2.immobilized = true; grabbed2.gripped = true; grabbed2.ThrowItem(); grabbed2._trapped = (TrappedDuck)null; } } if (this._grabbed is Duck grabbed) { grabbed.isGrabbedByMagnet = true; if (this.isServerForObject) { this.Fondle((Thing)grabbed); this.Fondle((Thing)grabbed.holdObject); foreach (Thing t in grabbed._equipment) { this.Fondle(t); } this.Fondle((Thing)grabbed._ragdollInstance); this.Fondle((Thing)grabbed._trappedInstance); this.Fondle((Thing)grabbed._cookedInstance); } } } if (this._grabbed == null && this._prevGrabDuck != null && this._prevGrabDuck is Duck) { (this._prevGrabDuck as Duck).isGrabbedByMagnet = false; } this._prevGrabDuck = this._grabbed; } if (this._grabbed != null && this.owner != null) { if (this.isServerForObject) { this.Fondle(this._grabbed); } this._grabbed.hSpeed = this.owner.hSpeed; this._grabbed.vSpeed = this.owner.vSpeed; this._grabbed.angle = this.angle; this._grabbed.visible = false; this._grabbed.offDir = this.offDir; this._grabbed.enablePhysics = false; this._collisionSize = new Vec2(16f + this._grabbed.width, this._collisionSize.y); if (this._grabbed is Duck grabbed) { grabbed.grounded = true; grabbed.sliding = false; grabbed.crouch = false; } else { this._grabbed.owner = (Thing)this; } } if (this.localAttachIndex < this.attachIndex) { for (int index = 0; index < 2; ++index) { Level.Add((Thing)SmallSmoke.New(p1_1.x + Rando.Float(-1f, 1f), p1_1.y + Rando.Float(-1f, 1f))); } SFX.Play("grappleHook"); for (int index = 0; index < 6; ++index) { Level.Add((Thing)Spark.New(p1_1.x - this.barrelVector.x * 2f + Rando.Float(-1f, 1f), p1_1.y - this.barrelVector.y * 2f + Rando.Float(-1f, 1f), this.barrelVector + new Vec2(Rando.Float(-1f, 1f), Rando.Float(-1f, 1f)))); } this.localAttachIndex = this.attachIndex; } if (this.isServerForObject) { if (this._magnetActive && this._raised && (this.duck != null && !this.duck.grounded) && this._grabbed == null) { this._keepRaised = true; } else { this._keepRaised = false; } if (this._stuck != null && this.duck != null) { if ((double)this._stickPos.y < (double)this.owner.position.y - 8.0) { this.owner.position = this._stickPos + this._stickNormal * 12f; this._raised = true; this._keepRaised = true; } else { this.owner.position = this._stickPos + this._stickNormal * 16f; this._raised = false; this._keepRaised = false; } this.owner.hSpeed = this.owner.vSpeed = 0.0f; this.duck.moveLock = true; } else if (this._stuck == null && this.duck != null) { this.duck.moveLock = false; } if (this.owner == null && this.prevOwner != null) { if (this.prevOwner is Duck prevOwner) { prevOwner.moveLock = false; } this._prevOwner = (Thing)null; } } base.Update(); }
public override void Update() { this._selectBeam.color = new Color(0.3f, (float)(0.300000011920929 + (double)this._wave2.normalized * 0.200000002980232), (float)(0.5 + (double)this._wave.normalized * 0.300000011920929)) * (1f + this._flash); this._flash = Maths.CountDown(this._flash, 0.1f); this._spawnWait -= 0.1f; if ((double)this._spawnWait < 0.0) { Level.Add((Thing) new BeamParticle(this.x, this.y + 190f, -0.8f - this._wave.normalized, false, Color.Cyan * 0.8f)); Level.Add((Thing) new BeamParticle(this.x, this.y + 190f, -0.8f - this._wave2.normalized, true, Color.LightBlue * 0.8f)); this._spawnWait = 1f; } foreach (Duck d in Level.CheckRectAll <Duck>(this.topLeft, this.bottomRight)) { if (d.isServerForObject) { this.TakeDuck(d); } } foreach (Holdable holdable in Level.CheckRectAll <Holdable>(this.topLeft, this.bottomRight)) { if (holdable.isServerForObject) { if (holdable is RagdollPart) { Duck captureDuck = (holdable as RagdollPart).doll.captureDuck; if (captureDuck != null) { (holdable as RagdollPart).doll.Unragdoll(); this.TakeDuck(captureDuck); } } else if (holdable.owner == null && !this._guns.Contains((Thing)holdable)) { this._guns.Add((Thing)holdable); } } } int count = this._ducks.Count; int num1 = 0; float num2 = (float)((double)this._beamHeight / (double)count / 2.0 + 20.0 * (count > 1 ? 1.0 : 0.0)); float num3 = (float)(((double)this._beamHeight - (double)num2 * 2.0) / (count > 1 ? (double)(count - 1) : 1.0)); for (int index = 0; index < this._ducks.Count; ++index) { BeamDuck duck = this._ducks[index]; if (duck.leaving) { duck.duck.solid = true; duck.duck.y = MathHelper.Lerp(duck.duck.position.y, duck.entryHeight, 0.35f); duck.duck.vSpeed = 0.0f; if ((double)Math.Abs(duck.duck.position.y - duck.entryHeight) < 4.0) { duck.duck.position.y = duck.entryHeight; duck.duck.hSpeed = (float)duck.entryDir * 3f; duck.duck.vSpeed = 0.0f; } if ((double)Math.Abs(duck.duck.position.x - this.x) > 24.0) { duck.duck.gravMultiplier = 1f; duck.duck.immobilized = false; duck.duck.beammode = false; this._ducks.RemoveAt(index); --index; continue; } } else { duck.duck.position.x = Lerp.FloatSmooth(duck.duck.position.x, this.position.x + (float)duck.sin2 * 1f, 0.4f); duck.duck.position.y = Lerp.FloatSmooth(duck.duck.position.y, (float)((double)num2 + (double)num3 * (double)index + (double)(float)duck.sin * 2.0), 0.1f); duck.duck.vSpeed = 0.0f; duck.duck.hSpeed = 0.0f; duck.duck.gravMultiplier = 0.0f; } if (duck.duck.inputProfile.Pressed("QUACK") && (double)Math.Abs(duck.duck.position.x - this.x) < 2.0) { duck.leaving = true; } ++num1; } for (int index = 0; index < this._guns.Count; ++index) { Thing gun = this._guns[index]; gun.vSpeed = 0.0f; gun.hSpeed = 0.0f; if ((double)Math.Abs(this.position.x - gun.position.x) < 6.0) { gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y - 3f), 0.1f); gun.alpha = Maths.LerpTowards(gun.alpha, 0.0f, 0.1f); if ((double)gun.alpha <= 0.0) { gun.y = -200f; this._guns.RemoveAt(index); --index; } } else { gun.position = Vec2.Lerp(gun.position, new Vec2(this.position.x, gun.position.y), 0.2f); } } base.Update(); }