Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions TombEditor/EditorActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,11 +2401,34 @@ public static void PlaceLight(LightType type)
_editor.Action = new EditorActionPlace(false, (l, r) => new LightInstance(type) { Color = color });
}

private static bool ObjectInstanceIsMoveable(ObjectInstance instance) =>
instance is ItemInstance item && !item.ItemType.IsStatic;

private static bool ObjectGroupContainsMoveable(ObjectGroup group) =>
group.Any(ObjectInstanceIsMoveable);

private static bool IsInvalidMoveablePlacement(Room room, ObjectInstance instance)
{
if (!room.IsAlternate)
return false;

if (instance is ObjectGroup group)
return ObjectGroupContainsMoveable(group);

return ObjectInstanceIsMoveable(instance);
}

public static void PlaceObject(Room room, VectorInt2 pos, ObjectInstance instance)
{
if (!(instance is ISpatial))
return;

if (IsInvalidMoveablePlacement(room, instance))
{
_editor.SendMessage("You can't add moveables to a flipped room.", PopupType.Info);
return;
}

if (instance is ObjectGroup)
{
PlaceObjectGroupContents(room, pos, (ObjectGroup)instance);
Expand Down