public void DrawDamageModifiers(SpriteBatch spriteBatch, Camera cam, Vector2 startPos, bool isScreenSpace) { foreach (var modifier in damageModifiers) { //Vector2 up = VectorExtensions.Backward(-body.TransformedRotation + Params.GetSpriteOrientation() * Dir); //int width = 4; //if (!isScreenSpace) //{ // width = (int)Math.Round(width / cam.Zoom); //} //GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(up) * size, Color.Red, width: width); Color color = modifier.DamageMultiplier > 1 ? Color.Red : Color.GreenYellow; float size = ConvertUnits.ToDisplayUnits(body.GetSize().Length() / 2); if (isScreenSpace) { size *= cam.Zoom; } int thickness = 2; if (!isScreenSpace) { thickness = (int)Math.Round(thickness / cam.Zoom); } float bodyRotation = -body.Rotation; float constantOffset = -MathHelper.PiOver2; Vector2 armorSector = modifier.ArmorSectorInRadians; float armorSectorSize = Math.Abs(armorSector.X - armorSector.Y); float radians = armorSectorSize * Dir; float armorSectorOffset = armorSector.X * Dir; float finalOffset = bodyRotation + constantOffset + armorSectorOffset; ShapeExtensions.DrawSector(spriteBatch, startPos, size, radians, 40, color, finalOffset, thickness); } }
public void DrawDamageModifiers(SpriteBatch spriteBatch, Camera cam, Vector2 startPos, bool isScreenSpace) { foreach (var modifier in damageModifiers) { float rotation = -body.TransformedRotation + GetArmorSectorRotationOffset(modifier.ArmorSectorInRadians) * Dir; Vector2 forward = VectorExtensions.Forward(rotation); float size = ConvertUnits.ToDisplayUnits(body.GetSize().Length() / 2); if (isScreenSpace) { size *= cam.Zoom; } Color color = modifier.DamageMultiplier > 1 ? Color.Red : Color.GreenYellow; int width = 4; if (!isScreenSpace) { width = (int)Math.Round(width / cam.Zoom); } GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(forward) * size, color, width: width); int thickness = 2; if (!isScreenSpace) { thickness = (int)Math.Round(thickness / cam.Zoom); } ShapeExtensions.DrawSector(spriteBatch, startPos, size, GetArmorSectorSize(modifier.ArmorSectorInRadians) * Dir, 40, color, rotation + MathHelper.Pi, thickness); } }
public void DebugDraw(SpriteBatch spriteBatch) { foreach (ScriptedEvent ev in activeEvents) { Vector2 drawPos = ev.DebugDrawPos; drawPos.Y = -drawPos.Y; var textOffset = new Vector2(-150, 0); ShapeExtensions.DrawCircle(spriteBatch, drawPos, 600, 6, Color.White, thickness: 20); GUI.DrawString(spriteBatch, drawPos + textOffset, ev.ToString(), Color.White, Color.Black, 0, GUI.LargeFont); } }
public void Draw(SpriteBatch spriteBatch) { if (!ShowAITargets) { return; } var pos = new Vector2(WorldPosition.X, -WorldPosition.Y); if (soundRange > 0.0f) { Color color; if (Entity is Character) { color = Color.Yellow; } else if (Entity is Item) { color = Color.Orange; } else { color = Color.OrangeRed; } ShapeExtensions.DrawCircle(spriteBatch, pos, SoundRange, 100, color, thickness: 1 / Screen.Selected.Cam.Zoom); ShapeExtensions.DrawCircle(spriteBatch, pos, 3, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom); } if (sightRange > 0.0f) { Color color; if (Entity is Character) { color = Color.CornflowerBlue; } else if (Entity is Item) { color = Color.CadetBlue; // disable the indicators for items, because they clutter the debug view return; } else { color = Color.WhiteSmoke; // disable the indicators for structures, because they clutter the debug view return; } ShapeExtensions.DrawCircle(spriteBatch, pos, SightRange, 100, color, thickness: 1 / Screen.Selected.Cam.Zoom); ShapeExtensions.DrawCircle(spriteBatch, pos, 6, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom); } }
public virtual void Draw(SpriteBatch spriteBatch, float deltaTime) { PreDraw?.Invoke(spriteBatch, deltaTime); var drawRect = DrawRect; switch (shape) { case Shape.Rectangle: if (secondaryColor.HasValue) { GUI.DrawRectangle(spriteBatch, drawRect, secondaryColor.Value, isFilled, thickness: 2); } GUI.DrawRectangle(spriteBatch, drawRect, color, isFilled, thickness: IsSelected ? 3 : 1); break; case Shape.Circle: if (secondaryColor.HasValue) { ShapeExtensions.DrawCircle(spriteBatch, DrawPos, size / 2, sides, secondaryColor.Value, thickness: 2); } ShapeExtensions.DrawCircle(spriteBatch, DrawPos, size / 2, sides, color, thickness: IsSelected ? 3 : 1); break; case Shape.Cross: float halfSize = size / 2; if (secondaryColor.HasValue) { GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitY * halfSize, DrawPos - Vector2.UnitY * halfSize, secondaryColor.Value, width: 2); GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitX * halfSize, DrawPos - Vector2.UnitX * halfSize, secondaryColor.Value, width: 2); } GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitY * halfSize, DrawPos - Vector2.UnitY * halfSize, color, width: IsSelected ? 3 : 1); GUI.DrawLine(spriteBatch, DrawPos + Vector2.UnitX * halfSize, DrawPos - Vector2.UnitX * halfSize, color, width: IsSelected ? 3 : 1); break; default: throw new NotImplementedException(shape.ToString()); } if (IsSelected) { if (showTooltip && !string.IsNullOrEmpty(tooltip)) { var offset = tooltipOffset ?? new Vector2(size, -size / 2); GUI.DrawString(spriteBatch, DrawPos + offset, tooltip, textColor, textBackgroundColor); } } PostDraw?.Invoke(spriteBatch, deltaTime); }
public void Draw(SpriteBatch spriteBatch) { if (!ShowAITargets) { return; } var pos = new Vector2(WorldPosition.X, -WorldPosition.Y); if (soundRange > 0.0f) { Color color = Entity is Character ? Color.Yellow : Color.Orange; ShapeExtensions.DrawCircle(spriteBatch, pos, SoundRange, 100, color, thickness: 1 / Screen.Selected.Cam.Zoom); } if (sightRange > 0.0f) { Color color = Entity is Character ? Color.CornflowerBlue : Color.CadetBlue; ShapeExtensions.DrawCircle(spriteBatch, pos, SightRange, 100, color, thickness: 1 / Screen.Selected.Cam.Zoom); } }
public void Draw(SpriteBatch spriteBatch, float textSizeHalf, float xPos, float yPos) { ShapeExtensions.DrawLine(spriteBatch, new Vector2(xPos - textSizeHalf - expand, yPos), new Vector2(xPos + textSizeHalf + expand, yPos), Color, thickness); }
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 hideLimb = wearingItems.Any(w => w != null && w.HideLimb); body.UpdateDrawPosition(); if (!hideLimb) { var activeSprite = ActiveSprite; if (DeformSprite != null && activeSprite == DeformSprite.Sprite) { 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); } else { body.Draw(spriteBatch, activeSprite, color, null, Scale * TextureScale); } } if (LightSource != null) { LightSource.Position = body.DrawPosition; LightSource.LightSpriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipVertically; } float depthStep = 0.000001f; WearableSprite onlyDrawable = wearingItems.Find(w => w.HideOtherWearables); SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; if (onlyDrawable == null) { if (HuskSprite != null && (character.SpeciesName == "Humanhusk" || (character.SpeciesName == "Human" && character.CharacterHealth.GetAffliction <AfflictionHusk>("huskinfection")?.State == AfflictionHusk.InfectionState.Active))) { DrawWearable(HuskSprite, depthStep, spriteBatch, color, spriteEffect); } foreach (WearableSprite wearable in OtherWearables) { DrawWearable(wearable, depthStep, spriteBatch, color, spriteEffect); //if there are multiple sprites on this limb, make the successive ones be drawn in front depthStep += 0.000001f; } } 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 += 0.000001f; } if (damageOverlayStrength > 0.0f && DamagedSprite != null && !hideLimb) { float depth = ActiveSprite.Depth - 0.0000015f; // TODO: enable when the damage overlay textures have been remade. //DamagedSprite.Draw(spriteBatch, // new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), // color * Math.Min(damageOverlayStrength, 1.0f), ActiveSprite.Origin, // -body.DrawRotation, // 1.0f, spriteEffect, depth); } 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(MathHelper.ToRadians(limbParams.Ragdoll.SpritesheetOrientation)); 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(ragdoll.RagdollParams.SpritesheetOrientation)))); //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); } foreach (var modifier in damageModifiers) { float rotation = -body.TransformedRotation + GetArmorSectorRotationOffset(modifier.ArmorSector) * Dir; Vector2 forward = VectorExtensions.Forward(rotation); float size = ConvertUnits.ToDisplayUnits(body.GetSize().Length() / 2); color = modifier.DamageMultiplier > 1 ? Color.Red : Color.GreenYellow; GUI.DrawLine(spriteBatch, bodyDrawPos, bodyDrawPos + Vector2.Normalize(forward) * size, color, width: (int)Math.Round(4 / cam.Zoom)); ShapeExtensions.DrawSector(spriteBatch, bodyDrawPos, size, GetArmorSectorSize(modifier.ArmorSector) * Dir, 40, color, rotation + MathHelper.Pi, thickness: 2 / cam.Zoom); } } }
public void Draw(SpriteBatch spriteBatch) { if (!ShowAITargets) { return; } var pos = new Vector2(WorldPosition.X, -WorldPosition.Y); float thickness = 1 / Screen.Selected.Cam.Zoom; float offset = MathUtils.VectorToAngle(new Vector2(sectorDir.X, -sectorDir.Y)) - (sectorRad / 2f); if (soundRange > 0.0f) { Color color; if (Entity is Character) { color = Color.Yellow; } else if (Entity is Item) { color = Color.Orange; } else { color = Color.OrangeRed; } if (sectorRad < MathHelper.TwoPi) { spriteBatch.DrawSector(pos, SoundRange, sectorRad, 100, color, offset: offset, thickness: thickness); } else { spriteBatch.DrawCircle(pos, SoundRange, 100, color, thickness: thickness); } spriteBatch.DrawCircle(pos, 3, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom); GUI.DrawLine(spriteBatch, pos, pos + Vector2.UnitY * SoundRange, color, width: (int)(1 / Screen.Selected.Cam.Zoom) + 1); } if (sightRange > 0.0f) { Color color; if (Entity is Character) { color = Color.CornflowerBlue; } else if (Entity is Item) { color = Color.CadetBlue; } else { //color = Color.WhiteSmoke; // disable the indicators for structures and hulls, because they clutter the debug view return; } if (sectorRad < MathHelper.TwoPi) { spriteBatch.DrawSector(pos, SightRange, sectorRad, 100, color, offset: offset, thickness: thickness); } else { spriteBatch.DrawCircle(pos, SightRange, 100, color, thickness: thickness); } ShapeExtensions.DrawCircle(spriteBatch, pos, 6, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom); GUI.DrawLine(spriteBatch, pos, pos + Vector2.UnitY * SightRange, color, width: (int)(1 / Screen.Selected.Cam.Zoom) + 1); } }