3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
5 using Microsoft.Xna.Framework.Input;
7 using System.Collections.Generic;
8 using System.Collections.Immutable;
11 using Microsoft.Xna.Framework;
15 abstract partial class MapEntity : Entity
20 private static Vector2 startMovingPos = Vector2.Zero;
22 private static float keyDelay;
29 public static bool Resizing {
get;
private set; }
30 private int resizeDirX, resizeDirY;
36 public static HashSet<MapEntity>
SelectedList {
get;
private set; } =
new HashSet<MapEntity>();
38 public static List<MapEntity>
CopiedList =
new List<MapEntity>();
40 private static List<MapEntity> highlightedInEditorList =
new List<MapEntity>();
42 private static float highlightTimer;
47 get {
return highlightedListBox; }
60 private static bool disableSelect;
63 get {
return disableSelect; }
66 disableSelect = value;
92 public virtual void Draw(SpriteBatch spriteBatch,
bool editing,
bool back =
true) { }
99 float depth = baseDepth
101 + (sprite?.
Texture?.SortingKey ?? 0) % 100 * 0.000001f
102 +
ID % 100 * 0.0000001f;
103 return Math.Min(depth, 1.0f);
110 Vector2 noisePos =
new Vector2(
111 (
float)PerlinNoise.GetPerlin((
float)(Timing.TotalTime +
ID) * 0.1f, (
float)(Timing.TotalTime +
ID) * 0.5f) - 0.5f,
112 (
float)PerlinNoise.GetPerlin((
float)(Timing.TotalTime +
ID) * 0.1f, (
float)(Timing.TotalTime +
ID) * 0.1f) - 0.5f);
114 return offsetFromOrigin * MathF.Pow(collapseEffectStrength, MathHelper.Lerp(1, 4,
ID % 1000 / 1000.0f)) + (noisePos * 100.0f * collapseEffectStrength);
141 if (startMovingPos == Vector2.Zero
145 if (highlightedListBox ==
null ||
146 (GUI.MouseOn != highlightedListBox && !highlightedListBox.
IsParentOf(GUI.MouseOn)))
148 UpdateHighlightedListBox(
null,
false);
159 if (GUI.KeyboardDispatcher.Subscriber ==
null)
166 SelectedList.ForEachMod(
static e => {
if (!e.Removed) { e.Remove(); } });
176 bool terminate =
false;
179 if (entity is
Item item && item.GetComponent<Planter>() is { } planter)
181 planter.Update(1.0f, cam);
182 for (var i = 0; i < planter.GrowableSeeds.Length; i++)
184 Growable seed = planter.GrowableSeeds[i];
185 PlantSlot slot = planter.PlantSlots.ContainsKey(i) ? planter.PlantSlots[i] : Planter.NullSlot;
186 if (seed ==
null) {
continue; }
188 seed.CreateDebugHUD(planter, slot);
194 if (terminate) {
break; }
236 if (startMovingPos == Vector2.Zero)
239 if (highlightedListBox !=
null && highlightedListBox.
IsParentOf(GUI.MouseOn))
241 highLightedEntity = GUI.MouseOn.UserData as
MapEntity;
247 if (!e.SelectableInEditor) {
continue; }
248 if (e.IsMouseOn(position))
258 if (i == 0) highLightedEntity = e;
264 if (highLightedEntity !=
null) { highLightedEntity.IsHighlighted =
true; }
267 if (GUI.KeyboardDispatcher.Subscriber ==
null)
270 if (nudge != Vector2.Zero)
283 if (startMovingPos != Vector2.Zero)
286 if (targetContainer !=
null) { targetContainer.
IsHighlighted =
true; }
292 Vector2 moveAmount = position - startMovingPos;
307 HashSet<MapEntity> clones =
Clone(
SelectedList.ToList()).Where(c => c !=
null).ToHashSet();
314 var oldRects =
SelectedList.Select(e => e.Rect).ToList();
315 List<MapEntity> deposited =
new List<MapEntity>();
320 if (isShiftDown && e is
Item item && targetContainer !=
null)
335 if (deposited.Any() && deposited.Any(entity => entity is
Item))
337 var depositedItems = deposited.Where(entity => entity is
Item).Cast<
Item>().ToList();
341 deposited.ForEach(entity => {
SelectedList.Remove(entity); });
344 startMovingPos = Vector2.Zero;
356 entity.IsIncludedInSelection =
false;
359 HashSet<MapEntity> newSelection =
new HashSet<MapEntity>();
366 if (highLightedEntity !=
null)
371 foreach (
MapEntity entity
in entitiesInSameLayer.Where(e => !newSelection.Contains(e)))
373 newSelection.Add(entity);
376 foreach (
MapEntity entity
in entitiesInSameLayer)
378 entity.IsIncludedInSelection =
true;
383 newSelection.Add(highLightedEntity);
384 highLightedEntity.IsIncludedInSelection =
true;
410 foreach (var entity
in newSelection)
412 HandleDoorGapLinks(entity,
413 onGapFound: (door, gap) =>
415 door.RefreshLinkedGap();
418 SelectedList.Add(gap);
421 onDoorFound: (door, gap) =>
435 var wire = item.GetComponent<
Wire>();
436 if (wire ==
null) {
continue; }
440 if (item0 ==
null && item1 !=
null)
444 else if (item0 !=
null && item1 ==
null)
458 entity.IsIncludedInSelection =
false;
469 (highlightedListBox ==
null || (GUI.MouseOn != highlightedListBox && !highlightedListBox.
IsParentOf(GUI.MouseOn))))
474 if (e.IsMouseOn(position)) startMovingPos = position;
486 startMovingPos = Vector2.Zero;
493 Vector2 nudgeAmount = Vector2.Zero;
501 int xKeysDown = (left + right);
502 int yKeysDown = (up + down);
504 if (xKeysDown != 0 || yKeysDown != 0) { keyDelay += (float) Timing.Step; }
else { keyDelay = 0; }
507 if (keyDelay >= 0.5f)
509 nudgeAmount.Y = yKeysDown;
510 nudgeAmount.X = xKeysDown;
529 Item targetContainer =
null;
532 if (!isShiftDown) {
return null; }
536 if (!e.SelectableInEditor || e is not
Item potentialContainer) {
continue; }
538 if (e.IsMouseOn(position))
540 if (entities ==
null)
542 if (potentialContainer.OwnInventory !=
null && potentialContainer.ParentInventory ==
null && !potentialContainer.OwnInventory.IsFull(takeStacksIntoAccount:
true))
544 targetContainer = potentialContainer;
550 foreach (
MapEntity selectedEntity
in entities)
552 if (!(selectedEntity is
Item selectedItem)) {
continue; }
553 if (potentialContainer.OwnInventory !=
null && potentialContainer.ParentInventory ==
null && potentialContainer != selectedItem &&
554 potentialContainer.OwnInventory.CanBePut(selectedItem))
556 targetContainer = potentialContainer;
562 if (targetContainer !=
null) {
break; }
565 return targetContainer;
578 highlightTimer = 0.0f;
582 bool mouseNearHighlightBox =
false;
584 if (highlightedListBox !=
null)
587 expandedRect.Inflate(20, 20);
589 if (!mouseNearHighlightBox) highlightedListBox =
null;
592 highlightTimer += (float)Timing.Step;
593 if (highlightTimer > 1.0f)
595 if (!mouseNearHighlightBox)
598 highlightTimer = 0.0f;
604 private static void UpdateHighlightedListBox(List<MapEntity>
highlightedEntities,
bool wiringMode)
608 highlightedListBox =
null;
611 if (highlightedListBox !=
null)
613 if (GUI.MouseOn == highlightedListBox || highlightedListBox.
IsParentOf(GUI.MouseOn))
return;
619 highlightedListBox =
new GUIListBox(
new RectTransform(
new Point(180,
highlightedEntities.Count * 18 + 5), GUI.Canvas)
621 MaxSize = new Point(int.MaxValue, 256),
622 ScreenSpaceOffset = PlayerInput.MousePosition.ToPoint() + new Point(15)
623 }, style:
"GUIToolTip");
627 LocalizedString tooltip =
string.Empty;
629 if (wiringMode && entity is Item item)
631 var wire = item.GetComponent<
Wire>();
632 if (wire?.Connections !=
null)
634 for (var i = 0; i < wire.Connections.Length; i++)
639 tooltip += TextManager.GetWithVariables(
"wirelistformat",
640 (
"[item]", conn.Item?.Name),
641 (
"[pin]", conn.Name));
643 if (i != wire.Connections.Length - 1) { tooltip +=
'\n'; }
649 ToolBox.LimitString(entity.Name, GUIStyle.SmallFont, 140), font: GUIStyle.SmallFont)
656 highlightedListBox.
OnSelected = (GUIComponent component,
object obj) =>
660 if (PlayerInput.IsCtrlDown() && !wiringMode)
683 HandleDoorGapLinks(entity,
684 onGapFound: (door, gap) =>
686 door.RefreshLinkedGap();
689 SelectedList.Add(gap);
692 onDoorFound: (door, gap) =>
701 private static void HandleDoorGapLinks(
MapEntity entity, Action<Door, Gap> onGapFound, Action<Door, Gap> onDoorFound)
707 var door = i.GetComponent<
Door>();
711 onGapFound(door, gap);
718 var door = gap.ConnectedDoor;
721 onDoorFound(door, gap);
732 HandleDoorGapLinks(entity,
734 onDoorFound: (door, gap) =>
SelectedList.Remove(door.Item));
737 static partial
void UpdateAllProjSpecific(
float deltaTime)
740 foreach (
MapEntity me
in entitiesToRender)
744 item.UpdateSpriteStates(deltaTime);
746 else if (me is Structure structure)
748 structure.UpdateSpriteStates(deltaTime);
760 if (subEditor.IsMouseOnEditorGUI()) {
return; }
762 else if (GUI.MouseOn !=
null)
770 if (startMovingPos != Vector2.Zero)
772 Vector2 moveAmount = position - startMovingPos;
773 moveAmount.Y = -moveAmount.Y;
788 SpriteEffects spriteEffects = SpriteEffects.None;
789 float spriteRotation = 0.0f;
790 float rectangleRotation = 0.0f;
795 if (item.FlippedX && item.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
796 if (item.FlippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
797 spriteRotation = MathHelper.ToRadians(item.Rotation);
798 rectangleRotation = spriteRotation;
799 var wire = item.GetComponent<
Wire>();
800 if (wire !=
null && wire.Item.body !=
null && !wire.Item.body.Enabled)
802 wire.
Draw(spriteBatch, editing:
false,
new Vector2(moveAmount.X, -moveAmount.Y));
809 if (structure.FlippedX && structure.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
810 if (structure.FlippedY && structure.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
811 rectangleRotation = MathHelper.ToRadians(structure.Rotation);
813 spriteRotation = rectangleRotation;
814 bool spriteIsFlippedHorizontally = structure.
Sprite.
effects.HasFlag(SpriteEffects.FlipHorizontally);
815 bool spriteIsFlippedVertically = structure.Sprite.effects.HasFlag(SpriteEffects.FlipVertically);
816 if (spriteIsFlippedHorizontally != spriteIsFlippedVertically)
818 spriteRotation = -spriteRotation;
821 if (structure.FlippedX != structure.FlippedY) { rectangleRotation = -rectangleRotation; }
827 drawPos.Y = -drawPos.Y;
828 drawPos += moveAmount;
829 wayPoint.Draw(spriteBatch, drawPos);
838 linkedSub.Draw(spriteBatch, lPos, alpha: 0.5f);
842 e.Prefab?.DrawPlacing(spriteBatch,
843 new Rectangle(e.WorldRect.Location +
new Point((
int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteRotation, spriteEffects: spriteEffects);
844 GUI.DrawRectangle(spriteBatch,
845 center: e.WorldRect.Center.ToVector2().FlipY() + moveAmount +
new Vector2(0f, e.WorldRect.Height),
846 width: e.WorldRect.Width, height: e.WorldRect.Height,
847 rotation: rectangleRotation, clr: Color.White,
861 public static void DrawSelectionRect(SpriteBatch spriteBatch, Vector2 pos, Vector2 size, Color color)
863 var (sizeX, sizeY) = size;
864 var (posX, posY) = pos;
870 new Vector2(posX, posY),
871 new Vector2(posX + sizeX, posY),
872 new Vector2(posX + sizeX, posY + sizeY),
873 new Vector2(posX, posY + sizeY)
878 GUI.DrawFilledRectangle(spriteBatch, corners[0], size, color * 0.1f);
880 Vector2 offset =
new Vector2(0f, thickness / 2f);
882 if (sizeY < 0) { offset.Y = -offset.Y; }
884 spriteBatch.DrawLine(corners[0], corners[1], color, thickness);
885 spriteBatch.DrawLine(corners[1] - offset, corners[2] + offset, color, thickness);
886 spriteBatch.DrawLine(corners[2], corners[3], color, thickness);
887 spriteBatch.DrawLine(corners[3] + offset, corners[0] - offset, color, thickness);
892 var color = flip ? GUIStyle.Green : Color.White;
893 var hsv = ToolBox.RGBToHSV(color);
899 btn.
Color = ToolBoxCore.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
900 btn.
SelectedColor = ToolBoxCore.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
904 btn.
HoverColor = ToolBoxCore.HSVToRGB(hsvHover.X, hsvHover.Y, hsvHover.Z);
911 if (highlightedListBox !=
null) { highlightedListBox.
UpdateManually(deltaTime); }
920 if (textBox ==
null)
continue;
936 first.UpdateEditing(cam, deltaTime);
937 if (first.ResizeHorizontal || first.ResizeVertical)
939 first.UpdateResizing(cam);
949 float minX = firstSelected.WorldRect.X,
950 maxX = firstSelected.WorldRect.Right;
954 minX = Math.Min(minX, entity.WorldRect.X);
955 maxX = Math.Max(maxX, entity.WorldRect.Right);
958 float centerX = (minX + maxX) / 2.0f;
962 me.Move(
new Vector2((centerX - me.WorldPosition.X) * 2.0f, 0.0f));
969 float minY = firstSelected.WorldRect.Y - firstSelected.WorldRect.Height,
970 maxY = firstSelected.WorldRect.Y;
975 minY = Math.Min(minY, entity.WorldRect.Y - entity.WorldRect.Height);
976 maxY = Math.Max(maxY, entity.WorldRect.Y);
979 float centerY = (minY + maxY) / 2.0f;
983 me.Move(
new Vector2(0.0f, (centerY - me.WorldPosition.Y) * 2.0f));
999 firstSelected.DrawEditing(spriteBatch, cam);
1000 if (firstSelected.ResizeHorizontal || firstSelected.ResizeVertical)
1002 firstSelected.DrawResizing(spriteBatch, cam);
1021 public static void Copy(List<MapEntity> entities)
1023 if (entities.Count == 0) {
return; }
1030 public static void Cut(List<MapEntity> entities)
1032 if (entities.Count == 0) {
return; }
1038 entities.ForEach(e => {
if (!e.Removed) { e.Remove(); } });
1042 public static void Paste(Vector2 position)
1046 List<MapEntity> prevEntities =
new List<MapEntity>(
MapEntityList);
1050 var nonWireClones = clones.Where(c => !(c is
Item item) || item.GetComponent<
Wire>() ==
null);
1051 if (!nonWireClones.Any()) { nonWireClones = clones; }
1053 Vector2 center = Vector2.Zero;
1054 nonWireClones.ForEach(c => center += c.WorldPosition);
1062 clone.Move(moveAmount);
1067 (clone as
Item)?.GetComponent<ItemContainer>()?.SetContainedItemPositions();
1078 List<MapEntity> prevEntities =
new List<MapEntity>(
MapEntityList);
1083 var newEntities =
MapEntityList.Except(prevEntities).ToList();
1087 newEntities.ForEach(e => e.ShallowRemove());
1104 HUDLayoutSettings.InventoryAreaLower.Y - HUDLayoutSettings.CrewArea.Bottom - 10;
1108 if (listBox !=
null)
1111 int contentHeight = 0;
1114 contentHeight += child.
Rect.Height + listBox.Spacing;
1122 MathHelper.Clamp(contentHeight + padding * 2, 50, maxHeight)), resizeChildren:
false);
1134 HUDLayoutSettings.HealthBarAfflictionArea.Y -
editingHUD.
Rect.Height - GUI.IntScale(10));
1140 private float RotationRad
1141 => MathHelper.ToRadians(
1149 private Vector2 GetEditingHandlePos(
int x,
int y, Camera cam)
1151 Vector2 handleDiff =
new Vector2(x * (
rect.Width * 0.5f), y * (
rect.Height * 0.5f));
1152 var rotation = -RotationRad;
1153 handleDiff = MathUtils.RotatePoint(handleDiff, rotation);
1154 if (
FlippedX) { handleDiff = handleDiff.FlipX(); }
1155 if (
FlippedY) { handleDiff = handleDiff.FlipY(); }
1156 return cam.WorldToScreen(
Position + handleDiff);
1159 float ResizeHandleSize => 10 * GUI.Scale;
1160 float ResizeHandleHighlightDistance => 8 * GUI.Scale;
1162 private void UpdateResizing(Camera cam)
1169 for (
int x = startX; x < 2; x += 2)
1171 for (
int y = startY; y < 2; y += 2)
1173 Vector2 handlePos = GetEditingHandlePos(x, y, cam);
1175 bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
1177 if (highlighted && PlayerInput.PrimaryMouseButtonDown())
1183 startMovingPos = Vector2.Zero;
1191 if (prevRect ==
null)
1196 Vector2 placePosition = prevRect.Value.Location.ToVector2();
1197 Vector2 placeSize = prevRect.Value.Size.ToVector2();
1199 static Vector2 flipThenRotate(Vector2 point, Vector2 center,
float angle,
bool flipX,
bool flipY)
1201 if (flipX) { point = (point - center).
FlipX() + center; }
1202 if (flipY) { point = (point - center).
FlipY() + center; }
1204 point = MathUtils.RotatePointAroundTarget(point, center, angle);
1209 static Vector2 rotateThenFlip(Vector2 point, Vector2 center,
float angle,
bool flipX,
bool flipY)
1211 point = MathUtils.RotatePointAroundTarget(point, center, angle);
1213 if (flipX) { point = (point - center).
FlipX() + center; }
1214 if (flipY) { point = (point - center).
FlipY() + center; }
1219 Vector2 mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
1220 Vector2 prevPos = placePosition;
1221 Vector2 prevOppositeCorner = prevPos + placeSize.FlipY();
1222 Vector2 prevCenter = placePosition + placeSize.FlipY() * 0.5f;
1223 mousePos = flipThenRotate(mousePos, prevCenter, RotationRad,
FlippedX,
FlippedY);
1225 if (!PlayerInput.IsShiftDown())
1233 placeSize.X = mousePos.X - placePosition.X;
1235 else if (resizeDirX < 0)
1239 placeSize.X = MathF.Round((placePosition.X + placeSize.X) - mousePos.X);
1240 placePosition.X = MathF.Round(mousePos.X);
1245 placeSize.Y = placePosition.Y - mousePos.Y;
1247 else if (resizeDirY > 0)
1249 mousePos.Y = Math.Max(mousePos.Y, prevRect.Value.Y - prevRect.Value.Height +
Submarine.
GridSize.Y);
1251 placeSize.Y = mousePos.Y - (prevRect.Value.Y - prevRect.Value.Height);
1252 placePosition.Y = mousePos.Y;
1255 Vector2 newPos = placePosition;
1256 Vector2 newOppositeCorner = placePosition + placeSize.FlipY();
1258 Vector2 transformedCornerDiff = rotateThenFlip(newPos-prevPos, Vector2.Zero, -RotationRad,
FlippedX,
FlippedY);
1259 Vector2 transformedOppositeCornerDiff = rotateThenFlip(newOppositeCorner-prevOppositeCorner, Vector2.Zero, -RotationRad,
FlippedX,
FlippedY);
1261 Vector2 newPosTransformed = rotateThenFlip(prevPos, prevCenter, -RotationRad,
FlippedX,
FlippedY)
1262 + transformedCornerDiff;
1263 Vector2 newOppositeTransformed = rotateThenFlip(prevOppositeCorner, prevCenter, -RotationRad,
FlippedX,
FlippedY)
1264 + transformedOppositeCornerDiff;
1265 Vector2 newTransformedCenter = (newPosTransformed + newOppositeTransformed) * 0.5f;
1267 var newDiff = (newOppositeCorner - newPos) * 0.5f;
1268 placePosition = newTransformedCenter - newDiff;
1270 if ((
int)placePosition.X !=
rect.X || (int)placePosition.Y !=
rect.Y || (
int)placeSize.X !=
rect.Width || (int)placeSize.Y !=
rect.Height)
1272 Rect =
new Rectangle((
int)placePosition.X, (
int)placePosition.Y, (
int)placeSize.X, (
int)placeSize.Y);
1275 if (!PlayerInput.PrimaryMouseButtonHeld())
1279 if (prevRect !=
null)
1281 var newData =
new List<Rectangle> {
Rect };
1282 var oldData =
new List<Rectangle> { prevRect.Value };
1283 SubEditorScreen.StoreCommand(
new TransformCommand(
new List<MapEntity> {
this }, newData, oldData,
true));
1286 if (
this is Structure structure)
1299 private void DrawResizing(SpriteBatch spriteBatch, Camera cam)
1306 for (
int x = startX; x < 2; x += 2)
1308 for (
int y = startY; y < 2; y += 2)
1310 Vector2 handlePos = GetEditingHandlePos(x, y, cam);
1312 bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
1313 var color = Color.White * (highlighted ? 1.0f : 0.6f);
1314 if (highlighted && !PlayerInput.PrimaryMouseButtonHeld())
1318 GUI.DrawRectangle(spriteBatch,
1319 handlePos -
new Vector2(ResizeHandleSize / 2),
1320 new Vector2(ResizeHandleSize),
1323 (int)Math.Max(1.5f / GameScreen.Selected.Cam.Zoom, 1.0f));
1333 HashSet<MapEntity> foundEntities =
new HashSet<MapEntity>();
1336 Quad2D selectionQuad = Quad2D.FromSubmarineRectangle(selectionRect);
1340 if (!entity.SelectableInEditor) {
continue; }
1342 Quad2D entityQuad = entity.GetTransformedQuad();
1344 if (selectionQuad.Intersects(entityQuad))
1346 foundEntities.Add(entity);
1347 entity.IsIncludedInSelection =
true;
1352 foreach (
MapEntity layerEntity
in entitiesInSameLayer.Where(e => !foundEntities.Contains(e)))
1354 foundEntities.Add(layerEntity);
1355 layerEntity.IsIncludedInSelection =
true;
1361 return foundEntities;
Vector2 ScreenToWorld(Vector2 coords)
static Character? Controlled
virtual Vector2 WorldPosition
virtual Vector2 DrawPosition
readonly ushort ID
Unique, but non-persistent identifier. Stays the same if the entities are created in the exactly same...
GUIComponent GetChild(int index)
virtual void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
bool IsParentOf(GUIComponent component, bool recursive=true)
void UpdateManually(float deltaTime, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are updated automatically in the same order they appear on the updat...
RectTransform RectTransform
IEnumerable< GUIComponent > Children
OnSelectedHandler OnSelected
GUIFrame Content
A frame that contains the contents of the listbox. The frame itself is not rendered.
static SubEditorScreen SubEditorScreen
static int GraphicsHeight
ItemInventory OwnInventory
List< Connection > Connections
static readonly List< Item > ItemList
override bool TryPutItem(Item item, Character user, IEnumerable< InvSlotType > allowedSlots=null, bool createNetworkEvent=true, bool ignoreCondition=false)
If there is room, puts the item in the inventory and returns true, otherwise returns false
readonly HashSet< Wire > DisconnectedWires
Wires that have been disconnected from the panel, but not removed completely (visible at the bottom o...
void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth=-1, Color? overrideColor=null)
Vector2 CollapseEffectOrigin
float CollapseEffectStrength
Vector2 LightTextureTargetSize
static void ResetEditingHUD()
virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam)
virtual void FlipX(bool relativeToSub)
Flip the entity horizontally
static HashSet< MapEntity > SelectedList
virtual bool SelectableInEditor
static List< MapEntity > FilteredSelectedList
bool IsIncludedInSelection
static GUIListBox HighlightedListBox
static GUIComponent editingHUD
static HashSet< MapEntity > FindSelectedEntities(Vector2 pos, Vector2 size)
Find entities whose rect intersects with the "selection rect"
static Vector2 StartMovingPos
static Item GetPotentialContainer(Vector2 position, HashSet< MapEntity > entities=null)
static Vector2 GetNudgeAmount(bool doHold=true)
virtual void FlipY(bool relativeToSub)
Flip the entity vertically
static void ColorFlipButton(GUIButton btn, bool flip)
static void PositionEditingHUD()
static readonly List< MapEntity > MapEntityList
static bool SelectionChanged
Vector2 GetCollapseEffectOffset()
static void AddSelection(MapEntity entity)
static void Paste(Vector2 position)
MapEntity(MapEntityPrefab prefab, Submarine submarine, ushort id)
float GetDrawDepth(float baseDepth, Sprite sprite)
A method that modifies the draw depth to prevent z-fighting between entities with the same sprite dep...
static void DrawEditor(SpriteBatch spriteBatch, Camera cam)
static void UpdateEditor(Camera cam, float deltaTime)
static Vector2 selectionSize
Action< Rectangle > Resized
static void RemoveSelection(MapEntity entity)
static Vector2 selectionPos
static List< MapEntity > CopyEntities(List< MapEntity > entities)
copies a list of entities to the "clipboard" (copiedList)
static readonly HashSet< MapEntity > highlightedEntities
static void DeselectAll()
static List< MapEntity > CopiedList
override Vector2 Position
static void StopSelection()
static void SelectEntity(MapEntity entity)
static GUIComponent EditingHUD
abstract MapEntity Clone()
static bool DisableSelect
static void DrawSelectionRect(SpriteBatch spriteBatch, Vector2 pos, Vector2 size, Color color)
MapEntity ReplacedBy
Used for undo/redo to determine what this item has been replaced with
virtual void AddToGUIUpdateList(int order=0)
static void Cut(List< MapEntity > entities)
virtual bool IsVisible(Rectangle worldView)
virtual void UpdateEditing(Camera cam, float deltaTime)
static void UpdateHighlighting(List< MapEntity > highlightedEntities, bool wiringMode=false)
Updates the logic that runs the highlight box when the mouse is sitting still.
MapEntity GetReplacementOrThis()
static void UpdateSelecting(Camera cam)
Update the selection logic in submarine editor
static Vector2 SelectionPos
static void DrawSelecting(SpriteBatch spriteBatch, Camera cam)
Draw the "selection rectangle" and outlines of entities that are being dragged (if any)
static void ClearHighlightedEntities()
virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true)
static void Copy(List< MapEntity > entities)
Copy the selected entities to the "clipboard" (copiedList)
static MapEntityPrefab Selected
static void StoreCommand(Command command)
static ImmutableHashSet< MapEntity > GetEntitiesInSameLayer(MapEntity entity)
static bool IsLayerLinked(MapEntity entity)
static IEnumerable< MapEntity > VisibleEntities
static readonly Vector2 GridSize
static Vector2 VectorToWorldGrid(Vector2 position, Submarine sub=null, bool round=false)
static Rectangle AbsRect(Vector2 pos, Vector2 size)