Skip to content

Commit

Permalink
You can now unselect objects in console
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal78900 committed Jul 31, 2022
1 parent 899c142 commit bb0db45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions MapEditorReborn/Commands/ToolgunCommands/SelectObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
Player player = Player.Get(sender);
if (!ToolGunHandler.TryGetMapObject(player, out MapEditorObject mapObject))
{
if (player.TryGetSessionVariable(API.API.SelectedObjectSessionVarName, out object _))
{
ToolGunHandler.SelectObject(player, null);
response = "You've successfully unselected the object!";
return true;
}

response = "You aren't looking at any Map Editor object!";
return false;
}
Expand Down
13 changes: 7 additions & 6 deletions MapEditorReborn/Events/Handlers/Internal/ToolGunHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ internal static bool SelectObject(Player player, MapEditorObject mapObject)

return true;
}
else if (player.TryGetSessionVariable(SelectedObjectSessionVarName, out mapObject))
{
mapObject.prevOwner = null;
player.SessionVariables.Remove(SelectedObjectSessionVarName);
player.ShowHint("Object has been unselected");
}

if (!player.TryGetSessionVariable(SelectedObjectSessionVarName, out mapObject))
return false;

mapObject.prevOwner = null;
player.SessionVariables.Remove(SelectedObjectSessionVarName);
player.ShowHint("Object has been unselected");

return false;
}
Expand Down

0 comments on commit bb0db45

Please sign in to comment.