Skip to content

Commit

Permalink
add prefab on context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Dec 7, 2024
1 parent 4be0892 commit 1226f03
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Murder.Editor/Systems/EntitiesPlacerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Bang.Entities;
using Bang.Systems;
using ImGuiNET;
using Murder.Assets;
using Murder.Assets.Graphics;
using Murder.Components;
using Murder.Core;
Expand Down Expand Up @@ -132,8 +133,11 @@ private bool DrawCreateEmptyEntity(World world, EditorHook hook)
targetGroup,
/* name */ null);
}


ImGui.Separator();
Guid spriteGuid = Guid.Empty;
ImGui.PushID("add prop");
if (SearchBox.SearchAsset(ref spriteGuid, typeof(SpriteAsset), SearchBoxFlags.None, null, "Add unique prop"))
{
Point cursorWorldPosition = hook.LastCursorWorldPosition;
Expand All @@ -150,6 +154,29 @@ private bool DrawCreateEmptyEntity(World world, EditorHook hook)

ImGui.CloseCurrentPopup();
}
ImGui.PopID();

ImGui.Separator();

Guid prefabGuid = Guid.Empty;
ImGui.PushID("add Prefab");
if (SearchBox.SearchAsset(ref prefabGuid, typeof(PrefabAsset), SearchBoxFlags.None, null, "Add a prefab"))
{
Point cursorWorldPosition = hook.LastCursorWorldPosition;
string? targetGroup = EditorTileServices.FindTargetGroup(world, hook, cursorWorldPosition);
PrefabAsset? prefab= Game.Data.TryGetAsset<PrefabAsset>(prefabGuid);

hook.AddPrefabWithStage?.Invoke(
prefabGuid,
[
new PositionComponent(cursorWorldPosition),
], prefab?.Name ?? "Unknown Prefab");

ImGui.CloseCurrentPopup();
}
ImGui.PopID();

ImGuiHelpers.HelpTooltip("Add a saved prefab from project");

ImGui.Separator();

Expand Down

0 comments on commit 1226f03

Please sign in to comment.