public void DrawSectionColors(SpriteBatch spriteBatch) { if (BackgroundSections == null || BackgroundSections.Count == 0) { return; } Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition; Point sectionSize = BackgroundSections[0].Rect.Size; Vector2 drawPos = drawOffset + new Vector2(rect.Location.X + sectionSize.X / 2, rect.Location.Y - sectionSize.Y / 2); for (int i = 0; i < BackgroundSections.Count; i++) { BackgroundSection section = BackgroundSections[i]; if (section.ColorStrength < 0.01f || section.Color.A < 1) { continue; } if (GameMain.DecalManager.GrimeSprites.Count == 0) { GUI.DrawRectangle(spriteBatch, new Vector2(drawOffset.X + rect.X + section.Rect.X, -(drawOffset.Y + rect.Y + section.Rect.Y)), new Vector2(sectionSize.X, sectionSize.Y), section.GetStrengthAdjustedColor(), true, 0.0f, (int)Math.Max(1.5f / Screen.Selected.Cam.Zoom, 1.0f)); } else { Vector2 sectionPos = new Vector2(drawPos.X + section.Rect.Location.X, -(drawPos.Y + section.Rect.Location.Y)); Vector2 randomOffset = new Vector2(section.Noise.X - 0.5f, section.Noise.Y - 0.5f) * 15.0f; var sprite = GameMain.DecalManager.GrimeSprites[i % GameMain.DecalManager.GrimeSprites.Count]; sprite.Draw(spriteBatch, sectionPos + randomOffset, section.GetStrengthAdjustedColor(), scale: 1.25f); } } }
protected override void CreateViews() { if (m_background == null) { m_background = new BackgroundSection(); m_background.Initialize(); } if (m_header == null) { m_header = new HeaderSection(); m_header.Initialize(); } if (m_characterList == null) { m_characterList = new CharacterListSection(); m_characterList.Initialize(); } if (m_createHolder == null) { m_createHolder = new CreateHolderSection(); m_createHolder.Initialize(); } if (m_characterCreation == null) { m_characterCreation = new CharacterCreationSection(); m_characterCreation.Initialize(); } if (m_defaultSection == null) { m_defaultSection = new DefaultSection(); m_defaultSection.Initialize(); } }
public override void UpdateHUD(Character character, float deltaTime, Camera cam) { if (character == null || !character.IsKeyDown(InputType.Aim)) { return; } if (PlayerInput.KeyHit(InputType.PreviousFireMode)) { if (spraySetting > 0) { spraySetting--; } else { spraySetting = 2; } targetSections.Clear(); } if (PlayerInput.KeyHit(InputType.NextFireMode)) { if (spraySetting < 2) { spraySetting++; } else { spraySetting = 0; } targetSections.Clear(); } crosshairPointerPos = PlayerInput.MousePosition; Vector2 rayStart; Vector2 sourcePos = character?.AnimController == null ? item.SimPosition : character.AnimController.AimSourceSimPos; Vector2 barrelPos = item.SimPosition + TransformedBarrelPos; //make sure there's no obstacles between the base of the item (or the shoulder of the character) and the end of the barrel if (Submarine.PickBody(sourcePos, barrelPos, collisionCategory: Physics.CollisionItem | Physics.CollisionItemBlocking | Physics.CollisionWall) == null) { //no obstacles -> we start the raycast at the end of the barrel rayStart = ConvertUnits.ToSimUnits(item.WorldPosition) + TransformedBarrelPos; } else { targetHull = null; targetSections.Clear(); return; } Vector2 pos = character.CursorWorldPosition; Vector2 rayEnd = ConvertUnits.ToSimUnits(pos); rayStartWorldPosition = ConvertUnits.ToDisplayUnits(rayStart); if (Vector2.Distance(rayStartWorldPosition, pos) > Range) { targetHull = null; targetSections.Clear(); return; } #if DEBUG debugRayStartPos = ConvertUnits.ToDisplayUnits(rayStart); debugRayEndPos = ConvertUnits.ToDisplayUnits(rayEnd); #endif Submarine parentSub = character.Submarine ?? item.Submarine; if (parentSub != null) { rayStart -= parentSub.SimPosition; rayEnd -= parentSub.SimPosition; } var obstacles = Submarine.PickBodies(rayStart, rayEnd, collisionCategory: Physics.CollisionItem | Physics.CollisionItemBlocking | Physics.CollisionWall); foreach (var body in obstacles) { if (body.UserData is Item item) { var door = item.GetComponent <Door>(); if (door != null && door.CanBeTraversed) { continue; } } targetHull = null; targetSections.Clear(); return; } targetHull = Hull.GetCleanTarget(pos); if (targetHull == null) { targetSections.Clear(); return; } BackgroundSection mousedOverSection = targetHull.GetBackgroundSection(pos); if (mousedOverSection == null) { targetSections.Clear(); return; } // No need to refresh if (targetSections.Count > 0 && mousedOverSection == targetSections[0]) { return; } targetSections.Clear(); targetSections.Add(mousedOverSection); int mousedOverIndex = mousedOverSection.Index; // Start with 2x2 if (spraySetting > 0) { sprayArray[0].X = mousedOverIndex + 1; sprayArray[0].Y = mousedOverSection.RowIndex; sprayArray[1].X = mousedOverIndex + targetHull.xBackgroundMax; sprayArray[1].Y = mousedOverSection.RowIndex + 1; sprayArray[2].X = sprayArray[1].X + 1; sprayArray[2].Y = sprayArray[1].Y; for (int i = 0; i < 3; i++) { if (targetHull.DoesSectionMatch(sprayArray[i].X, sprayArray[i].Y)) { targetSections.Add(targetHull.BackgroundSections[sprayArray[i].X]); } } // Add more if it's 3x3 if (spraySetting == 2) { sprayArray[3].X = mousedOverIndex - 1; sprayArray[3].Y = mousedOverSection.RowIndex; sprayArray[4].X = sprayArray[1].X - 1; sprayArray[4].Y = sprayArray[1].Y; sprayArray[5].X = sprayArray[3].X - targetHull.xBackgroundMax; sprayArray[5].Y = sprayArray[3].Y - 1; sprayArray[6].X = sprayArray[5].X + 1; sprayArray[6].Y = sprayArray[5].Y; sprayArray[7].X = sprayArray[6].X + 1; sprayArray[7].Y = sprayArray[6].Y; for (int i = 3; i < sprayArray.Length; i++) { if (targetHull.DoesSectionMatch(sprayArray[i].X, sprayArray[i].Y)) { targetSections.Add(targetHull.BackgroundSections[sprayArray[i].X]); } } } } }
public bool AffectsSection(BackgroundSection section) { return(affectedSections != null && affectedSections.Contains(section)); }