public static void Draw() { if (RhythmMode._bar == null) { RhythmMode._bar = new Sprite("rhythmBar"); } if (RhythmMode._ball == null) { RhythmMode._ball = new Sprite("rhythmBall"); RhythmMode._ball.CenterOrigin(); } Vec2 vec2 = new Vec2(Layer.HUD.camera.width / 2f - (float)(RhythmMode._bar.w / 2), 10f); Graphics.Draw(RhythmMode._bar, vec2.x, vec2.y); for (int index = 0; index < 5; ++index) { float x = (float)((double)vec2.x + 2.0 + (double)(index * (RhythmMode._bar.w / 4) + 1) + (double)RhythmMode._pos * ((double)RhythmMode._bar.w / 4.0)); float num = Maths.Clamp((float)(((double)x - (double)vec2.x) / ((double)RhythmMode._bar.w - 2.0)), 0.0f, 1f); RhythmMode._ball.alpha = (float)((Math.Sin((double)num * (2.0 * Math.PI) - Math.PI / 2.0) + 1.0) / 2.0); if ((index == 1 && (double)RhythmMode._pos > 0.5 || index == 2 && (double)RhythmMode._pos <= 0.5) && RhythmMode.inTime) { RhythmMode._ball.scale = new Vec2(2f, 2f); } else { RhythmMode._ball.scale = new Vec2(1f, 1f); } Graphics.Draw(RhythmMode._ball, x, vec2.y + 4f); } }
public override void Update() { base.Update(); this._shakeInc += 0.8f; this._shakeMult = Lerp.Float(this._shakeMult, 0.0f, 0.05f); if (this._alternate == 0) { foreach (FluidStream hole in this._holes) { hole.onFire = this.onFire; hole.hSpeed = this.hSpeed; hole.vSpeed = this.vSpeed; hole.DoUpdate(); hole.position = this.Offset(hole.offset); hole.sprayAngle = this.OffsetLocal(hole.startSprayAngle); float num1 = (float) (1.0 - ((double) hole.offset.y - (double) this.topLocal) / ((double) this.bottomLocal - (double) this.topLocal)); if ((double) hole.x > (double) this.left - 2.0 && (double) hole.x < (double) this.right + 2.0 && (double) num1 < (double) this._fluidLevel) { float num2 = Maths.Clamp(this._fluidLevel - num1, 0.1f, 1f) * 0.0012f * hole.holeThickness; FluidData fluid = this._fluid; fluid.amount = num2; hole.Feed(fluid); this._fluidLevel -= num2; } } } this.weight = this._fluidLevel * 10f; ++this._alternate; if (this._alternate <= 4) return; this._alternate = 0; }
public override void Draw() { if (this._tracer || (double)this._bulletDistance <= 0.100000001490116) { return; } float length = (this.drawStart - this.drawEnd).length; float val = 0.0f; float num1 = (float)(1.0 / ((double)length / 8.0)); float num2 = 0.0f; float num3 = 8f; while (true) { bool flag = false; if ((double)val + (double)num3 > (double)length) { num3 = length - Maths.Clamp(val, 0.0f, 99f); flag = true; } num2 += num1; DuckGame.Graphics.DrawTexturedLine((Tex2D)this._beem, this.drawStart + this.travelDirNormalized * val, this.drawStart + this.travelDirNormalized * (val + num3), Color.White * num2, this._thickness, new Depth(0.6f)); if (!flag) { val += 8f; } else { break; } } }
public float CalculateDepth() { float distance = this.FeedAmountToDistance(this.data.amount); if ((double)this._wide == 0.0) { this._wide = 1f / 1000f; } return(Maths.Clamp(distance / this._wide, 1f, 99999f)); }
public static int GetCompressedVec2(Vec2 val, int range = 2147483647) { if (range != int.MaxValue) { float num = (float)((int)short.MaxValue / range); val.x = Maths.Clamp(val.x, (float)-range, (float)range) * num; val.y = Maths.Clamp(val.y, (float)-range, (float)range) * num; } return((int)((long)(ushort)Maths.Clamp((int)Math.Round((double)val.x), (int)short.MinValue, (int)short.MaxValue) << 16 | (long)(ushort)Maths.Clamp((int)Math.Round((double)val.y), (int)short.MinValue, (int)short.MaxValue))); }
public override void PostDrawLayer(Layer layer) { if (layer == Layer.Background) { Vec2 vec2_1 = new Vec2(0.0f, 0.0f); float num1 = -260f; float num2 = 140f; for (int index1 = 0; index1 < 7; ++index1) { int index2 = this.ProfileIndexAdd(this._selectorPosition, index1 - 3); string str = "NO PROFILE"; if (index2 != -1) { str = this._profiles[index2].name; } float num3 = (float)((double)vec2_1.x + (double)num1 + 3.0 * (double)num2); float x = (float)((double)vec2_1.x + (double)num1 + (double)index1 * (double)num2 + -(double)this._slide * (double)num2); float num4 = Maths.Clamp((float)((100.0 - (double)Math.Abs(x - num3)) / 100.0), 0.0f, 1f); float num5 = num4 * Maths.NormalizeSection(num4, 0.0f, 0.9f); this._door.color = Color.White * num5 * this._fade; this._door.depth = (Depth)(num5 * 0.8f); if ((double)num5 < 1.0) { this._unlitDoor.alpha = (float)((1.0 - (double)num5) * 0.5) * this._fade; Graphics.Draw(this._unlitDoor, x, 90f); } if ((double)num5 > 0.0) { Graphics.Draw(this._door, x, 90f); } string text = str; float num6 = (float)(((double)num5 + 1.0) * 0.5); float num7 = 0.0f; float num8 = 0.0f; Vec2 vec2_2 = new Vec2(1f, 1f); if (text.Length > 9) { vec2_2 = new Vec2(0.75f, 0.75f); num7 = 1f; num8 = 1f; } if (text.Length > 12) { vec2_2 = new Vec2(0.5f, 0.5f); num7 = 2f; num8 = 1f; } Graphics.DrawString(text, new Vec2(x - Graphics.GetStringWidth(text, scale: vec2_2.x) / 2f + num8, 35f + num7), new Color((byte)Math.Round(165.0 * (double)num6), (byte)Math.Round(100.0 * (double)num6), (byte)Math.Round(34.0 * (double)num6)) * this._fade, new Depth(0.9f), scale: vec2_2.x); } this._door.scale = new Vec2(1f, 1f); this._door.depth = new Depth(0.4f); } base.PostDrawLayer(layer); }
public override void Draw() { base.Draw(); this._light.depth = this.depth + 1; float num1 = (float)((double)(this._hitPoints / this._maxHealth) * 0.699999988079071 + 0.300000011920929); float g = 1f; float num2 = 1f; if ((double)this._hitPoints < (double)this._maxHealth / 2.0) { g = 0.0f; num2 = 0.4f; } this._light.color = new Color(1f - g, g, 0.2f) * Maths.Clamp(num2 + this._colorFlux.normalized * (1f - num2), 0.0f, 1f); Graphics.Draw(this._light, this.x, this.y); }
public override void Draw() { this._selectProjector.depth = new Depth(-0.51f); this._selectProjector.alpha = (float)(0.300000011920929 + (double)this._projectorSin.normalized * 0.200000002980232); this._selectPlatform.depth = new Depth(-0.51f); int count = this._profiles.Count; int num1 = 0; foreach (Profile profile in this._profiles) { Color color = new Color(0.35f, 0.5f, 0.6f); profile.persona.sprite.alpha = Maths.Clamp(this._swapFade, 0.0f, 1f); profile.persona.sprite.color = color * (float)(0.699999988079071 + (double)this._projectorSin.normalized * 0.100000001490116); profile.persona.sprite.color = new Color(profile.persona.sprite.color.r, profile.persona.sprite.color.g, profile.persona.sprite.color.b); profile.persona.armSprite.alpha = Maths.Clamp(this._swapFade, 0.0f, 1f); profile.persona.armSprite.color = color * (float)(0.699999988079071 + (double)this._projectorSin.normalized * 0.100000001490116); profile.persona.armSprite.color = new Color(profile.persona.armSprite.color.r, profile.persona.armSprite.color.g, profile.persona.armSprite.color.b); profile.persona.sprite.scale = new Vec2(1f, 1f); profile.persona.armSprite.scale = new Vec2(1f, 1f); float num2 = 12f; float num3 = (float)((double)this.x - (double)(count - 1) * (double)num2 / 2.0 + (double)num1 * (double)num2); profile.persona.sprite.depth = (Depth)(float)((double)num1 * 0.00999999977648258 - 0.400000005960464); profile.persona.armSprite.depth = (Depth)(float)((double)num1 * 0.00999999977648258 - 0.300000011920929); Graphics.Draw((Sprite)profile.persona.sprite, num3 + 1f, this.y - 17f, new Depth(-0.4f)); Graphics.Draw((Sprite)profile.persona.armSprite, (float)((double)num3 + 1.0 - 3.0), (float)((double)this.y - 17.0 + 6.0)); Team team = profile.team; if (team != null) { Vec2 hatPoint = DuckRig.GetHatPoint(profile.persona.sprite.imageIndex); team.hat.depth = profile.persona.sprite.depth + 1; team.hat.alpha = profile.persona.sprite.alpha; team.hat.color = profile.persona.sprite.color; team.hat.center = new Vec2(16f, 16f) + team.hatOffset; Graphics.Draw((Sprite)team.hat, (float)((double)num3 + (double)hatPoint.x + 1.0), this.y - 17f + hatPoint.y); team.hat.color = Color.White; } this._profile.persona.sprite.color = Color.White; this._profile.persona.armSprite.color = Color.White; ++num1; } Graphics.Draw(this._selectPlatform, this.x, this.y); Graphics.Draw(this._selectProjector, this.x, this.y - 6f); }
public override object GetNetValue() { int num1 = (int)BitBuffer.GetMaxValue(this._bits) / 2; float val = (float)this.value; float num2; if (this.isRotation) { if ((double)val < 0.0) { double num3 = (double)this._range / 2.0; val = val % -this._range + this._range; } num2 = val % this._range / this._range; } else { num2 = Maths.Clamp(val, -this._range, this._range) / this._range; } return((object)(int)Math.Round((double)num2 * (double)num1)); }
public override void Update() { if (!this._opening && this.opened && Editor.gamepadMode) { if (this._gridMenu != null && this._gridMenu.opened || this._saveMenu != null && this._saveMenu.opened || (this._newMenu != null && this._newMenu.opened || this._quitMenu != null && this._quitMenu.opened) || this._uploadMenu != null && this._uploadMenu.opened) { return; } if (Input.Pressed("UP")) { this.opened = false; if (this.owner is ContextMenu owner) { owner._opening = true; foreach (ToolbarButton button in this._buttons) { button.hover = false; } Editor.infoText = ""; return; } } if (Input.Pressed("DOWN")) { this.opened = false; if (this.owner is ContextMenu owner) { ++owner.selectedIndex; foreach (ToolbarButton button in this._buttons) { button.hover = false; } Editor.infoText = ""; return; } } if (Input.Pressed("LEFT")) { --this._selectedIndex; } else if (Input.Pressed("RIGHT")) { ++this._selectedIndex; } this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._buttons.Count - 1); int num = 0; foreach (ToolbarButton button in this._buttons) { if (this._selectedIndex == num) { button.hover = true; Editor.infoText = button.hoverText; if (Input.Pressed("SELECT")) { this.ButtonPressed(button); } } else { button.hover = false; } ++num; } } float x = this.position.x; this._newButton.x = x; this._newButton.y = this.position.y; float num1 = x + 18f; this._saveButton.x = num1; this._saveButton.y = this.position.y; float num2 = num1 + 18f; this._loadButton.x = num2; this._loadButton.y = this.position.y; float num3 = num2 + 18f; this._playButton.x = num3; this._playButton.y = this.position.y; float num4 = num3 + 18f; this._gridButton.x = num4; this._gridButton.y = this.position.y; if (Steam.IsInitialized()) { num4 += 18f; this._steamButton.x = num4; this._steamButton.y = this.position.y; } this._quitButton.x = num4 + 18f; this._quitButton.y = this.position.y; foreach (Thing button in this._buttons) { button.DoUpdate(); } base.Update(); }
public override void Update() { base.Update(); this.offDir = (sbyte)1; if ((double)this._hitPoints <= 0.0) { if (this.graphic != this._toreUp) { float num1 = this._fluidLevel * 0.5f; float num2 = this._fluidLevel * 0.5f; FluidData fluid = this._fluid; fluid.amount = num1 / 20f; for (int index = 0; index < 20; ++index) { Level.Add((Thing) new Fluid(this.x + Rando.Float(-4f, 4f), this.y + Rando.Float(-4f, 4f), new Vec2(Rando.Float(-4f, 4f), Rando.Float(-4f, 0.0f)), fluid)); } fluid.amount = num2; Level.Add((Thing) new Fluid(this.x, this.y - 8f, new Vec2(0.0f, -1f), fluid)); Level.Add((Thing)SmallSmoke.New(this.x, this.y)); SFX.Play("bulletHitWater"); SFX.Play("crateDestroy"); } this.graphic = (Sprite)this._toreUp; this._onFire = false; this.burnt = 0.0f; this._weight = 0.1f; this._collisionSize.y = 8f; this._collisionOffset.y = -3f; } this.burnSpeed = 0.0015f; if (this._onFire && (double)this.burnt < 0.899999976158142) { if ((double)this.burnt > 0.300000011920929) { this.graphic = this._melting; } this.yscale = (float)(0.5 + (1.0 - (double)this.burnt) * 0.5); this.centery = (float)(8.0 - (double)this.burnt * 7.0); this._collisionOffset.y = (float)((double)this.burnt * 7.0 - 8.0); this._collisionSize.y = (float)(16.0 - (double)this.burnt * 7.0); } if (!this._bottomHoles && (double)this.burnt > 0.600000023841858) { this._bottomHoles = true; this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(-1f, -1f), 1f, new Vec2(-7f, 8f)) { holeThickness = 2f }); this._holes.Add(new FluidStream(0.0f, 0.0f, new Vec2(1f, -1f), 1f, new Vec2(7f, 8f)) { holeThickness = 2f }); } if (this._owner != null) { this.hSpeed = this.owner.hSpeed; this.vSpeed = this.owner.vSpeed; } if (this._alternate == 0) { foreach (FluidStream hole in this._holes) { hole.onFire = this.onFire; hole.hSpeed = this.hSpeed; hole.vSpeed = this.vSpeed; hole.DoUpdate(); hole.position = this.Offset(hole.offset); hole.sprayAngle = this.OffsetLocal(hole.startSprayAngle); float num1 = (float)(1.0 - ((double)hole.offset.y - (double)this.topLocal) / ((double)this.bottomLocal - (double)this.topLocal)); if ((double)hole.x > (double)this.left - 2.0 && (double)hole.x < (double)this.right + 2.0 && (double)num1 < (double)this._fluidLevel) { float num2 = Maths.Clamp(this._fluidLevel - num1, 0.1f, 1f) * 0.008f * hole.holeThickness; FluidData fluid = this._fluid; fluid.amount = num2; hole.Feed(fluid); this._fluidLevel -= num2; this._lossAccum += num2; while ((double)this._lossAccum > 0.0500000007450581) { this._lossAccum -= 0.05f; if (this.sequence != null && this.sequence.isValid && ChallengeLevel.running) { ++ChallengeLevel.goodiesGot; SFX.Play("tinyTick"); } } } } } this.weight = this._fluidLevel * 10f; ++this._alternate; if (this._alternate <= 4) { return; } this._alternate = 0; }
// Token: 0x060015CD RID: 5581 public override void Update() //When used { Duck duck = this.owner as Duck; if (duck != null) { if (base.isServerForObject) { this.handPitch = 1f - Mouse.x / Layer.HUD.camera.width * 2f; if (this.handPitch < 0f) //Prevents hand and pitch going too far { float currentpitch = this.handPitch; float neededpitch = 0f - this.handPitch; this.handPitch = currentpitch + neededpitch; } if (duck.inputProfile.Down("SHOOT")) { this.notePitch = this.handPitch + 0.01f; } else { this.notePitch = 0f; } } if (this.notePitch != this.prevNotePitch) { if (this.notePitch != 0f) { int num = (int)Math.Round((double)(this.notePitch * 12f)); if (num < 0) { num = 0; } if (num > 12) { num = 12; } if (this.noteSound == null) { this.hitPitch = this.notePitch; Sound sound = SFX.Play("trombone" + Change.ToString(num), 1f, 0f, 0f, false); this.noteSound = sound; Level.Add(new MusicNote(base.barrelPosition.x, base.barrelPosition.y, base.barrelVector)); } else { this.noteSound.Pitch = Maths.Clamp(this.notePitch - this.hitPitch, -1f, 1f); } } else if (this.noteSound != null) { this.noteSound.Stop(); this.noteSound = null; } } if (this._raised) { this.handAngle = 0f; this.handOffset = new Vec2(0f, 0f); this._holdOffset = new Vec2(0f, 2f); this.collisionOffset = new Vec2(-4f, -7f); this.collisionSize = new Vec2(8f, 16f); } else //Hand pitch { this.handOffset = new Vec2(6f + (1f - this.handPitch) * 4f, -4f + (1f - this.handPitch) * 4f); this.handAngle = (1f - this.handPitch) * 0.4f * (float)this.offDir; this._holdOffset = new Vec2(5f + this.handPitch * 2f, -9f + this.handPitch * 2f); this.collisionOffset = new Vec2(-4f, -7f); this.collisionSize = new Vec2(2f, 16f); this._slideVal = 1f - this.handPitch; } } else { this.collisionOffset = new Vec2(-4f, -5f); this.collisionSize = new Vec2(8f, 11f); } this.prevNotePitch = this.notePitch; base.Update(); }
public override void Update() { ++this._framesSinceFeed; this.fluidWave += 0.1f; if ((double)this.data.amount < 9.99999974737875E-05) { Level.Remove((Thing)this); } if ((double)this.collisionSize.y > 10.0) { ++this.bubbleWait; if (this.bubbleWait > Rando.Int(15, 25)) { for (int index = 0; index < (int)Math.Floor((double)this.collisionSize.x / 16.0); ++index) { if ((double)Rando.Float(1f) > 0.850000023841858) { Level.Add((Thing) new TinyBubble(this.left + (float)(index * 16) + Rando.Float(-4f, 4f), this.bottom + Rando.Float(-4f), 0.0f, this.top + 10f)); } } this.bubbleWait = 0; } foreach (PhysicsObject physicsObject in Level.CheckRectAll <PhysicsObject>(this.topLeft, this.bottomRight)) { physicsObject.sleeping = false; } } FluidPuddle fluidPuddle = Level.CheckLine <FluidPuddle>(new Vec2(this.left, this.y), new Vec2(this.right, this.y), (Thing)this); if (fluidPuddle != null && (double)fluidPuddle.data.amount < (double)this.data.amount) { fluidPuddle.active = false; float num1 = Math.Min(fluidPuddle.left, this.left); float num2 = Math.Max(fluidPuddle.right, this.right); this.x = num1 + (float)(((double)num2 - (double)num1) / 2.0); this.Feed(fluidPuddle.data); Level.Remove((Thing)fluidPuddle); } if (this._leftStream != null) { this._leftStream.Update(); this._leftStream.onFire = this.onFire; } if (this._rightStream != null) { this._rightStream.Update(); this._rightStream.onFire = this.onFire; } float distance = this.FeedAmountToDistance(this.data.amount); if ((double)this._wide == 0.0) { this._wide = 1f / 1000f; } float num = Maths.Clamp(distance / this._wide, 1f, 99999f); if (this.onFire) { this._fireRise = Lerp.FloatSmooth(this._fireRise, 1f, 0.1f, 1.2f); if (this._framesSinceFeed > 10) { FluidData data = this.data; data.amount = -1f / 1000f; this.Feed(data); if ((double)this.data.amount <= 0.0) { this.data.amount = 0.0f; this.alpha = Lerp.Float(this.alpha, 0.0f, 0.04f); } else { this.alpha = Lerp.Float(this.alpha, 1f, 0.04f); } if ((double)this.alpha <= 0.0) { Level.Remove((Thing)this); } } } else { this.alpha = Lerp.Float(this.alpha, 1f, 0.04f); if ((double)num < 3.0) { FluidData data = this.data; data.amount = -0.0001f; this.Feed(data); } } float depth = this.CalculateDepth(); if ((double)depth > 4.0 && !this._initializedUpperCorners) { this._initializedUpperCorners = true; foreach (BlockCorner groupCorner in this._block.GetGroupCorners()) { if (this._leftCorner != null && (double)groupCorner.corner.x == (double)this._leftCorner.corner.x && (double)groupCorner.corner.y < (double)this._leftCorner.corner.y) { if (this._topLeftCorner == null) { this._topLeftCorner = groupCorner; } else if ((double)groupCorner.corner.y > (double)this._topLeftCorner.corner.y) { this._topLeftCorner = groupCorner; } } else if (this._rightCorner != null && (double)groupCorner.corner.x == (double)this._rightCorner.corner.x && (double)groupCorner.corner.y < (double)this._rightCorner.corner.y) { if (this._topRightCorner == null) { this._topRightCorner = groupCorner; } else if ((double)groupCorner.corner.y > (double)this._topRightCorner.corner.y) { this._topRightCorner = groupCorner; } } } } if (this._leftStream != null) { this._leftStream.position.y = this.y - this._collisionOffset.y; } if (this._rightStream != null) { this._rightStream.position.y = this.y - this._collisionOffset.y; } this._collisionOffset.y = -depth; this._collisionSize.y = depth; }
public float CalculateProfileScore(bool log = false) { List <StatContribution> statContributionList = new List <StatContribution>(); float num1 = 0.0f; float num2 = 0.0f; float num3 = 0.0f; float num4 = 0.0f; if (this.timesSpawned > 0) { num4 = (float)((double)this.matchesWon / (double)this.timesSpawned * 0.400000005960464); } float num5 = num1 + num4; if ((double)num4 > 0.0) { num3 += num4; } else if ((double)num4 < 0.0) { num2 += num4; } statContributionList.Add(new StatContribution() { name = "MAT", amount = num4 }); if (this.gamesPlayed > 0) { num4 = (float)((double)this.trophiesWon / (double)this.gamesPlayed * 0.400000005960464); } float num6 = num5 + num4; if ((double)num4 > 0.0) { num3 += num4; } else if ((double)num4 < 0.0) { num2 += num4; } statContributionList.Add(new StatContribution() { name = "WON", amount = num4 }); int num7 = this.timesKilled; if (num7 < 1) { num7 = 1; } float num8 = (float)Math.Log(1.0 + (double)this.kills / (double)num7) * 0.4f; float num9 = num6 + num8; if ((double)num8 > 0.0) { num3 += num8; } else if ((double)num8 < 0.0) { num2 += num8; } statContributionList.Add(new StatContribution() { name = "KDR", amount = num8 }); float num10 = (float)((double)Maths.Clamp((DateTime.Now - this.lastPlayed).Days, 0, 60) / 60.0 * 0.5); float num11 = num9 + num10; if ((double)num10 > 0.0) { num3 += num10; } else if ((double)num10 < 0.0) { num2 += num10; } statContributionList.Add(new StatContribution() { name = "LVE", amount = num10 }); float num12 = (float)Math.Log(1.0 + (double)this.quacks * 9.99999974737875E-05) * 0.4f; float num13 = num11 + num12; if ((double)num12 > 0.0) { num3 += num12; } else if ((double)num12 < 0.0) { num2 += num12; } statContributionList.Add(new StatContribution() { name = "CHR", amount = num12 }); float num14 = (float)Math.Log(0.75 + (double)this.coolness * 0.025000000372529); float num15 = num13 + num14; if ((double)num14 > 0.0) { num3 += num14; } else if ((double)num14 < 0.0) { num2 += num14; } statContributionList.Add(new StatContribution() { name = "COO", amount = num14 }); float num16 = (float)Math.Log(1.0 + (double)this.bulletsFired * 9.99999974737875E-05); float num17 = num15 + num16; if ((double)num16 > 0.0) { num3 += num16; } else if ((double)num16 < 0.0) { num2 += num16; } statContributionList.Add(new StatContribution() { name = "SHT", amount = num16 }); if (this.bulletsFired > 0) { num16 = (float)((double)this.bulletsThatHit / (double)this.bulletsFired * 0.200000002980232 - 0.100000001490116); } float num18 = num17 + num16; if ((double)num16 > 0.0) { num3 += num16; } else if ((double)num16 < 0.0) { num2 += num16; } statContributionList.Add(new StatContribution() { name = "ACC", amount = num16 }); float num19 = (float)Math.Log(1.0 + (double)this.disarms * 0.000500000023748726) * 0.5f; float num20 = num18 + num19; if ((double)num19 > 0.0) { num3 += num19; } else if ((double)num19 < 0.0) { num2 += num19; } statContributionList.Add(new StatContribution() { name = "DSM", amount = num19 }); float num21 = -(float)(Math.Log(1.0 + (double)(this.timesLitOnFire + this.timesMindControlled + this.timesNetted + this.timesDisarmed + this.minesSteppedOn + this.fallDeaths) * 0.000500000023748726) * 0.5); float num22 = num20 + num21; if ((double)num21 > 0.0) { num3 += num21; } else if ((double)num21 < 0.0) { num2 += num21; } statContributionList.Add(new StatContribution() { name = "BAD", amount = num21 }); float num23 = (float)(-((double)Maths.Clamp((DateTime.Now - this.lastWon).Days, 0, 60) / 60.0) * 0.300000011920929); float num24 = num22 + num23; if ((double)num23 > 0.0) { num3 += num23; } else if ((double)num23 < 0.0) { num2 += num23; } statContributionList.Add(new StatContribution() { name = "LOS", amount = num23 }); float num25 = (float)Math.Log(1.0 + (double)this.timesJumped * 9.99999974737875E-05) * 0.2f; float num26 = num24 + num25; if ((double)num25 > 0.0) { num3 += num25; } else if ((double)num25 < 0.0) { num2 += num25; } statContributionList.Add(new StatContribution() { name = "JMP", amount = num25 }); float num27 = (float)Math.Log(1.0 + (double)this.timeWithMouthOpen * (1.0 / 1000.0)) * 0.5f; float num28 = num26 + num27; if ((double)num27 > 0.0) { num3 += num27; } else if ((double)num27 < 0.0) { num2 += num27; } statContributionList.Add(new StatContribution() { name = "MTH", amount = num27 }); float num29 = (float)Math.Log(1.0 + (double)this.timesSwore) * 0.5f; float num30 = num28 + num29; if ((double)num29 > 0.0) { num3 += num29; } else if ((double)num29 < 0.0) { num2 += num29; } statContributionList.Add(new StatContribution() { name = "SWR", amount = num29 }); if (log && (double)num30 != 0.0) { foreach (StatContribution statContribution in statContributionList) { float num31 = 0.0f; if ((double)statContribution.amount != 0.0) { num31 = (double)statContribution.amount <= 0.0 ? (float)((double)Math.Abs(statContribution.amount) / (double)Math.Abs(num2) * ((double)Math.Abs(num2) / ((double)num3 + (double)Math.Abs(num2)))) : (float)((double)Math.Abs(statContribution.amount) / (double)Math.Abs(num3) * ((double)num3 / ((double)num3 + (double)Math.Abs(num2)))); } if ((double)statContribution.amount < 0.0) { num31 = -num31; } float num32 = 0.5f; float num33 = 0.5f; float r; float g; if ((double)num31 < 0.0) { r = num32 + Math.Abs(num31) * 0.5f; g = num33 - Math.Abs(num31) * 0.5f; } else { g = num33 + Math.Abs(num31) * 0.5f; r = num32 - Math.Abs(num31) * 0.5f; } DevConsole.Log(statContribution.name + ": " + (num31 * 100f).ToString("0.000") + "%", new Color(r, g, 0.0f), 1f); } } return(num30); }
public override void Update() { if (this.owner is Duck owner) { if (this.isServerForObject) { this.handPitch = owner.inputProfile.leftTrigger; this.notePitch = !owner.inputProfile.Down("SHOOT") ? 0.0f : this.handPitch + 0.01f; } if ((double)this.notePitch != (double)this.prevNotePitch) { if ((double)this.notePitch != 0.0) { int num = (int)Math.Round((double)this.notePitch * 12.0); if (num < 0) { num = 0; } if (num > 12) { num = 12; } if (this.noteSound == null) { this.hitPitch = this.notePitch; this.noteSound = SFX.Play("sax" + Change.ToString((object)num)); Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector)); } else { this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.100000001490116), -1f, 1f); } } else if (this.noteSound != null) { this.noteSound.Stop(); this.noteSound = (Sound)null; } } if (this._raised) { this.handAngle = 0.0f; this.handOffset = new Vec2(0.0f, 0.0f); this._holdOffset = new Vec2(0.0f, 2f); this.collisionOffset = new Vec2(-4f, -7f); this.collisionSize = new Vec2(8f, 16f); this.OnReleaseAction(); } else { this.handOffset = new Vec2((float)(5.0 + (1.0 - (double)this.handPitch) * 2.0), (float)((1.0 - (double)this.handPitch) * 4.0 - 2.0)); this.handAngle = (float)((1.0 - (double)this.handPitch) * 0.400000005960464) * (float)this.offDir; this._holdOffset = new Vec2((float)(4.0 + (double)this.handPitch * 2.0), this.handPitch * 2f); this.collisionOffset = new Vec2(-1f, -7f); this.collisionSize = new Vec2(2f, 16f); } } else { this.collisionOffset = new Vec2(-4f, -7f); this.collisionSize = new Vec2(8f, 16f); } this.prevNotePitch = this.notePitch; base.Update(); }
public int GetProfileScore() => (int)Math.Round((double)Maths.Clamp((float)((double)this.CalculateProfileScore() * 0.300000011920929 * 250.0), -50f, 200f));
public override void Update() { if (!this.opened || this._dialog.opened || (this._deleteDialog.opened || this._overwriteDialog.opened) || this._opening) { this._opening = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = true; } } else { bool flag = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = false; if (!flag && contextMenu.hover) { flag = true; string str = ""; int startIndex = this._currentDirectory.IndexOf(this._rootFolder); if (startIndex != -1) { str = this._currentDirectory.Remove(startIndex, this._rootFolder.Length); } if (str != "" && !str.EndsWith("/")) { str += "/"; } if (str.StartsWith("/")) { str = str.Substring(1, str.Length - 1); } string path = str + contextMenu.data; if (this._prevPreviewPath != path) { if (path.EndsWith(".lev")) { if (this._preview == null || !(this._preview is RenderTarget2D)) { this._preview = (Tex2D) new RenderTarget2D(320, 200); } this._preview = (Tex2D)Content.GeneratePreview(path.Substring(0, path.Length - 4), this._preview as RenderTarget2D); } else if (path.EndsWith(".png")) { Texture2D texture2D = ContentPack.LoadTexture2D(this._currentDirectory + "/" + Path.GetFileName(path)); this._preview = texture2D == null ? Content.invalidTexture : (this._type != ContextFileType.Block && this._type != ContextFileType.Background && this._type != ContextFileType.Platform || texture2D.Width == 128 && texture2D.Height == 128 ? (this._type != ContextFileType.Parallax || texture2D.Width == 320 && texture2D.Height == 240 ? (this._type != ContextFileType.ArcadeStyle || texture2D.Width == 27 && texture2D.Height == 34 || texture2D.Width == 54 && texture2D.Height == 68 ? (Tex2D)texture2D : this._badArcade.texture) : this._badParallax.texture) : this._badTileset.texture); } else { this._previewSprite = (Sprite)null; this._prevPreviewPath = (string)null; } this._previewSprite = new Sprite(this._preview); if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax)) { this._previewSprite.scale = new Vec2(2f, 2f); } this._prevPreviewPath = path; } } } if (!flag && this._type == ContextFileType.ArcadeStyle) { this._preview = this._badArcade.texture; this._previewSprite = new Sprite(this._preview); this._prevPreviewPath = (string)null; } Editor.lockInput = (ContextMenu)this; base.Update(); this._scrollWait = Lerp.Float(this._scrollWait, 0.0f, 0.2f); if (this._dialog.result != null && this._dialog.result != "") { Editor current = Level.current as Editor; current._guid = Guid.NewGuid().ToString(); Editor.ResetWorkshopData(); current.DoSave(this._currentDirectory + "/" + this._dialog.result); this._dialog.result = ""; this.Close(); } if (!this._overwriteDialog.opened && this._doOverwriteDialog) { this._doOverwriteDialog = false; if (this._overwriteDialog.result) { (Level.current as Editor).DoSave(this._currentDirectory + "/" + this._overwriteName); this._overwriteDialog.result = false; this._overwriteName = ""; this.Close(); } } if (!this._deleteDialog.opened && this._doDeleteDialog) { this._doDeleteDialog = false; if (this._deleteDialog.result) { foreach (ContextMenu contextMenu in this._items) { if (contextMenu.hover) { Editor.Delete(this._currentDirectory + "/" + contextMenu.text); break; } } this.ClearItems(); this.SetDirectory(this._currentDirectory); } } if (Keyboard.Pressed(Keys.Escape) || Mouse.right == InputState.Pressed || Input.Pressed("QUACK")) { this.Close(); } if (!this._selectLevels && Input.Pressed("GRAB")) { this._deleteDialog.Open("CONFIRM DELETE"); Editor.lockInput = (ContextMenu)this._deleteDialog; this._doDeleteDialog = true; this._deleteDialog.result = false; } else { if (Input.Pressed("LEFT")) { this._selectedIndex -= this._maxItems; } else if (Input.Pressed("RIGHT")) { this._selectedIndex += this._maxItems; } this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._items.Count - 1); if (this._items.Count <= this._maxItems) { return; } float num1 = 1f / (float)(this._items.Count - this._maxItems); if ((double)Mouse.scroll != 0.0) { this._scrollPosition += (float)Math.Sign(Mouse.scroll) * num1; if ((double)this._scrollPosition > 1.0) { this._scrollPosition = 1f; } if ((double)this._scrollPosition < 0.0) { this._scrollPosition = 0.0f; } } int num2 = (int)Math.Round(((double)(this._items.Count - this._maxItems) - 1.0) * (double)this._scrollPosition); int num3 = 0; int num4 = 0; for (int index = 0; index < this._items.Count; ++index) { if (this._items[index].hover) { num4 = index; break; } } if (Editor.gamepadMode) { if (num4 > num2 + this._maxItems) { this._scrollPosition += (float)(num4 - (num2 + this._maxItems)) * num1; } else if (num4 < num2) { this._scrollPosition -= (float)(num2 - num4) * num1; } } for (int index = 0; index < this._items.Count; ++index) { this._items[index].disabled = false; if (index < num2 || index > num2 + this._maxItems) { this._items[index].visible = false; this._items[index].hover = false; } else { ContextMenu contextMenu = this._items[index]; this._items[index].visible = true; this._items[index].position = new Vec2(this._items[index].position.x, (float)((double)this.y + 3.0 + (double)num3 * (double)this._items[index].itemSize.y)); ++num3; } } } } }
public string GetCoolnessString() => this._hotnessStrings[(int)Math.Floor((double)((float)(Maths.Clamp(this.GetProfileScore(), -50, 200) + 50) / 250f) * 8.98999977111816)];
public override void Update() { if (this.owner is Duck owner) { if (this.isServerForObject) { if (owner.inputProfile.Pressed("SHOOT")) { this.currentPitch = 2; } if (owner.inputProfile.Pressed("STRAFE")) { this.currentPitch = 0; } if (owner.inputProfile.Pressed("RAGDOLL")) { this.currentPitch = 1; } if ((double)owner.inputProfile.leftTrigger > 0.5 && !this.leftPressed) { this.currentPitch = 2; this.leftPressed = true; } if ((double)owner.inputProfile.rightTrigger > 0.5 && !this.rightPressed) { this.currentPitch = 3; this.rightPressed = true; } if (owner.inputProfile.Released("STRAFE") && this.currentPitch == 0) { this.currentPitch = -1; } if (owner.inputProfile.Released("SHOOT") && this.currentPitch == 2) { this.currentPitch = -1; } if (owner.inputProfile.Released("RAGDOLL") && this.currentPitch == 1) { this.currentPitch = -1; } if ((double)owner.inputProfile.leftTrigger <= 0.5) { if (this.currentPitch == 2 && this.leftPressed) { this.currentPitch = -1; } this.leftPressed = false; } if ((double)owner.inputProfile.rightTrigger <= 0.5) { if (this.currentPitch == 3 && this.rightPressed) { this.currentPitch = -1; } this.rightPressed = false; } this.notePitch = this.currentPitch < 0 || this._raised ? 0.0f : (float)((double)this.currentPitch / 3.0 + 0.00999999977648258); } if ((double)this.notePitch != (double)this.prevNotePitch) { if ((double)this.notePitch != 0.0) { if (this.noteSound != null) { this.noteSound.Stop(); this.noteSound = (Sound)null; } int num = (int)Math.Round((double)this.notePitch * 3.0); if (num < 0) { num = 0; } if (num > 12) { num = 12; } if (this.noteSound == null) { this.hitPitch = this.notePitch; this.noteSound = SFX.Play("trumpet0" + Change.ToString((object)(num + 1)), 0.8f); Level.Add((Thing) new MusicNote(this.barrelPosition.x, this.barrelPosition.y, this.barrelVector)); } else { this.noteSound.Pitch = Maths.Clamp((float)(((double)this.notePitch - (double)this.hitPitch) * 0.00999999977648258), -1f, 1f); } } else if (this.noteSound != null) { this.noteSound.Stop(); this.noteSound = (Sound)null; } } if (this._raised) { this.collisionOffset = new Vec2(4f, -4f); this.collisionSize = new Vec2(8f, 8f); this._holdOffset = new Vec2(0.0f, 0.0f); this.handOffset = new Vec2(0.0f, 0.0f); this.OnReleaseAction(); } else { this.collisionOffset = new Vec2(-6f, -4f); this.collisionSize = new Vec2(8f, 8f); this._holdOffset = new Vec2(10f, -2f); this.handOffset = new Vec2(5f, -2f); } } else { this.leftPressed = false; this.rightPressed = false; this.currentPitch = -1; this.collisionOffset = new Vec2(-6f, -4f); this.collisionSize = new Vec2(8f, 8f); this._holdOffset = new Vec2(6f, 2f); } this.prevNotePitch = this.notePitch; base.Update(); }
public static float NormalizeSection(float value, float sectionMin, float sectionMax) => Maths.Clamp(Maths.Clamp(value - sectionMin, 0.0f, sectionMax) / (sectionMax - sectionMin), 0.0f, 1f);
public override void Update() { if (this._harpoon == null) { return; } if (this.isServerForObject) { this.ropeData.Clear(); this.SerializeRope(this._rope); } else { this.ropeData.SeekToStart(); this.DeserializeRope(this._rope); } if (this._rope != null) { this._rope.SetServer(this.isServerForObject); } if (this.isServerForObject && this._equippedDuck != null && this.duck != null) { if (this.duck._trapped != null) { this.Degrapple(); } ATTracer atTracer = new ATTracer(); float num = atTracer.range = this._grappleLength; atTracer.penetration = 1f; float ang = 45f; if (this.offDir < (sbyte)0) { ang = 135f; } if (this._harpoon.inGun) { Vec2 p1 = this.Offset(this.barrelOffset); if (this._lagFrames > 0) { --this._lagFrames; if (this._lagFrames == 0) { this._canGrab = false; } else { ang = Maths.PointDirection(p1, this._lastHit); } } atTracer.penetration = 9f; Bullet bullet = new Bullet(p1.x, p1.y, (AmmoType)atTracer, ang, this.owner, tracer: true); this._wallPoint = bullet.end; this._grappleTravel = bullet.travelDirNormalized; num = (p1 - this._wallPoint).length; } if ((double)num < (double)this._grappleLength - 2.0 && (double)num <= (double)this._grappleDist + 16.0) { this._lastHit = this._wallPoint; this._canGrab = true; } else if (this._canGrab && this._lagFrames == 0) { this._lagFrames = 6; this._wallPoint = this._lastHit; } else { this._canGrab = false; } this._grappleDist = num; if (this.duck.inputProfile.Pressed("JUMP") && this.duck._trapped == null) { if (this._harpoon.inGun) { if (!this.duck.grounded && this.duck.framesSinceJump > 6 && this._canGrab && (!(this.duck.holdObject is TV) || (this.duck.holdObject as TV)._ruined || (!(this.duck.holdObject as TV).channel || !this.duck._double) || this.duck._groundValid <= 0)) { this._harpoon.Fire(this.wallPoint, this.grappelTravel); this._rope = new Rope(this.barrelPosition.x, this.barrelPosition.y, (Thing)null, (Thing)this._harpoon, (Thing)this.duck, tex: this._ropeSprite, belongsTo: ((Thing)this)); Level.Add((Thing)this._rope); } } else { this.Degrapple(); this._lagFrames = 0; this._canGrab = false; } } } base.Update(); if (this.owner != null) { this.offDir = this.owner.offDir; } if (this.duck != null) { this.duck.grappleMul = false; } if (!this.isServerForObject || this._rope == null) { return; } if (this.owner != null) { this._rope.position = this.owner.position; } else { this._rope.position = this.position; if (this.prevOwner != null) { PhysicsObject prevOwner = this.prevOwner as PhysicsObject; prevOwner.frictionMult = 1f; prevOwner.gravMultiplier = 1f; this._prevOwner = (Thing)null; this.frictionMult = 1f; this.gravMultiplier = 1f; if (this.prevOwner is Duck) { (this.prevOwner as Duck).grappleMul = false; } } } if (!this._harpoon.stuck) { return; } if (this.duck != null) { if (!this.duck.grounded) { this.duck.frictionMult = 0.0f; } else { this.duck.frictionMult = 1f; this.duck.gravMultiplier = 1f; } if ((double)this._rope.properLength > 0.0) { if (this.duck.inputProfile.Down("UP") && (double)this._rope.properLength >= 16.0) { this._rope.properLength -= 2f; } if (this.duck.inputProfile.Down("DOWN") && (double)this._rope.properLength <= 256.0) { this._rope.properLength += 2f; } this._rope.properLength = Maths.Clamp(this._rope.properLength, 16f, 256f); } } else if (!this.grounded) { this.frictionMult = 0.0f; } else { this.frictionMult = 1f; this.gravMultiplier = 1f; } Vec2 vec2_1 = this._rope.attach1.position - this._rope.attach2.position; if ((double)this._rope.properLength < 0.0) { this._rope.properLength = vec2_1.length; } if ((double)vec2_1.length <= (double)this._rope.properLength) { return; } vec2_1 = vec2_1.normalized; if (this.duck != null) { this.duck.grappleMul = true; PhysicsObject duck = (PhysicsObject)this.duck; if (this.duck.ragdoll != null) { this.Degrapple(); } else { Vec2 position = duck.position; duck.position = this._rope.attach2.position + vec2_1 * this._rope.properLength; Vec2 vec2_2 = duck.position - duck.lastPosition; duck.hSpeed = vec2_2.x; duck.vSpeed = vec2_2.y; } } else { Vec2 position = this.position; this.position = this._rope.attach2.position + vec2_1 * this._rope.properLength; Vec2 vec2_2 = this.position - this.lastPosition; this.hSpeed = vec2_2.x; this.vSpeed = vec2_2.y; } }
public override void Activate(string trigger) { if (this._filterField != null) { if (!(bool)this._filterField.value && trigger == "RIGHT") { SFX.Play("textLetter", 0.7f); this._filterField.value = (object)true; this._field.value = (object)(int)this._field.min; return; } if ((bool)this._filterField.value && trigger == "LEFT" && (double)(int)this._field.value == (double)this._field.min) { SFX.Play("textLetter", 0.7f); this._filterField.value = (object)false; return; } if (this._setting != null && trigger == "GRAB") { SFX.Play("textLetter", 0.7f); if (this._setting.filterMode == FilterMode.GreaterThan) { this._setting.filterMode = FilterMode.Equal; return; } if (this._setting.filterMode == FilterMode.Equal) { this._setting.filterMode = FilterMode.LessThan; return; } if (this._setting.filterMode != FilterMode.LessThan) { return; } this._setting.filterMode = FilterMode.GreaterThan; return; } } int num1 = (int)this._field.value; if (trigger == "LEFT") { this._field.value = (object)((int)this._field.value - this.GetStep((int)this._field.value, false)); } else if (trigger == "RIGHT") { this._field.value = (object)((int)this._field.value + this.GetStep((int)this._field.value, true)); } int index = (int)Maths.Clamp((float)(int)this._field.value, this._field.min, this._field.max); if (this._upperBoundField != null && index > (int)this._upperBoundField.value) { this._upperBoundField.value = (object)index; } if (this._lowerBoundField != null && index < (int)this._lowerBoundField.value) { this._lowerBoundField.value = (object)index; } if (num1 != (int)this._field.value) { SFX.Play("textLetter", 0.7f); } int num2 = index - num1; this._field.value = (object)index; if (num2 > 0) { int num3 = num2; using (List <FieldBinding> .Enumerator enumerator = this.percentageGroup.GetEnumerator()) { label_29: while (enumerator.MoveNext()) { FieldBinding current = enumerator.Current; while (true) { if ((double)(int)current.value > (double)current.min && num3 > 0) { int num4 = (int)current.value - (int)current.inc; current.value = (object)num4; num3 -= (int)current.inc; } else { goto label_29; } } } } } else if (num2 < 0) { int num3 = num2; using (List <FieldBinding> .Enumerator enumerator = this.percentageGroup.GetEnumerator()) { label_37: while (enumerator.MoveNext()) { FieldBinding current = enumerator.Current; while (true) { if ((double)(int)current.value < (double)current.max && num3 < 0) { int num4 = (int)current.value + (int)current.inc; current.value = (object)num4; num3 += (int)current.inc; } else { goto label_37; } } } } } if (this._textItem == null || index < 0 || index >= this._valueStrings.Count) { return; } this._textItem.text = this._valueStrings[index]; }
public void Feed(FluidData dat) { if (this._lava == null && dat.sprite != "" && dat.sprite != null) { if (this.data.sprite == null) { this.data.sprite = dat.sprite; } this._lava = new SpriteMap(dat.sprite, 16, 16); this._lava.AddAnimation("idle", 0.1f, true, 0, 1, 2, 3); this._lava.SetAnimation("idle"); this._lava.center = new Vec2(8f, 10f); this._lavaAlternate = new SpriteMap(dat.sprite, 16, 16); this._lavaAlternate.AddAnimation("idle", 0.1f, true, 2, 3, 0, 1); this._lavaAlternate.SetAnimation("idle"); this._lavaAlternate.center = new Vec2(8f, 10f); } if (this._lightRect == null && Layer.lighting) { this._lightRect = new WhiteRectangle(this.x, this.y, this.width, this.height, (double)dat.heat <= 0.0); Level.Add((Thing)this._lightRect); } if ((double)dat.amount > 0.0) { this._framesSinceFeed = 0; } this.data.Mix(dat); this.data.amount = Maths.Clamp(this.data.amount, 0.0f, this.MaxFluidFill()); this._wide = this.FeedAmountToDistance(this.data.amount); float num1 = this._wide + 4f; this._collisionOffset.x = (float)-((double)num1 / 2.0); this._collisionSize.x = num1; this.FeedEdges(); if (this._leftCorner != null && this._rightCorner != null && (double)this._wide > (double)this._rightCorner.corner.x - (double)this._leftCorner.corner.x) { this._wide = this._rightCorner.corner.x - this._leftCorner.corner.x; this.x = this._leftCorner.corner.x + (float)(((double)this._rightCorner.corner.x - (double)this._leftCorner.corner.x) / 2.0); } float num2 = this._wide + 4f; this._collisionOffset.x = (float)-((double)num2 / 2.0); this._collisionSize.x = num2; if (!(this.data.sprite == "water") || this._leftCorner == null) { return; } Block block = this._leftCorner.block; while (true) { switch (block) { case null: goto label_19; case SnowTileset _: if ((double)block.left + 2.0 > (double)this.left && (double)block.right - 2.0 < (double)this.right) { (block as SnowTileset).Freeze(); break; } break; case SnowIceTileset _: if ((double)block.left + 2.0 > (double)this.left && (double)block.right - 2.0 < (double)this.right) { (block as SnowIceTileset).Freeze(); break; } break; } block = block.rightBlock; } label_19 :; }