v0.14.6.0

This commit is contained in:
Joonas Rikkonen
2021-06-17 17:54:52 +03:00
parent 3f324b14e8
commit c27e2ea5ab
348 changed files with 13156 additions and 4266 deletions
@@ -71,15 +71,15 @@ namespace Barotrauma
if (sparks)
{
GameMain.ParticleManager.CreateParticle("spark", worldPosition,
Rand.Vector(Rand.Range(500.0f, 800.0f)), 0.0f, hull);
Rand.Vector(Rand.Range(1200.0f, 2400.0f)), 0.0f, hull);
}
}
if (flash)
{
float displayRange = flashRange.HasValue ? flashRange.Value : Attack.Range;
float displayRange = flashRange ?? Attack.Range;
if (displayRange < 0.1f) { return; }
var light = new LightSource(worldPosition, displayRange, Color.LightYellow, null);
var light = new LightSource(worldPosition, displayRange, flashColor, null);
CoroutineManager.StartCoroutine(DimLight(light));
}
}
@@ -169,40 +169,43 @@ namespace Barotrauma
}
}
if (EditWater)
if (!IdFreed)
{
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(WorldRect, position))
if (EditWater)
{
if (PlayerInput.PrimaryMouseButtonHeld())
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(WorldRect, position))
{
WaterVolume += 1500.0f;
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
if (PlayerInput.PrimaryMouseButtonHeld())
{
WaterVolume += 1500.0f;
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
}
else if (PlayerInput.SecondaryMouseButtonHeld())
{
WaterVolume -= 1500.0f;
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
}
}
else if (PlayerInput.SecondaryMouseButtonHeld())
}
else if (EditFire)
{
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(WorldRect, position))
{
WaterVolume -= 1500.0f;
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
if (PlayerInput.PrimaryMouseButtonClicked())
{
new FireSource(position, this, isNetworkMessage: true);
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
}
}
}
}
else if (EditFire)
{
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(WorldRect, position))
{
if (PlayerInput.PrimaryMouseButtonClicked())
{
new FireSource(position, this, isNetworkMessage: true);
networkUpdatePending = true;
serverUpdateDelay = 0.5f;
}
}
}
if (waterVolume < 1.0f) return;
if (waterVolume < 1.0f) { return; }
for (int i = 1; i < waveY.Length - 1; i++)
{
float maxDelta = Math.Max(Math.Abs(rightDelta[i]), Math.Abs(leftDelta[i]));
@@ -629,9 +632,9 @@ namespace Barotrauma
PowerConsumptionTimer = message.ReadSingle()
};
}
else if (BallastFlora != null)
else
{
BallastFlora.ClientRead(message, header);
BallastFlora?.ClientRead(message, header);
}
return;
}
@@ -210,7 +210,7 @@ namespace Barotrauma
if (ParticleEmitterTriggers[i] != null && !ParticleEmitterTriggers[i].IsTriggered) { continue; }
Vector2 emitterPos = LocalToWorld(Prefab.EmitterPositions[i]);
ParticleEmitters[i].Emit(deltaTime, emitterPos, hullGuess: null,
angle: ParticleEmitters[i].Prefab.CopyEntityAngle ? -CurrentRotation + MathHelper.PiOver2 : 0.0f);
angle: ParticleEmitters[i].Prefab.Properties.CopyEntityAngle ? -CurrentRotation + MathHelper.Pi : 0.0f);
}
}
@@ -293,6 +293,12 @@ namespace Barotrauma
public void ClientRead(IReadMessage msg)
{
if (Triggers == null) { return; }
if (Prefab.TakeLevelWallDamage)
{
float newHealth = msg.ReadRangedSingle(0.0f, Prefab.Health, 8);
AddDamage(Health - newHealth, 1.0f, null, isNetworkEvent: true);
}
for (int i = 0; i < Triggers.Count; i++)
{
if (!Triggers[i].UseNetworkSyncing) { continue; }
@@ -20,6 +20,8 @@ namespace Barotrauma
const int MaxVisibleObjects = 500;
private Rectangle currentGridIndices;
public bool ForceRefreshVisibleObjects;
partial void UpdateProjSpecific(float deltaTime)
{
@@ -60,6 +62,8 @@ namespace Barotrauma
if (objectGrid[x, y] == null) { continue; }
foreach (LevelObject obj in objectGrid[x, y])
{
if (obj.Prefab.HideWhenBroken && obj.Health <= 0.0f) { continue; }
if (zoom < 0.05f)
{
//hide if the sprite is very small when zoomed this far out
@@ -154,9 +158,10 @@ namespace Barotrauma
indices.Height = Math.Min(indices.Height, objectGrid.GetLength(1) - 1);
float z = 0.0f;
if (currentGridIndices != indices && Timing.TotalTime > NextRefreshTime)
if (ForceRefreshVisibleObjects || (currentGridIndices != indices && Timing.TotalTime > NextRefreshTime))
{
RefreshVisibleObjects(indices, cam.Zoom);
ForceRefreshVisibleObjects = false;
if (cam.Zoom < 0.1f)
{
//when zoomed very far out, refresh a little less often
@@ -361,6 +361,7 @@ namespace Barotrauma.Lights
void DrawHalo(Character character)
{
if (character == null || character.Removed) { return; }
Vector2 haloDrawPos = character.DrawPosition;
haloDrawPos.Y = -haloDrawPos.Y;
@@ -404,7 +405,7 @@ namespace Barotrauma.Lights
}
foreach (Item item in Item.ItemList)
{
if (item.IsHighlighted && !highlightedEntities.Contains(item))
if ((item.IsHighlighted || item.IconStyle != null) && !highlightedEntities.Contains(item))
{
highlightedEntities.Add(item);
}
@@ -425,7 +426,14 @@ namespace Barotrauma.Lights
{
if (highlighted is Item item)
{
item.Draw(spriteBatch, false, true);
if (item.IconStyle != null && (item != Character.Controlled.FocusedItem || Character.Controlled.FocusedItem == null))
{
//wait until next pass
}
else
{
item.Draw(spriteBatch, false, true);
}
}
else if (highlighted is Character character)
{
@@ -434,6 +442,22 @@ namespace Barotrauma.Lights
}
spriteBatch.End();
//draw items with iconstyles in the style's color
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, samplerState: SamplerState.LinearWrap, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
foreach (Entity highlighted in highlightedEntities)
{
if (highlighted is Item item)
{
if (item.IconStyle != null && (item != Character.Controlled.FocusedItem || Character.Controlled.FocusedItem == null))
{
SolidColorEffect.Parameters["color"].SetValue(item.IconStyle.Color.ToVector4());
SolidColorEffect.CurrentTechnique.Passes[0].Apply();
item.Draw(spriteBatch, false, true);
}
}
}
spriteBatch.End();
//draw characters in black with a bit of blur, leaving the white edges visible
float phase = (float)(Math.Sin(Timing.TotalTime * 3.0f) + 1.0f) / 2.0f; //phase oscillates between 0 and 1
Vector4 overlayColor = Color.Black.ToVector4() * MathHelper.Lerp(0.5f, 0.9f, phase);
@@ -607,15 +607,18 @@ namespace Barotrauma
tooltip = (new Rectangle(typeChangeIconPos.ToPoint(), new Point(30)), location.LastTypeChangeMessage);
}
}
if (location != CurrentLocation && CurrentLocation.AvailableMissions.Any(m => m.Locations.Contains(location)) && generationParams.MissionIcon != null)
if (location != CurrentLocation && generationParams.MissionIcon != null)
{
Vector2 missionIconPos = pos + new Vector2(1.35f, 0.35f) * generationParams.LocationIconSize * 0.5f * zoom;
float missionIconScale = 18.0f / generationParams.MissionIcon.SourceRect.Width;
generationParams.MissionIcon.Draw(spriteBatch, missionIconPos, generationParams.IndicatorColor, scale: missionIconScale * zoom);
if (Vector2.Distance(PlayerInput.MousePosition, missionIconPos) < generationParams.MissionIcon.SourceRect.Width * zoom && IsPreferredTooltip(missionIconPos))
if ((CurrentLocation == currentDisplayLocation && CurrentLocation.AvailableMissions.Any(m => m.Locations.Contains(location))) || location.AvailableMissions.Any(m => m.Prefab.Type == MissionType.GoTo))
{
var availableMissions = CurrentLocation.AvailableMissions.Where(m => m.Locations.Contains(location));
tooltip = (new Rectangle(missionIconPos.ToPoint(), new Point(30)), TextManager.Get("mission") + '\n'+ string.Join('\n', availableMissions.Select(m => "- " + m.Name)));
Vector2 missionIconPos = pos + new Vector2(1.35f, 0.35f) * generationParams.LocationIconSize * 0.5f * zoom;
float missionIconScale = 18.0f / generationParams.MissionIcon.SourceRect.Width;
generationParams.MissionIcon.Draw(spriteBatch, missionIconPos, generationParams.IndicatorColor, scale: missionIconScale * zoom);
if (Vector2.Distance(PlayerInput.MousePosition, missionIconPos) < generationParams.MissionIcon.SourceRect.Width * zoom && IsPreferredTooltip(missionIconPos))
{
var availableMissions = CurrentLocation.AvailableMissions.Where(m => m.Locations.Contains(location)).Concat(location.AvailableMissions.Where(m => m.Prefab.Type == MissionType.GoTo)).Distinct();
tooltip = (new Rectangle(missionIconPos.ToPoint(), new Point(30)), TextManager.Get("mission") + '\n'+ string.Join('\n', availableMissions.Select(m => "- " + m.Name)));
}
}
}
@@ -29,20 +29,14 @@ namespace Barotrauma
public static bool SelectionChanged;
//which entities have been selected for editing
private static List<MapEntity> selectedList = new List<MapEntity>();
public static List<MapEntity> SelectedList
{
get
{
return selectedList;
}
}
private static List<MapEntity> copiedList = new List<MapEntity>();
public static HashSet<MapEntity> SelectedList { get; private set; } = new HashSet<MapEntity>();
public static List<MapEntity> CopiedList = new List<MapEntity>();
private static List<MapEntity> highlightedList = new List<MapEntity>();
// Test feature. Not yet saved.
public static Dictionary<MapEntity, List<MapEntity>> SelectionGroups { get; private set; } = new Dictionary<MapEntity, List<MapEntity>>();
public static Dictionary<MapEntity, HashSet<MapEntity>> SelectionGroups { get; private set; } = new Dictionary<MapEntity, HashSet<MapEntity>>();
private static float highlightTimer;
@@ -78,25 +72,13 @@ namespace Barotrauma
}
}
public virtual bool SelectableInEditor
{
get { return true; }
}
public virtual bool SelectableInEditor => true;
public static bool SelectedAny
{
get { return selectedList.Count > 0; }
}
public static bool SelectedAny => SelectedList.Count > 0;
public static IEnumerable<MapEntity> CopiedList
{
get { return copiedList; }
}
public bool IsSelected => SelectedList.Contains(this);
public bool IsSelected
{
get { return selectedList.Contains(this); }
}
public bool IsIncludedInSelection { get; set; }
public virtual bool IsVisible(Rectangle worldView)
{
@@ -129,7 +111,10 @@ namespace Barotrauma
{
if (resizing)
{
if (selectedList.Count == 0) resizing = false;
if (!SelectedAny)
{
resizing = false;
}
return;
}
@@ -157,19 +142,19 @@ namespace Barotrauma
if (MapEntityPrefab.Selected != null)
{
selectionPos = Vector2.Zero;
selectedList.Clear();
SelectedList.Clear();
return;
}
if (GUI.KeyboardDispatcher.Subscriber == null)
{
if (PlayerInput.KeyHit(Keys.Delete))
{
if (selectedList.Any())
if (SelectedAny)
{
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(selectedList, true));
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity>(SelectedList), true));
}
selectedList.ForEach(e => { if (!e.Removed) { e.Remove(); } });
selectedList.Clear();
SelectedList.ForEach(e => { if (!e.Removed) { e.Remove(); } });
SelectedList.Clear();
}
if (PlayerInput.IsCtrlDown())
@@ -178,7 +163,7 @@ namespace Barotrauma
if (PlayerInput.KeyHit(Keys.D))
{
bool terminate = false;
foreach (MapEntity entity in selectedList)
foreach (MapEntity entity in SelectedList)
{
if (entity is Item item && item.GetComponent<Planter>() is { } planter)
{
@@ -201,11 +186,11 @@ namespace Barotrauma
#endif
if (PlayerInput.KeyHit(Keys.C))
{
Copy(selectedList);
Copy(SelectedList.ToList());
}
else if (PlayerInput.KeyHit(Keys.X))
{
Cut(selectedList);
Cut(SelectedList.ToList());
}
else if (PlayerInput.KeyHit(Keys.V))
{
@@ -213,21 +198,21 @@ namespace Barotrauma
}
else if (PlayerInput.KeyHit(Keys.G))
{
if (selectedList.Any())
if (SelectedList.Any())
{
if (SelectionGroups.ContainsKey(selectedList.Last()))
if (SelectionGroups.ContainsKey(SelectedList.Last()))
{
// Ungroup all selected
selectedList.ForEach(e => SelectionGroups.Remove(e));
SelectedList.ForEach(e => SelectionGroups.Remove(e));
}
else
{
foreach (var entity in selectedList)
foreach (var entity in SelectedList)
{
// Remove the old group, if any
SelectionGroups.Remove(entity);
// Create a group that can be accessed with any member
SelectionGroups.Add(entity, selectedList);
SelectionGroups.Add(entity, SelectedList);
}
}
}
@@ -277,7 +262,7 @@ namespace Barotrauma
Vector2 nudge = GetNudgeAmount();
if (nudge != Vector2.Zero)
{
foreach (MapEntity entityToNudge in selectedList) { entityToNudge.Move(nudge); }
foreach (MapEntity entityToNudge in SelectedList) { entityToNudge.Move(nudge); }
}
}
else
@@ -290,7 +275,7 @@ namespace Barotrauma
//started moving selected entities
if (startMovingPos != Vector2.Zero)
{
Item targetContainer = GetPotentialContainer(position, selectedList);
Item targetContainer = GetPotentialContainer(position, SelectedList);
if (targetContainer != null) { targetContainer.IsHighlighted = true; }
@@ -313,16 +298,16 @@ namespace Barotrauma
//clone
if (PlayerInput.IsCtrlDown())
{
var clones = Clone(selectedList).Where(c => c != null).ToList();
selectedList = clones;
selectedList.ForEach(c => c.Move(moveAmount));
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(clones, false));
HashSet<MapEntity> clones = Clone(SelectedList.ToList()).Where(c => c != null).ToHashSet();
SelectedList = clones;
SelectedList.ForEach(c => c.Move(moveAmount));
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity>(clones), false));
}
else // move
{
var oldRects = selectedList.Select(e => e.Rect).ToList();
var oldRects = SelectedList.Select(e => e.Rect).ToList();
List<MapEntity> deposited = new List<MapEntity>();
foreach (MapEntity e in selectedList)
foreach (MapEntity e in SelectedList)
{
e.Move(moveAmount);
@@ -340,14 +325,14 @@ namespace Barotrauma
}
}
SubEditorScreen.StoreCommand(new TransformCommand(new List<MapEntity>(selectedList),selectedList.Select(entity => entity.Rect).ToList(), oldRects, false));
SubEditorScreen.StoreCommand(new TransformCommand(new List<MapEntity>(SelectedList),SelectedList.Select(entity => entity.Rect).ToList(), oldRects, false));
if (deposited.Any() && deposited.Any(entity => entity is Item))
{
var depositedItems = deposited.Where(entity => entity is Item).Cast<Item>().ToList();
SubEditorScreen.StoreCommand(new InventoryPlaceCommand(targetContainer.OwnInventory, depositedItems, false));
}
deposited.ForEach(entity => { selectedList.Remove(entity); });
deposited.ForEach(entity => { SelectedList.Remove(entity); });
}
}
startMovingPos = Vector2.Zero;
@@ -360,7 +345,12 @@ namespace Barotrauma
selectionSize.X = position.X - selectionPos.X;
selectionSize.Y = selectionPos.Y - position.Y;
List<MapEntity> newSelection = new List<MapEntity>();// FindSelectedEntities(selectionPos, selectionSize);
foreach (MapEntity entity in mapEntityList)
{
entity.IsIncludedInSelection = false;
}
HashSet<MapEntity> newSelection = new HashSet<MapEntity>();// FindSelectedEntities(selectionPos, selectionSize);
if (Math.Abs(selectionSize.X) > Submarine.GridSize.X || Math.Abs(selectionSize.Y) > Submarine.GridSize.Y)
{
newSelection = FindSelectedEntities(selectionPos, selectionSize);
@@ -369,13 +359,22 @@ namespace Barotrauma
{
if (highLightedEntity != null)
{
if (SelectionGroups.TryGetValue(highLightedEntity, out List<MapEntity> group))
if (SelectionGroups.TryGetValue(highLightedEntity, out HashSet<MapEntity> group))
{
newSelection.AddRange(group);
foreach (MapEntity entity in group.Where(e => !newSelection.Contains(e)))
{
newSelection.Add(entity);
}
foreach (MapEntity entity in group)
{
entity.IsIncludedInSelection = true;
}
}
else
{
newSelection.Add(highLightedEntity);
highLightedEntity.IsIncludedInSelection = true;
}
}
}
@@ -386,7 +385,7 @@ namespace Barotrauma
{
foreach (MapEntity e in newSelection)
{
if (selectedList.Contains(e))
if (SelectedList.Contains(e))
{
RemoveSelection(e);
}
@@ -398,7 +397,7 @@ namespace Barotrauma
}
else
{
selectedList = new List<MapEntity>(newSelection);
SelectedList = new HashSet<MapEntity>(newSelection);
//selectedList.Clear();
//newSelection.ForEach(e => AddSelection(e));
foreach (var entity in newSelection)
@@ -407,23 +406,23 @@ namespace Barotrauma
onGapFound: (door, gap) =>
{
door.RefreshLinkedGap();
if (!selectedList.Contains(gap))
if (!SelectedList.Contains(gap))
{
selectedList.Add(gap);
SelectedList.Add(gap);
}
},
onDoorFound: (door, gap) =>
{
if (!selectedList.Contains(door.Item))
if (!SelectedList.Contains(door.Item))
{
selectedList.Add(door.Item);
SelectedList.Add(door.Item);
}
});
}
}
//select wire if both items it's connected to are selected
var selectedItems = selectedList.Where(e => e is Item).Cast<Item>().ToList();
var selectedItems = SelectedList.Where(e => e is Item).Cast<Item>().ToList();
foreach (Item item in selectedItems)
{
if (item.Connections == null) continue;
@@ -431,11 +430,11 @@ namespace Barotrauma
{
foreach (Wire w in c.Wires)
{
if (w == null || selectedList.Contains(w.Item)) continue;
if (w == null || SelectedList.Contains(w.Item)) continue;
if (w.OtherConnection(c) != null && selectedList.Contains(w.OtherConnection(c).Item))
if (w.OtherConnection(c) != null && SelectedList.Contains(w.OtherConnection(c).Item))
{
selectedList.Add(w.Item);
SelectedList.Add(w.Item);
}
}
}
@@ -443,6 +442,10 @@ namespace Barotrauma
selectionPos = Vector2.Zero;
selectionSize = Vector2.Zero;
foreach (MapEntity entity in mapEntityList)
{
entity.IsIncludedInSelection = false;
}
}
}
//default, not doing anything specific yet
@@ -455,7 +458,7 @@ namespace Barotrauma
(highlightedListBox == null || (GUI.MouseOn != highlightedListBox && !highlightedListBox.IsParentOf(GUI.MouseOn))))
{
//if clicking a selected entity, start moving it
foreach (MapEntity e in selectedList)
foreach (MapEntity e in SelectedList)
{
if (e.IsMouseOn(position)) startMovingPos = position;
}
@@ -503,7 +506,7 @@ namespace Barotrauma
return ReplacedBy?.GetReplacementOrThis() ?? this;
}
public static Item GetPotentialContainer(Vector2 position, List<MapEntity> entities = null)
public static Item GetPotentialContainer(Vector2 position, HashSet<MapEntity> entities = null)
{
Item targetContainer = null;
bool isShiftDown = PlayerInput.IsShiftDown();
@@ -638,7 +641,7 @@ namespace Barotrauma
if (PlayerInput.IsCtrlDown() && !wiringMode)
{
if (selectedList.Contains(entity))
if (SelectedList.Contains(entity))
{
RemoveSelection(entity);
}
@@ -657,56 +660,60 @@ namespace Barotrauma
public static void AddSelection(MapEntity entity)
{
if (selectedList.Contains(entity)) { return; }
selectedList.Add(entity);
if (SelectedList.Contains(entity)) { return; }
SelectedList.Add(entity);
HandleDoorGapLinks(entity,
onGapFound: (door, gap) =>
{
door.RefreshLinkedGap();
if (!selectedList.Contains(gap))
if (!SelectedList.Contains(gap))
{
selectedList.Add(gap);
SelectedList.Add(gap);
}
},
onDoorFound: (door, gap) =>
{
if (!selectedList.Contains(door.Item))
if (!SelectedList.Contains(door.Item))
{
selectedList.Add(door.Item);
SelectedList.Add(door.Item);
}
});
}
private static void HandleDoorGapLinks(MapEntity entity, Action<Door, Gap> onGapFound, Action<Door, Gap> onDoorFound)
{
if (entity is Item i)
switch (entity)
{
var door = i.GetComponent<Door>();
if (door != null)
case Item i:
{
var gap = door.LinkedGap;
var door = i.GetComponent<Door>();
var gap = door?.LinkedGap;
if (gap != null)
{
onGapFound(door, gap);
}
break;
}
}
else if (entity is Gap gap)
{
var door = gap.ConnectedDoor;
if (door != null)
case Gap gap:
{
onDoorFound(door, gap);
var door = gap.ConnectedDoor;
if (door != null)
{
onDoorFound(door, gap);
}
break;
}
}
}
public static void RemoveSelection(MapEntity entity)
{
selectedList.Remove(entity);
SelectedList.Remove(entity);
HandleDoorGapLinks(entity,
onGapFound: (door, gap) => selectedList.Remove(gap),
onDoorFound: (door, gap) => selectedList.Remove(door.Item));
onGapFound: (door, gap) => SelectedList.Remove(gap),
onDoorFound: (door, gap) => SelectedList.Remove(door.Item));
}
static partial void UpdateAllProjSpecific(float deltaTime)
@@ -751,7 +758,7 @@ namespace Barotrauma
//started moving the selected entities
if (Math.Abs(moveAmount.X) >= Submarine.GridSize.X || Math.Abs(moveAmount.Y) >= Submarine.GridSize.Y || isShiftDown)
{
foreach (MapEntity e in selectedList)
foreach (MapEntity e in SelectedList)
{
SpriteEffects spriteEffects = SpriteEffects.None;
switch (e)
@@ -800,7 +807,32 @@ namespace Barotrauma
}
if (selectionPos != null && selectionPos != Vector2.Zero)
{
GUI.DrawRectangle(spriteBatch, new Vector2(selectionPos.X, -selectionPos.Y), selectionSize, Color.DarkRed, false, 0, 2f / GameScreen.Selected.Cam.Zoom);
var (sizeX, sizeY) = selectionSize;
var (posX, posY) = selectionPos;
posY = -posY;
Vector2[] corners =
{
new Vector2(posX, posY),
new Vector2(posX + sizeX, posY),
new Vector2(posX + sizeX, posY + sizeY),
new Vector2(posX, posY + sizeY)
};
Color selectionColor = GUI.Style.Blue;
float thickness = Math.Max(2f, 2f / Screen.Selected.Cam.Zoom);
GUI.DrawFilledRectangle(spriteBatch, corners[0], selectionSize, selectionColor * 0.1f);
Vector2 offset = new Vector2(0f, thickness / 2f);
if (sizeY < 0) { offset.Y = -offset.Y; }
spriteBatch.DrawLine(corners[0], corners[1], selectionColor, thickness);
spriteBatch.DrawLine(corners[1] - offset, corners[2] + offset, selectionColor, thickness);
spriteBatch.DrawLine(corners[2], corners[3], selectionColor, thickness);
spriteBatch.DrawLine(corners[3] + offset, corners[0] - offset, selectionColor, thickness);
}
}
@@ -824,8 +856,8 @@ namespace Barotrauma
}
}
FilteredSelectedList.Clear();
if (selectedList.Count == 0) return;
foreach (var e in selectedList)
if (SelectedList.Count == 0) return;
foreach (var e in SelectedList)
{
if (e is Gap gap && gap.ConnectedDoor != null) { continue; }
FilteredSelectedList.Add(e);
@@ -844,15 +876,19 @@ namespace Barotrauma
{
if (PlayerInput.KeyHit(Keys.N))
{
float minX = selectedList[0].WorldRect.X, maxX = selectedList[0].WorldRect.Right;
for (int i = 0; i < selectedList.Count; i++)
MapEntity firstSelected = SelectedList.First();
float minX = firstSelected.WorldRect.X,
maxX = firstSelected.WorldRect.Right;
foreach (MapEntity entity in SelectedList)
{
minX = Math.Min(minX, selectedList[i].WorldRect.X);
maxX = Math.Max(maxX, selectedList[i].WorldRect.Right);
minX = Math.Min(minX, entity.WorldRect.X);
maxX = Math.Max(maxX, entity.WorldRect.Right);
}
float centerX = (minX + maxX) / 2.0f;
foreach (MapEntity me in selectedList)
foreach (MapEntity me in SelectedList)
{
me.FlipX(false);
me.Move(new Vector2((centerX - me.WorldPosition.X) * 2.0f, 0.0f));
@@ -860,15 +896,20 @@ namespace Barotrauma
}
else if (PlayerInput.KeyHit(Keys.M))
{
float minY = selectedList[0].WorldRect.Y - selectedList[0].WorldRect.Height, maxY = selectedList[0].WorldRect.Y;
for (int i = 0; i < selectedList.Count; i++)
MapEntity firstSelected = SelectedList.First();
float minY = firstSelected.WorldRect.Y - firstSelected.WorldRect.Height,
maxY = firstSelected.WorldRect.Y;
foreach (MapEntity entity in SelectedList)
{
minY = Math.Min(minY, selectedList[i].WorldRect.Y - selectedList[i].WorldRect.Height);
maxY = Math.Max(maxY, selectedList[i].WorldRect.Y);
minY = Math.Min(minY, entity.WorldRect.Y - entity.WorldRect.Height);
maxY = Math.Max(maxY, entity.WorldRect.Y);
}
float centerY = (minY + maxY) / 2.0f;
foreach (MapEntity me in selectedList)
foreach (MapEntity me in SelectedList)
{
me.FlipY(false);
me.Move(new Vector2(0.0f, (centerY - me.WorldPosition.Y) * 2.0f));
@@ -879,19 +920,20 @@ namespace Barotrauma
public static void DrawEditor(SpriteBatch spriteBatch, Camera cam)
{
if (selectedList.Count == 1)
if (SelectedList.Count == 1)
{
selectedList[0].DrawEditing(spriteBatch, cam);
if (selectedList[0].ResizeHorizontal || selectedList[0].ResizeVertical)
MapEntity firstSelected = SelectedList.First();
firstSelected.DrawEditing(spriteBatch, cam);
if (firstSelected.ResizeHorizontal || firstSelected.ResizeVertical)
{
selectedList[0].DrawResizing(spriteBatch, cam);
firstSelected.DrawResizing(spriteBatch, cam);
}
}
}
public static void DeselectAll()
{
selectedList.Clear();
SelectedList.Clear();
}
public static void SelectEntity(MapEntity entity)
@@ -926,10 +968,10 @@ namespace Barotrauma
public static void Paste(Vector2 position)
{
if (copiedList.Count == 0) { return; }
if (CopiedList.Count == 0) { return; }
List<MapEntity> prevEntities = new List<MapEntity>(mapEntityList);
Clone(copiedList);
Clone(CopiedList);
var clones = mapEntityList.Except(prevEntities).ToList();
var nonWireClones = clones.Where(c => !(c is Item item) || item.GetComponent<Wire>() == null);
@@ -941,8 +983,8 @@ namespace Barotrauma
Vector2 moveAmount = Submarine.VectorToWorldGrid(position - center);
selectedList = new List<MapEntity>(clones);
foreach (MapEntity clone in selectedList)
SelectedList = new HashSet<MapEntity>(clones);
foreach (MapEntity clone in SelectedList)
{
clone.Move(moveAmount);
clone.Submarine = Submarine.MainSub;
@@ -958,7 +1000,7 @@ namespace Barotrauma
{
List<MapEntity> prevEntities = new List<MapEntity>(mapEntityList);
copiedList = Clone(entities);
CopiedList = Clone(entities);
//find all new entities created during cloning
var newEntities = mapEntityList.Except(prevEntities).ToList();
@@ -1131,9 +1173,9 @@ namespace Barotrauma
/// <summary>
/// Find entities whose rect intersects with the "selection rect"
/// </summary>
public static List<MapEntity> FindSelectedEntities(Vector2 pos, Vector2 size)
public static HashSet<MapEntity> FindSelectedEntities(Vector2 pos, Vector2 size)
{
List<MapEntity> foundEntities = new List<MapEntity>();
HashSet<MapEntity> foundEntities = new HashSet<MapEntity>();
Rectangle selectionRect = Submarine.AbsRect(pos, size);
@@ -1141,7 +1183,11 @@ namespace Barotrauma
{
if (!e.SelectableInEditor) continue;
if (Submarine.RectsOverlap(selectionRect, e.rect)) foundEntities.Add(e);
if (Submarine.RectsOverlap(selectionRect, e.rect))
{
foundEntities.Add(e);
e.IsIncludedInSelection = true;
}
}
return foundEntities;
@@ -127,7 +127,11 @@ namespace Barotrauma
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
OnClicked = (button, data) =>
{
FlipX(relativeToSub: false);
foreach (MapEntity me in SelectedList)
{
me.FlipX(relativeToSub: false);
}
if (!SelectedList.Contains(this)) { FlipX(relativeToSub: false); }
return true;
}
};
@@ -136,7 +140,11 @@ namespace Barotrauma
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
OnClicked = (button, data) =>
{
FlipY(relativeToSub: false);
foreach (MapEntity me in SelectedList)
{
me.FlipY(relativeToSub: false);
}
if (!SelectedList.Contains(this)) { FlipY(relativeToSub: false); }
return true;
}
};
@@ -145,7 +153,7 @@ namespace Barotrauma
OnClicked = (button, data) =>
{
Sprite.ReloadXML();
Sprite.ReloadTexture();
Sprite.ReloadTexture(updateAllSprites: true);
return true;
}
};
@@ -153,7 +161,12 @@ namespace Barotrauma
{
OnClicked = (button, data) =>
{
Reset();
foreach (MapEntity me in SelectedList)
{
(me as Item)?.Reset();
(me as Structure)?.Reset();
}
if (!SelectedList.Contains(this)) { Reset(); }
CreateEditingHUD();
return true;
}
@@ -247,7 +260,7 @@ namespace Barotrauma
}
else if (HiddenInGame) { return; }
Color color = IsHighlighted ? GUI.Style.Orange : spriteColor;
Color color = IsIncludedInSelection && editing ? GUI.Style.Blue : IsHighlighted ? GUI.Style.Orange * Math.Max(spriteColor.A / (float) byte.MaxValue, 0.1f) : spriteColor;
if (IsSelected && editing)
{
@@ -114,7 +114,6 @@ namespace Barotrauma
if (realWorldDimensions != Vector2.Zero)
{
string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] { "[width]", "[height]" }, new string[2] { ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString() });
var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
{ CanBeFocused = false };
@@ -124,6 +123,15 @@ namespace Barotrauma
dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
}
string cargoCapacityStr = CargoCapacity < 0 ? TextManager.Get("unknown") : TextManager.GetWithVariables("cargocapacityformat", new string[1] { "[cratecount]" }, new string[1] {CargoCapacity.ToString() });
var cargoCapacityText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
TextManager.Get("cargocapacity"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
{ CanBeFocused = false };
new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), cargoCapacityText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
cargoCapacityStr, textAlignment: Alignment.TopLeft, font: font, wrap: true)
{ CanBeFocused = false };
cargoCapacityText.RectTransform.MinSize = new Point(0, cargoCapacityText.Children.First().Rect.Height);
if (RecommendedCrewSizeMax > 0)
{
var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
@@ -46,7 +46,10 @@ namespace Barotrauma
if (IsHighlighted || IsHighlighted) { clr = Color.Lerp(clr, Color.White, 0.8f); }
int iconSize = spawnType == SpawnType.Path ? WaypointSize : SpawnPointSize;
if (ConnectedDoor != null || Ladders != null || Stairs != null || SpawnType != SpawnType.Path) { iconSize = (int)(iconSize * 1.5f); }
if (ConnectedDoor != null || Ladders != null || Stairs != null || SpawnType != SpawnType.Path)
{
iconSize = (int)(iconSize * 1.5f);
}
if (IsSelected || IsHighlighted)
{
@@ -98,10 +101,32 @@ namespace Barotrauma
GUI.Style.Green * 0.5f, width: 1);
}
var color = Color.WhiteSmoke;
if (spawnType == SpawnType.Path)
{
if (linkedTo.Count < 2)
{
if (linkedTo.Count == 0)
{
color = Color.Red;
}
else
{
if (CurrentHull == null)
{
color = Ladders == null ? Color.Red : Color.Yellow;
}
else
{
color = Color.Yellow;
}
}
}
}
GUI.SmallFont.DrawString(spriteBatch,
ID.ToString(),
new Vector2(DrawPosition.X - 10, -DrawPosition.Y - 30),
Color.WhiteSmoke);
color);
}
public override bool IsMouseOn(Vector2 position)