partial void RemoveProjSpecific() { Sprite?.Remove(); Sprite = null; DamagedSprite?.Remove(); DamagedSprite = null; _deformSprite?.Sprite?.Remove(); _deformSprite = null; DecorativeSprites.ForEach(s => s.Remove()); ConditionalSprites.Clear(); ConditionalSprites.ForEach(s => s.Remove()); ConditionalSprites.Clear(); LightSource?.Remove(); LightSource = null; OtherWearables?.ForEach(w => w.Sprite.Remove()); OtherWearables = null; HuskSprite?.Sprite.Remove(); HuskSprite = null; HerpesSprite?.Sprite.Remove(); HerpesSprite = null; }
public void UpdateWearableTypesToHide() { wearableTypeHidingSprites.Clear(); if (WearingItems != null && WearingItems.Count > 0) { wearableTypeHidingSprites.AddRange( WearingItems.FindAll(w => w.HideWearablesOfType != null && w.HideWearablesOfType.Count > 0)); } if (OtherWearables != null && OtherWearables.Count > 0) { wearableTypeHidingSprites.AddRange( OtherWearables.FindAll(w => w.HideWearablesOfType != null && w.HideWearablesOfType.Count > 0)); } wearableTypesToHide.Clear(); if (wearableTypeHidingSprites.Count > 0) { foreach (WearableSprite sprite in wearableTypeHidingSprites) { foreach (WearableType type in sprite.HideWearablesOfType) { if (!wearableTypesToHide.Contains(type)) { wearableTypesToHide.Add(type); } } } } }
partial void RemoveProjSpecific() { Sprite?.Remove(); Sprite = null; DamagedSprite?.Remove(); DamagedSprite = null; DeformSprite?.Sprite?.Remove(); DeformSprite = null; LightSource?.Remove(); LightSource = null; OtherWearables?.ForEach(w => w.Sprite.Remove()); OtherWearables = null; }
public void Draw(SpriteBatch spriteBatch, Camera cam, Color?overrideColor = null) { float brightness = 1.0f - (burnOverLayStrength / 100.0f) * 0.5f; Color color = new Color(brightness, brightness, brightness); color = overrideColor ?? color; if (isSevered) { if (severedFadeOutTimer > SeveredFadeOutTime) { return; } else if (severedFadeOutTimer > SeveredFadeOutTime - 1.0f) { color *= SeveredFadeOutTime - severedFadeOutTimer; } } body.Dir = Dir; bool enableHuskSprite = character.IsHusk || character.CharacterHealth.GetAffliction <AfflictionHusk>("huskinfection")?.State == AfflictionHusk.InfectionState.Active; float herpesStrength = character.CharacterHealth.GetAfflictionStrength("spaceherpes"); bool hideLimb = Params.Hide || enableHuskSprite && HuskSprite != null && HuskSprite.HideLimb || OtherWearables.Any(w => w.HideLimb) || wearingItems.Any(w => w != null && w.HideLimb); var activeSprite = ActiveSprite; if (type == LimbType.Head) { CalculateHeadPosition(activeSprite); } // TODO: there's now two calls to this, because body.Draw() method calls this too -> is this an issue? body.UpdateDrawPosition(); if (!hideLimb) { var deformSprite = DeformSprite; if (deformSprite != null) { if (Deformations != null && Deformations.Any()) { var deformation = SpriteDeformation.GetDeformation(Deformations, deformSprite.Size); deformSprite.Deform(deformation); } else { deformSprite.Reset(); } body.Draw(deformSprite, cam, Vector2.One * Scale * TextureScale, color, Params.MirrorHorizontally); } else { body.Draw(spriteBatch, activeSprite, color, null, Scale * TextureScale, Params.MirrorHorizontally, Params.MirrorVertically); } } SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; if (LightSource != null) { LightSource.Position = body.DrawPosition; if (LightSource.ParentSub != null) { LightSource.Position -= LightSource.ParentSub.DrawPosition; } LightSource.LightSpriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipVertically; } if (damageOverlayStrength > 0.0f && DamagedSprite != null && !hideLimb) { DamagedSprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), color * Math.Min(damageOverlayStrength, 1.0f), activeSprite.Origin, -body.DrawRotation, Scale, spriteEffect, activeSprite.Depth - 0.0000015f); } foreach (var decorativeSprite in DecorativeSprites) { if (!spriteAnimState[decorativeSprite].IsActive) { continue; } float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState); Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState) * Scale; var ca = (float)Math.Cos(-body.Rotation); var sa = (float)Math.Sin(-body.Rotation); Vector2 transformedOffset = new Vector2(ca * offset.X + sa * offset.Y, -sa * offset.X + ca * offset.Y); decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X + transformedOffset.X, -(body.DrawPosition.Y + transformedOffset.Y)), color, -body.Rotation + rotation, Scale, spriteEffect, depth: decorativeSprite.Sprite.Depth); } float depthStep = 0.000001f; float step = depthStep; WearableSprite onlyDrawable = wearingItems.Find(w => w.HideOtherWearables); if (Params.MirrorHorizontally) { spriteEffect = spriteEffect == SpriteEffects.None ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } if (Params.MirrorVertically) { spriteEffect |= SpriteEffects.FlipVertically; } if (onlyDrawable == null) { if (HerpesSprite != null) { DrawWearable(HerpesSprite, depthStep, spriteBatch, color * Math.Min(herpesStrength / 10.0f, 1.0f), spriteEffect); depthStep += step; } if (HuskSprite != null && enableHuskSprite) { DrawWearable(HuskSprite, depthStep, spriteBatch, color, spriteEffect); depthStep += step; } foreach (WearableSprite wearable in OtherWearables) { if (wearable.Type == WearableType.Beard && enableHuskSprite && HuskSprite != null) { continue; } DrawWearable(wearable, depthStep, spriteBatch, color, spriteEffect); //if there are multiple sprites on this limb, make the successive ones be drawn in front depthStep += step; } } foreach (WearableSprite wearable in WearingItems) { if (onlyDrawable != null && onlyDrawable != wearable) { continue; } DrawWearable(wearable, depthStep, spriteBatch, color, spriteEffect); //if there are multiple sprites on this limb, make the successive ones be drawn in front depthStep += step; } if (GameMain.DebugDraw) { if (pullJoint != null) { Vector2 pos = ConvertUnits.ToDisplayUnits(pullJoint.WorldAnchorB); GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 5, 5), Color.Red, true); } var bodyDrawPos = body.DrawPosition; bodyDrawPos.Y = -bodyDrawPos.Y; if (IsStuck) { Vector2 from = ConvertUnits.ToDisplayUnits(attachJoint.WorldAnchorA); from.Y = -from.Y; Vector2 to = ConvertUnits.ToDisplayUnits(attachJoint.WorldAnchorB); to.Y = -to.Y; var localFront = body.GetLocalFront(Params.GetSpriteOrientation()); var front = ConvertUnits.ToDisplayUnits(body.FarseerBody.GetWorldPoint(localFront)); front.Y = -front.Y; GUI.DrawLine(spriteBatch, bodyDrawPos, front, Color.Yellow, width: 2); GUI.DrawLine(spriteBatch, from, to, Color.Red, width: 1); GUI.DrawRectangle(spriteBatch, new Rectangle((int)from.X, (int)from.Y, 12, 12), Color.White, true); GUI.DrawRectangle(spriteBatch, new Rectangle((int)to.X, (int)to.Y, 12, 12), Color.White, true); GUI.DrawRectangle(spriteBatch, new Rectangle((int)from.X, (int)from.Y, 10, 10), Color.Blue, true); GUI.DrawRectangle(spriteBatch, new Rectangle((int)to.X, (int)to.Y, 10, 10), Color.Red, true); GUI.DrawRectangle(spriteBatch, new Rectangle((int)front.X, (int)front.Y, 10, 10), Color.Yellow, true); //Vector2 mainLimbFront = ConvertUnits.ToDisplayUnits(ragdoll.MainLimb.body.FarseerBody.GetWorldPoint(ragdoll.MainLimb.body.GetFrontLocal(MathHelper.ToRadians(limbParams.Orientation)))); //mainLimbFront.Y = -mainLimbFront.Y; //var mainLimbDrawPos = ragdoll.MainLimb.body.DrawPosition; //mainLimbDrawPos.Y = -mainLimbDrawPos.Y; //GUI.DrawLine(spriteBatch, mainLimbDrawPos, mainLimbFront, Color.White, width: 5); //GUI.DrawRectangle(spriteBatch, new Rectangle((int)mainLimbFront.X, (int)mainLimbFront.Y, 10, 10), Color.Yellow, true); } DrawDamageModifiers(spriteBatch, cam, bodyDrawPos, isScreenSpace: false); } }