public override void OnSoftImpact(MaterialThing with, ImpactedFrom from) { if (from == ImpactedFrom.Bottom && (double)this.hitWait == 0.0 && with.isServerForObject) { with.Fondle((Thing)this); } if (!this.isServerForObject || from != ImpactedFrom.Bottom || (double)this.hitWait != 0.0) { return; } this.hitWait = 1f; switch (with) { case Holdable holdable when holdable.lastThrownBy != null || holdable is RagdollPart && !Network.isActive: Duck lastThrownBy = holdable.lastThrownBy as Duck; if (holdable is RagdollPart) { break; } if (lastThrownBy != null) { PurpleBlock.StoreItem(lastThrownBy.profile, (Thing)with); } this.Bounce(); break; case Duck duck: StoredItem storedItem = PurpleBlock.GetStoredItem(duck.profile); if (storedItem.type != (System.Type)null && !this._served.Contains(duck.profile)) { this.contains = storedItem.type; this._contextThing = storedItem.thing; this.Pop(); this._hit = false; this._served.Add(duck.profile); } else { if (this._served.Contains(duck.profile)) { SFX.Play("scanFail"); } this.Bounce(); } if (duck.holdObject == null) { break; } Holdable holdObject = duck.holdObject; if (holdObject == null) { break; } PurpleBlock.StoreItem(duck.profile, (Thing)holdObject); break; } }
public static void StoreItem(Profile p, Thing t) { if (Network.isActive && t is RagdollPart || t is TrappedDuck) { return; } if (t is WeightBall) { t = (Thing)(t as WeightBall).collar; } StoredItem storedItem = PurpleBlock.GetStoredItem(p); System.Type type = t.GetType(); if (!(storedItem.type != type) && !(storedItem.type == typeof(RagdollPart)) && (!(t is TeamHat) || !(storedItem.thing is TeamHat) || (t as TeamHat).team == (storedItem.thing as TeamHat).team)) { return; } Thing thing; if (t is RagdollPart) { if (storedItem.thing != null && storedItem.thing is SpriteThing && (storedItem.thing as SpriteThing).persona == (t as RagdollPart)._persona) { return; } thing = (Thing) new SpriteThing(0.0f, 0.0f, (Sprite)(t as RagdollPart)._persona.defaultHead); (thing as SpriteThing).persona = (t as RagdollPart)._persona; } else { thing = Editor.CreateThing(type); } if (thing is TeamHat) { TeamHat teamHat1 = thing as TeamHat; TeamHat teamHat2 = t as TeamHat; teamHat1.sprite = teamHat2.sprite.CloneMap(); teamHat1.graphic = (Sprite)teamHat1.sprite; teamHat1.pickupSprite = teamHat2.pickupSprite.Clone(); teamHat1.team = teamHat2.team; } else if (thing.graphic == null) { thing.graphic = t.graphic.Clone(); } storedItem.sprite = thing.GetEditorImage(0, 0, true, (Effect)PurpleBlock._grayscaleEffect); storedItem.sprite.CenterOrigin(); if (t is RagdollPart) { storedItem.sprite.centerx += 2f; storedItem.sprite.centery += 4f; } storedItem.type = type; storedItem.thing = thing; SFX.Play("scanBeep"); }
public static void ResetMatchStuff() { PurpleBlock.Reset(); Highlights.ClearHighlights(); Crowd.GoHome(); GameMode.lastWinners.Clear(); Deathmatch.levelsSinceRandom = 0; Deathmatch.levelsSinceCustom = 0; GameMode.numMatchesPlayed = 0; GameMode.showdown = false; RockWeather.Reset(); Music.Reset(); foreach (Team team in Teams.all) { team.prevScoreboardScore = team.score = 0; if (team.activeProfiles.Count > 0) { foreach (Profile activeProfile in team.activeProfiles) { activeProfile.stats.lastPlayed = activeProfile.stats.lastPlayed = DateTime.Now; activeProfile.RecordPreviousStats(); Profiles.Save(activeProfile); } } } if (Profiles.all != null) { foreach (Profile profile in Profiles.all) { profile?.RecordPreviousStats(); } } Global.Save(); Options.Save(); Crowd.InitializeCrowd(); }
public override void Update() { if ((double)this.hitWait > 0.0) { this.hitWait -= 0.1f; } else { this.hitWait = 0.0f; } this._alternate = !this._alternate; this._scanner.alpha = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858); this._projector.alpha = (float)(0.400000005960464 + (double)this._wave.normalized * 0.600000023841858) * this._projectorAlpha; this._currentProjection.alpha = (float)(0.400000005960464 + (double)this._projectionFlashWave.normalized * 0.600000023841858); this._currentProjection.alpha -= this._glitch * 3f; this._currentProjection.alpha *= this._projectorAlpha; this._double = Maths.CountDown(this._double, 0.15f); this._glitch = Maths.CountDown(this._glitch, 0.1f); if ((double)Rando.Float(1f) < 0.00999999977648258) { this._glitch = 0.3f; this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f); this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f); this._projectorGlitch.flipH = (double)Rando.Float(1f) > 0.5; } if ((double)Rando.Float(1f) < 0.00499999988824129) { this._glitch = 0.3f; this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f); this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f); this._projectorGlitch.flipH = (double)Rando.Float(1f) > 0.5; this._useWave = !this._useWave; } if ((double)Rando.Float(1f) < 0.00800000037997961) { this._glitch = 0.3f; this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f); this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f); this._projectorGlitch.flipH = (double)Rando.Float(1f) > 0.5; this._useWave = !this._useWave; this._double = 0.6f + Rando.Float(0.6f); } this._close.Clear(); if (this._hoverItem != null && this._hoverItem.owner != null) { this.BreakHoverBond(); } if (this._hoverItem == null) { Holdable holdable = Level.Nearest <Holdable>(this.x, this.y); if (holdable != null && holdable.owner == null && (holdable != null && holdable.canPickUp) && ((double)holdable.bottom <= (double)this.top && (double)Math.Abs(holdable.hSpeed) + (double)Math.Abs(holdable.vSpeed) < 2.0)) { float num = 999f; if (holdable != null) { num = (this.position - holdable.position).length; } if ((double)num < 24.0) { this._hoverItem = holdable; } } } else if ((double)Math.Abs(this._hoverItem.hSpeed) + (double)Math.Abs(this._hoverItem.vSpeed) > 2.0 || (double)(this._hoverItem.position - this.position).length > 25.0) { this.BreakHoverBond(); } else { this._hoverItem.position = Lerp.Vec2Smooth(this._hoverItem.position, this.position + new Vec2(0.0f, (float)(-12.0 - (double)this._hoverItem.collisionSize.y / 2.0 + (double)(float)this._projectionWave * 2.0)), 0.2f); this._hoverItem.vSpeed = 0.0f; this._hoverItem.gravMultiplier = 0.0f; } foreach (Duck duck in this._level.things[typeof(Duck)]) { if (!duck.dead && (double)(duck.position - this.position).length < 64.0) { this._close.Add(duck.profile); this._closeGlitch = false; } } this._closeWait = Maths.CountDown(this._closeWait, 0.05f); for (int index = 0; index < this._close.Count; ++index) { if (this._close.Count == 1) { this._closeIndex = 0; } else if (this._close.Count > 1 && index == this._closeIndex && (double)this._closeWait <= 0.0) { this._closeIndex = (this._closeIndex + 1) % this._close.Count; this._closeWait = 1f; this._glitch = 0.3f; this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f); this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f); this._projectorGlitch.flipH = (double)Rando.Float(1f) > 0.5; this._useWave = !this._useWave; this._double = 0.6f + Rando.Float(0.6f); break; } } if (this._closeIndex >= this._close.Count) { this._closeIndex = 0; } if (this._close.Count == 0) { if (!this._closeGlitch) { this._closeWait = 1f; this._glitch = 0.3f; this._projectorGlitch.xscale = 0.8f + Rando.Float(0.7f); this._projectorGlitch.yscale = 0.6f + Rando.Float(0.5f); this._projectorGlitch.flipH = (double)Rando.Float(1f) > 0.5; this._useWave = !this._useWave; this._double = 0.6f + Rando.Float(0.6f); this._closeGlitch = true; } this._projectorAlpha = Maths.CountDown(this._projectorAlpha, 0.1f); this._currentProjection = this._none; } else { StoredItem storedItem = PurpleBlock.GetStoredItem(this._close[this._closeIndex]); this._currentProjection = storedItem.sprite != null ? (!this._served.Contains(this._close[this._closeIndex]) ? storedItem.sprite : (this._alternate ? storedItem.sprite : this._none)) : this._none; this._projectorAlpha = Maths.CountUp(this._projectorAlpha, 0.1f); } this._projectorGlitch.alpha = this._glitch * this._projectorAlpha; base.Update(); }