Merge pull request #52830 from aaronfranke/3.x-cs-format-mini
[3.x] Some more C# formatting and style fixes
This commit is contained in:
commit
673612f1b7
46 changed files with 899 additions and 874 deletions
|
@ -12,12 +12,16 @@ namespace GodotTools.BuildLogger
|
|||
public string Parameters { get; set; }
|
||||
public LoggerVerbosity Verbosity { get; set; }
|
||||
|
||||
private StreamWriter _logStreamWriter;
|
||||
private StreamWriter _issuesStreamWriter;
|
||||
private int _indent;
|
||||
|
||||
public void Initialize(IEventSource eventSource)
|
||||
{
|
||||
if (null == Parameters)
|
||||
throw new LoggerException("Log directory parameter not specified.");
|
||||
|
||||
var parameters = Parameters.Split(new[] {';'});
|
||||
string[] parameters = Parameters.Split(new[] { ';' });
|
||||
|
||||
string logDir = parameters[0];
|
||||
|
||||
|
@ -35,8 +39,8 @@ namespace GodotTools.BuildLogger
|
|||
if (!Directory.Exists(logDir))
|
||||
Directory.CreateDirectory(logDir);
|
||||
|
||||
logStreamWriter = new StreamWriter(logFile);
|
||||
issuesStreamWriter = new StreamWriter(issuesFile);
|
||||
_logStreamWriter = new StreamWriter(logFile);
|
||||
_issuesStreamWriter = new StreamWriter(issuesFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -66,12 +70,12 @@ namespace GodotTools.BuildLogger
|
|||
private void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e)
|
||||
{
|
||||
WriteLine(e.Message);
|
||||
indent++;
|
||||
_indent++;
|
||||
}
|
||||
|
||||
private void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e)
|
||||
{
|
||||
indent--;
|
||||
_indent--;
|
||||
WriteLine(e.Message);
|
||||
}
|
||||
|
||||
|
@ -87,7 +91,7 @@ namespace GodotTools.BuildLogger
|
|||
string errorLine = $@"error,{e.File.CsvEscape()},{e.LineNumber},{e.ColumnNumber}," +
|
||||
$"{e.Code?.CsvEscape() ?? string.Empty},{e.Message.CsvEscape()}," +
|
||||
$"{e.ProjectFile?.CsvEscape() ?? string.Empty}";
|
||||
issuesStreamWriter.WriteLine(errorLine);
|
||||
_issuesStreamWriter.WriteLine(errorLine);
|
||||
}
|
||||
|
||||
private void eventSource_WarningRaised(object sender, BuildWarningEventArgs e)
|
||||
|
@ -102,7 +106,7 @@ namespace GodotTools.BuildLogger
|
|||
string warningLine = $@"warning,{e.File.CsvEscape()},{e.LineNumber},{e.ColumnNumber}," +
|
||||
$"{e.Code?.CsvEscape() ?? string.Empty},{e.Message.CsvEscape()}," +
|
||||
$"{e.ProjectFile?.CsvEscape() ?? string.Empty}";
|
||||
issuesStreamWriter.WriteLine(warningLine);
|
||||
_issuesStreamWriter.WriteLine(warningLine);
|
||||
}
|
||||
|
||||
private void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
|
||||
|
@ -136,35 +140,31 @@ namespace GodotTools.BuildLogger
|
|||
|
||||
private void WriteLine(string line)
|
||||
{
|
||||
for (int i = indent; i > 0; i--)
|
||||
for (int i = _indent; i > 0; i--)
|
||||
{
|
||||
logStreamWriter.Write("\t");
|
||||
_logStreamWriter.Write("\t");
|
||||
}
|
||||
|
||||
logStreamWriter.WriteLine(line);
|
||||
_logStreamWriter.WriteLine(line);
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
logStreamWriter.Close();
|
||||
issuesStreamWriter.Close();
|
||||
_logStreamWriter.Close();
|
||||
_issuesStreamWriter.Close();
|
||||
}
|
||||
|
||||
private bool IsVerbosityAtLeast(LoggerVerbosity checkVerbosity)
|
||||
{
|
||||
return Verbosity >= checkVerbosity;
|
||||
}
|
||||
|
||||
private StreamWriter logStreamWriter;
|
||||
private StreamWriter issuesStreamWriter;
|
||||
private int indent;
|
||||
}
|
||||
|
||||
internal static class StringExtensions
|
||||
{
|
||||
public static string CsvEscape(this string value, char delimiter = ',')
|
||||
{
|
||||
bool hasSpecialChar = value.IndexOfAny(new[] {'\"', '\n', '\r', delimiter}) != -1;
|
||||
bool hasSpecialChar = value.IndexOfAny(new[] { '\"', '\n', '\r', delimiter }) != -1;
|
||||
|
||||
if (hasSpecialChar)
|
||||
return "\"" + value.Replace("\"", "\"\"") + "\"";
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace GodotTools.Core
|
|||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
private static readonly string _driveRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
public static string RelativeToPath(this string path, string dir)
|
||||
{
|
||||
// Make sure the directory ends with a path separator
|
||||
|
@ -49,13 +51,11 @@ namespace GodotTools.Core
|
|||
return Path.DirectorySeparatorChar + path;
|
||||
}
|
||||
|
||||
private static readonly string DriveRoot = Path.GetPathRoot(Environment.CurrentDirectory);
|
||||
|
||||
public static bool IsAbsolutePath(this string path)
|
||||
{
|
||||
return path.StartsWith("/", StringComparison.Ordinal) ||
|
||||
path.StartsWith("\\", StringComparison.Ordinal) ||
|
||||
path.StartsWith(DriveRoot, StringComparison.Ordinal);
|
||||
path.StartsWith(_driveRoot, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string ToSafeDirName(this string dirName, bool allowDirSeparator = false)
|
||||
|
|
|
@ -9,95 +9,7 @@ namespace GodotTools.ProjectEditor
|
|||
{
|
||||
public class DotNetSolution
|
||||
{
|
||||
private string directoryPath;
|
||||
private readonly Dictionary<string, ProjectInfo> projects = new Dictionary<string, ProjectInfo>();
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string DirectoryPath
|
||||
{
|
||||
get => directoryPath;
|
||||
set => directoryPath = value.IsAbsolutePath() ? value : Path.GetFullPath(value);
|
||||
}
|
||||
|
||||
public class ProjectInfo
|
||||
{
|
||||
public string Guid;
|
||||
public string PathRelativeToSolution;
|
||||
public List<string> Configs = new List<string>();
|
||||
}
|
||||
|
||||
public void AddNewProject(string name, ProjectInfo projectInfo)
|
||||
{
|
||||
projects[name] = projectInfo;
|
||||
}
|
||||
|
||||
public bool HasProject(string name)
|
||||
{
|
||||
return projects.ContainsKey(name);
|
||||
}
|
||||
|
||||
public ProjectInfo GetProjectInfo(string name)
|
||||
{
|
||||
return projects[name];
|
||||
}
|
||||
|
||||
public bool RemoveProject(string name)
|
||||
{
|
||||
return projects.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (!Directory.Exists(DirectoryPath))
|
||||
throw new FileNotFoundException("The solution directory does not exist.");
|
||||
|
||||
string projectsDecl = string.Empty;
|
||||
string slnPlatformsCfg = string.Empty;
|
||||
string projPlatformsCfg = string.Empty;
|
||||
|
||||
bool isFirstProject = true;
|
||||
|
||||
foreach (var pair in projects)
|
||||
{
|
||||
string name = pair.Key;
|
||||
ProjectInfo projectInfo = pair.Value;
|
||||
|
||||
if (!isFirstProject)
|
||||
projectsDecl += "\n";
|
||||
|
||||
projectsDecl += string.Format(ProjectDeclaration,
|
||||
name, projectInfo.PathRelativeToSolution.Replace("/", "\\"), projectInfo.Guid);
|
||||
|
||||
for (int i = 0; i < projectInfo.Configs.Count; i++)
|
||||
{
|
||||
string config = projectInfo.Configs[i];
|
||||
|
||||
if (i != 0 || !isFirstProject)
|
||||
{
|
||||
slnPlatformsCfg += "\n";
|
||||
projPlatformsCfg += "\n";
|
||||
}
|
||||
|
||||
slnPlatformsCfg += string.Format(SolutionPlatformsConfig, config);
|
||||
projPlatformsCfg += string.Format(ProjectPlatformsConfig, projectInfo.Guid, config);
|
||||
}
|
||||
|
||||
isFirstProject = false;
|
||||
}
|
||||
|
||||
string solutionPath = Path.Combine(DirectoryPath, Name + ".sln");
|
||||
string content = string.Format(SolutionTemplate, projectsDecl, slnPlatformsCfg, projPlatformsCfg);
|
||||
|
||||
File.WriteAllText(solutionPath, content, Encoding.UTF8); // UTF-8 with BOM
|
||||
}
|
||||
|
||||
public DotNetSolution(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
const string SolutionTemplate =
|
||||
private const string _solutionTemplate =
|
||||
@"Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
{0}
|
||||
|
@ -111,23 +23,111 @@ Global
|
|||
EndGlobal
|
||||
";
|
||||
|
||||
const string ProjectDeclaration =
|
||||
private const string _projectDeclaration =
|
||||
@"Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{0}"", ""{1}"", ""{{{2}}}""
|
||||
EndProject";
|
||||
|
||||
const string SolutionPlatformsConfig =
|
||||
private const string _solutionPlatformsConfig =
|
||||
@" {0}|Any CPU = {0}|Any CPU";
|
||||
|
||||
const string ProjectPlatformsConfig =
|
||||
private const string _projectPlatformsConfig =
|
||||
@" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU
|
||||
{{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU";
|
||||
|
||||
private string _directoryPath;
|
||||
private readonly Dictionary<string, ProjectInfo> _projects = new Dictionary<string, ProjectInfo>();
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string DirectoryPath
|
||||
{
|
||||
get => _directoryPath;
|
||||
set => _directoryPath = value.IsAbsolutePath() ? value : Path.GetFullPath(value);
|
||||
}
|
||||
|
||||
public class ProjectInfo
|
||||
{
|
||||
public string Guid;
|
||||
public string PathRelativeToSolution;
|
||||
public List<string> Configs = new List<string>();
|
||||
}
|
||||
|
||||
public void AddNewProject(string name, ProjectInfo projectInfo)
|
||||
{
|
||||
_projects[name] = projectInfo;
|
||||
}
|
||||
|
||||
public bool HasProject(string name)
|
||||
{
|
||||
return _projects.ContainsKey(name);
|
||||
}
|
||||
|
||||
public ProjectInfo GetProjectInfo(string name)
|
||||
{
|
||||
return _projects[name];
|
||||
}
|
||||
|
||||
public bool RemoveProject(string name)
|
||||
{
|
||||
return _projects.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (!Directory.Exists(DirectoryPath))
|
||||
throw new FileNotFoundException("The solution directory does not exist.");
|
||||
|
||||
string projectsDecl = string.Empty;
|
||||
string slnPlatformsCfg = string.Empty;
|
||||
string projPlatformsCfg = string.Empty;
|
||||
|
||||
bool isFirstProject = true;
|
||||
|
||||
foreach (var pair in _projects)
|
||||
{
|
||||
string name = pair.Key;
|
||||
ProjectInfo projectInfo = pair.Value;
|
||||
|
||||
if (!isFirstProject)
|
||||
projectsDecl += "\n";
|
||||
|
||||
projectsDecl += string.Format(_projectDeclaration,
|
||||
name, projectInfo.PathRelativeToSolution.Replace("/", "\\"), projectInfo.Guid);
|
||||
|
||||
for (int i = 0; i < projectInfo.Configs.Count; i++)
|
||||
{
|
||||
string config = projectInfo.Configs[i];
|
||||
|
||||
if (i != 0 || !isFirstProject)
|
||||
{
|
||||
slnPlatformsCfg += "\n";
|
||||
projPlatformsCfg += "\n";
|
||||
}
|
||||
|
||||
slnPlatformsCfg += string.Format(_solutionPlatformsConfig, config);
|
||||
projPlatformsCfg += string.Format(_projectPlatformsConfig, projectInfo.Guid, config);
|
||||
}
|
||||
|
||||
isFirstProject = false;
|
||||
}
|
||||
|
||||
string solutionPath = Path.Combine(DirectoryPath, Name + ".sln");
|
||||
string content = string.Format(_solutionTemplate, projectsDecl, slnPlatformsCfg, projPlatformsCfg);
|
||||
|
||||
File.WriteAllText(solutionPath, content, Encoding.UTF8); // UTF-8 with BOM
|
||||
}
|
||||
|
||||
public DotNetSolution(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public static void MigrateFromOldConfigNames(string slnPath)
|
||||
{
|
||||
if (!File.Exists(slnPath))
|
||||
return;
|
||||
|
||||
var input = File.ReadAllText(slnPath);
|
||||
string input = File.ReadAllText(slnPath);
|
||||
|
||||
if (!Regex.IsMatch(input, Regex.Escape("Tools|Any CPU")))
|
||||
return;
|
||||
|
@ -151,7 +151,7 @@ EndProject";
|
|||
};
|
||||
|
||||
var regex = new Regex(string.Join("|", dict.Keys.Select(Regex.Escape)));
|
||||
var result = regex.Replace(input, m => dict[m.Value]);
|
||||
string result = regex.Replace(input, m => dict[m.Value]);
|
||||
|
||||
if (result != input)
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace GodotTools.ProjectEditor
|
|||
return identifier;
|
||||
}
|
||||
|
||||
static bool IsKeyword(string value, bool anyDoubleUnderscore)
|
||||
private static bool IsKeyword(string value, bool anyDoubleUnderscore)
|
||||
{
|
||||
// Identifiers that start with double underscore are meant to be used for reserved keywords.
|
||||
// Only existing keywords are enforced, but it may be useful to forbid any identifier
|
||||
|
@ -103,14 +103,14 @@ namespace GodotTools.ProjectEditor
|
|||
}
|
||||
else
|
||||
{
|
||||
if (DoubleUnderscoreKeywords.Contains(value))
|
||||
if (_doubleUnderscoreKeywords.Contains(value))
|
||||
return true;
|
||||
}
|
||||
|
||||
return Keywords.Contains(value);
|
||||
return _keywords.Contains(value);
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> DoubleUnderscoreKeywords = new HashSet<string>
|
||||
private static readonly HashSet<string> _doubleUnderscoreKeywords = new HashSet<string>
|
||||
{
|
||||
"__arglist",
|
||||
"__makeref",
|
||||
|
@ -118,7 +118,7 @@ namespace GodotTools.ProjectEditor
|
|||
"__refvalue",
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> Keywords = new HashSet<string>
|
||||
private static readonly HashSet<string> _keywords = new HashSet<string>
|
||||
{
|
||||
"as",
|
||||
"do",
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace GodotTools.Build
|
|||
public string[] Targets { get; }
|
||||
public string Configuration { get; }
|
||||
public bool Restore { get; }
|
||||
public Array<string> CustomProperties { get; } = new Array<string>(); // TODO Use List once we have proper serialization
|
||||
// TODO Use List once we have proper serialization
|
||||
public Array<string> CustomProperties { get; } = new Array<string>();
|
||||
|
||||
public string LogsDirPath => Path.Combine(GodotSharpDirs.BuildLogsDirs, $"{Solution.MD5Text()}_{Configuration}");
|
||||
|
||||
|
@ -32,12 +33,12 @@ namespace GodotTools.Build
|
|||
unchecked
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 29 + Solution.GetHashCode();
|
||||
hash = hash * 29 + Targets.GetHashCode();
|
||||
hash = hash * 29 + Configuration.GetHashCode();
|
||||
hash = hash * 29 + Restore.GetHashCode();
|
||||
hash = hash * 29 + CustomProperties.GetHashCode();
|
||||
hash = hash * 29 + LogsDirPath.GetHashCode();
|
||||
hash = (hash * 29) + Solution.GetHashCode();
|
||||
hash = (hash * 29) + Targets.GetHashCode();
|
||||
hash = (hash * 29) + Configuration.GetHashCode();
|
||||
hash = (hash * 29) + Restore.GetHashCode();
|
||||
hash = (hash * 29) + CustomProperties.GetHashCode();
|
||||
hash = (hash * 29) + LogsDirPath.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace GodotTools.Build
|
|||
|
||||
private static void RemoveOldIssuesFile(BuildInfo buildInfo)
|
||||
{
|
||||
var issuesFile = GetIssuesFilePath(buildInfo);
|
||||
string issuesFile = GetIssuesFilePath(buildInfo);
|
||||
|
||||
if (!File.Exists(issuesFile))
|
||||
return;
|
||||
|
|
|
@ -22,14 +22,6 @@ namespace GodotTools.Build
|
|||
public string ProjectFile { get; set; }
|
||||
}
|
||||
|
||||
private readonly Array<BuildIssue> issues = new Array<BuildIssue>(); // TODO Use List once we have proper serialization
|
||||
private ItemList issuesList;
|
||||
private TextEdit buildLog;
|
||||
private PopupMenu issuesListContextMenu;
|
||||
|
||||
private readonly object pendingBuildLogTextLock = new object();
|
||||
[NotNull] private string pendingBuildLogText = string.Empty;
|
||||
|
||||
[Signal]
|
||||
public delegate void BuildStateChanged();
|
||||
|
||||
|
@ -61,13 +53,21 @@ namespace GodotTools.Build
|
|||
}
|
||||
}
|
||||
|
||||
private BuildInfo BuildInfo { get; set; }
|
||||
|
||||
public bool LogVisible
|
||||
{
|
||||
set => buildLog.Visible = value;
|
||||
set => _buildLog.Visible = value;
|
||||
}
|
||||
|
||||
// TODO Use List once we have proper serialization.
|
||||
private readonly Array<BuildIssue> _issues = new Array<BuildIssue>();
|
||||
private ItemList _issuesList;
|
||||
private PopupMenu _issuesListContextMenu;
|
||||
private TextEdit _buildLog;
|
||||
private BuildInfo _buildInfo;
|
||||
|
||||
private readonly object _pendingBuildLogTextLock = new object();
|
||||
[NotNull] private string _pendingBuildLogText = string.Empty;
|
||||
|
||||
private void LoadIssuesFromFile(string csvFile)
|
||||
{
|
||||
using (var file = new Godot.File())
|
||||
|
@ -108,7 +108,7 @@ namespace GodotTools.Build
|
|||
else
|
||||
ErrorCount += 1;
|
||||
|
||||
issues.Add(issue);
|
||||
_issues.Add(issue);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -120,21 +120,21 @@ namespace GodotTools.Build
|
|||
|
||||
private void IssueActivated(int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= issuesList.GetItemCount())
|
||||
if (idx < 0 || idx >= _issuesList.GetItemCount())
|
||||
throw new IndexOutOfRangeException("Item list index out of range");
|
||||
|
||||
// Get correct issue idx from issue list
|
||||
int issueIndex = (int)issuesList.GetItemMetadata(idx);
|
||||
int issueIndex = (int)_issuesList.GetItemMetadata(idx);
|
||||
|
||||
if (issueIndex < 0 || issueIndex >= issues.Count)
|
||||
if (issueIndex < 0 || issueIndex >= _issues.Count)
|
||||
throw new IndexOutOfRangeException("Issue index out of range");
|
||||
|
||||
BuildIssue issue = issues[issueIndex];
|
||||
BuildIssue issue = _issues[issueIndex];
|
||||
|
||||
if (string.IsNullOrEmpty(issue.ProjectFile) && string.IsNullOrEmpty(issue.File))
|
||||
return;
|
||||
|
||||
string projectDir = issue.ProjectFile.Length > 0 ? issue.ProjectFile.GetBaseDir() : BuildInfo.Solution.GetBaseDir();
|
||||
string projectDir = issue.ProjectFile.Length > 0 ? issue.ProjectFile.GetBaseDir() : _buildInfo.Solution.GetBaseDir();
|
||||
|
||||
string file = Path.Combine(projectDir.SimplifyGodotPath(), issue.File.SimplifyGodotPath());
|
||||
|
||||
|
@ -154,14 +154,14 @@ namespace GodotTools.Build
|
|||
|
||||
public void UpdateIssuesList()
|
||||
{
|
||||
issuesList.Clear();
|
||||
_issuesList.Clear();
|
||||
|
||||
using (var warningIcon = GetIcon("Warning", "EditorIcons"))
|
||||
using (var errorIcon = GetIcon("Error", "EditorIcons"))
|
||||
{
|
||||
for (int i = 0; i < issues.Count; i++)
|
||||
for (int i = 0; i < _issues.Count; i++)
|
||||
{
|
||||
BuildIssue issue = issues[i];
|
||||
BuildIssue issue = _issues[i];
|
||||
|
||||
if (!(issue.Warning ? WarningsVisible : ErrorsVisible))
|
||||
continue;
|
||||
|
@ -192,11 +192,11 @@ namespace GodotTools.Build
|
|||
|
||||
int lineBreakIdx = text.IndexOf("\n", StringComparison.Ordinal);
|
||||
string itemText = lineBreakIdx == -1 ? text : text.Substring(0, lineBreakIdx);
|
||||
issuesList.AddItem(itemText, issue.Warning ? warningIcon : errorIcon);
|
||||
_issuesList.AddItem(itemText, issue.Warning ? warningIcon : errorIcon);
|
||||
|
||||
int index = issuesList.GetItemCount() - 1;
|
||||
issuesList.SetItemTooltip(index, tooltip);
|
||||
issuesList.SetItemMetadata(index, i);
|
||||
int index = _issuesList.GetItemCount() - 1;
|
||||
_issuesList.SetItemTooltip(index, tooltip);
|
||||
_issuesList.SetItemMetadata(index, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,12 +206,12 @@ namespace GodotTools.Build
|
|||
HasBuildExited = true;
|
||||
BuildResult = Build.BuildResult.Error;
|
||||
|
||||
issuesList.Clear();
|
||||
_issuesList.Clear();
|
||||
|
||||
var issue = new BuildIssue {Message = cause, Warning = false};
|
||||
|
||||
ErrorCount += 1;
|
||||
issues.Add(issue);
|
||||
_issues.Add(issue);
|
||||
|
||||
UpdateIssuesList();
|
||||
|
||||
|
@ -220,13 +220,13 @@ namespace GodotTools.Build
|
|||
|
||||
private void BuildStarted(BuildInfo buildInfo)
|
||||
{
|
||||
BuildInfo = buildInfo;
|
||||
_buildInfo = buildInfo;
|
||||
HasBuildExited = false;
|
||||
|
||||
issues.Clear();
|
||||
_issues.Clear();
|
||||
WarningCount = 0;
|
||||
ErrorCount = 0;
|
||||
buildLog.Text = string.Empty;
|
||||
_buildLog.Text = string.Empty;
|
||||
|
||||
UpdateIssuesList();
|
||||
|
||||
|
@ -238,7 +238,7 @@ namespace GodotTools.Build
|
|||
HasBuildExited = true;
|
||||
BuildResult = result;
|
||||
|
||||
LoadIssuesFromFile(Path.Combine(BuildInfo.LogsDirPath, BuildManager.MsBuildIssuesFileName));
|
||||
LoadIssuesFromFile(Path.Combine(_buildInfo.LogsDirPath, BuildManager.MsBuildIssuesFileName));
|
||||
|
||||
UpdateIssuesList();
|
||||
|
||||
|
@ -247,46 +247,46 @@ namespace GodotTools.Build
|
|||
|
||||
private void UpdateBuildLogText()
|
||||
{
|
||||
lock (pendingBuildLogTextLock)
|
||||
lock (_pendingBuildLogTextLock)
|
||||
{
|
||||
buildLog.Text += pendingBuildLogText;
|
||||
pendingBuildLogText = string.Empty;
|
||||
_buildLog.Text += _pendingBuildLogText;
|
||||
_pendingBuildLogText = string.Empty;
|
||||
ScrollToLastNonEmptyLogLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void StdOutputReceived(string text)
|
||||
{
|
||||
lock (pendingBuildLogTextLock)
|
||||
lock (_pendingBuildLogTextLock)
|
||||
{
|
||||
if (pendingBuildLogText.Length == 0)
|
||||
if (_pendingBuildLogText.Length == 0)
|
||||
CallDeferred(nameof(UpdateBuildLogText));
|
||||
pendingBuildLogText += text + "\n";
|
||||
_pendingBuildLogText += text + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void StdErrorReceived(string text)
|
||||
{
|
||||
lock (pendingBuildLogTextLock)
|
||||
lock (_pendingBuildLogTextLock)
|
||||
{
|
||||
if (pendingBuildLogText.Length == 0)
|
||||
if (_pendingBuildLogText.Length == 0)
|
||||
CallDeferred(nameof(UpdateBuildLogText));
|
||||
pendingBuildLogText += text + "\n";
|
||||
_pendingBuildLogText += text + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollToLastNonEmptyLogLine()
|
||||
{
|
||||
int line;
|
||||
for (line = buildLog.GetLineCount(); line > 0; line--)
|
||||
for (line = _buildLog.GetLineCount(); line > 0; line--)
|
||||
{
|
||||
string lineText = buildLog.GetLine(line);
|
||||
string lineText = _buildLog.GetLine(line);
|
||||
|
||||
if (!string.IsNullOrEmpty(lineText) || !string.IsNullOrEmpty(lineText?.Trim()))
|
||||
break;
|
||||
}
|
||||
|
||||
buildLog.CursorSetLine(line);
|
||||
_buildLog.CursorSetLine(line);
|
||||
}
|
||||
|
||||
public void RestartBuild()
|
||||
|
@ -319,11 +319,11 @@ namespace GodotTools.Build
|
|||
// We don't allow multi-selection but just in case that changes later...
|
||||
string text = null;
|
||||
|
||||
foreach (int issueIndex in issuesList.GetSelectedItems())
|
||||
foreach (int issueIndex in _issuesList.GetSelectedItems())
|
||||
{
|
||||
if (text != null)
|
||||
text += "\n";
|
||||
text += issuesList.GetItemText(issueIndex);
|
||||
text += _issuesList.GetItemText(issueIndex);
|
||||
}
|
||||
|
||||
if (text != null)
|
||||
|
@ -339,20 +339,20 @@ namespace GodotTools.Build
|
|||
{
|
||||
_ = index; // Unused
|
||||
|
||||
issuesListContextMenu.Clear();
|
||||
issuesListContextMenu.SetSize(new Vector2(1, 1));
|
||||
_issuesListContextMenu.Clear();
|
||||
_issuesListContextMenu.SetSize(new Vector2(1, 1));
|
||||
|
||||
if (issuesList.IsAnythingSelected())
|
||||
if (_issuesList.IsAnythingSelected())
|
||||
{
|
||||
// Add menu entries for the selected item
|
||||
issuesListContextMenu.AddIconItem(GetIcon("ActionCopy", "EditorIcons"),
|
||||
_issuesListContextMenu.AddIconItem(GetIcon("ActionCopy", "EditorIcons"),
|
||||
label: "Copy Error".TTR(), (int)IssuesContextMenuOption.Copy);
|
||||
}
|
||||
|
||||
if (issuesListContextMenu.GetItemCount() > 0)
|
||||
if (_issuesListContextMenu.GetItemCount() > 0)
|
||||
{
|
||||
issuesListContextMenu.SetPosition(issuesList.RectGlobalPosition + atPosition);
|
||||
issuesListContextMenu.Popup_();
|
||||
_issuesListContextMenu.SetPosition(_issuesList.RectGlobalPosition + atPosition);
|
||||
_issuesListContextMenu.Popup_();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,27 +369,27 @@ namespace GodotTools.Build
|
|||
};
|
||||
AddChild(hsc);
|
||||
|
||||
issuesList = new ItemList
|
||||
_issuesList = new ItemList
|
||||
{
|
||||
SizeFlagsVertical = (int)SizeFlags.ExpandFill,
|
||||
SizeFlagsHorizontal = (int)SizeFlags.ExpandFill // Avoid being squashed by the build log
|
||||
};
|
||||
issuesList.Connect("item_activated", this, nameof(IssueActivated));
|
||||
issuesList.AllowRmbSelect = true;
|
||||
issuesList.Connect("item_rmb_selected", this, nameof(IssuesListRmbSelected));
|
||||
hsc.AddChild(issuesList);
|
||||
_issuesList.Connect("item_activated", this, nameof(IssueActivated));
|
||||
_issuesList.AllowRmbSelect = true;
|
||||
_issuesList.Connect("item_rmb_selected", this, nameof(IssuesListRmbSelected));
|
||||
hsc.AddChild(_issuesList);
|
||||
|
||||
issuesListContextMenu = new PopupMenu();
|
||||
issuesListContextMenu.Connect("id_pressed", this, nameof(IssuesListContextOptionPressed));
|
||||
issuesList.AddChild(issuesListContextMenu);
|
||||
_issuesListContextMenu = new PopupMenu();
|
||||
_issuesListContextMenu.Connect("id_pressed", this, nameof(IssuesListContextOptionPressed));
|
||||
_issuesList.AddChild(_issuesListContextMenu);
|
||||
|
||||
buildLog = new TextEdit
|
||||
_buildLog = new TextEdit
|
||||
{
|
||||
Readonly = true,
|
||||
SizeFlagsVertical = (int)SizeFlags.ExpandFill,
|
||||
SizeFlagsHorizontal = (int)SizeFlags.ExpandFill // Avoid being squashed by the issues list
|
||||
};
|
||||
hsc.AddChild(buildLog);
|
||||
hsc.AddChild(_buildLog);
|
||||
|
||||
AddBuildEventListeners();
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace GodotTools.Build
|
|||
{
|
||||
public BuildOutputView BuildOutputView { get; private set; }
|
||||
|
||||
private MenuButton buildMenuBtn;
|
||||
private Button errorsBtn;
|
||||
private Button warningsBtn;
|
||||
private Button viewLogBtn;
|
||||
private MenuButton _buildMenuBtn;
|
||||
private Button _errorsBtn;
|
||||
private Button _warningsBtn;
|
||||
private Button _viewLogBtn;
|
||||
|
||||
private void WarningsToggled(bool pressed)
|
||||
{
|
||||
|
@ -116,16 +116,16 @@ namespace GodotTools.Build
|
|||
var toolBarHBox = new HBoxContainer { SizeFlagsHorizontal = (int)SizeFlags.ExpandFill };
|
||||
AddChild(toolBarHBox);
|
||||
|
||||
buildMenuBtn = new MenuButton { Text = "Build", Icon = GetIcon("Play", "EditorIcons") };
|
||||
toolBarHBox.AddChild(buildMenuBtn);
|
||||
_buildMenuBtn = new MenuButton { Text = "Build", Icon = GetIcon("Play", "EditorIcons") };
|
||||
toolBarHBox.AddChild(_buildMenuBtn);
|
||||
|
||||
var buildMenu = buildMenuBtn.GetPopup();
|
||||
var buildMenu = _buildMenuBtn.GetPopup();
|
||||
buildMenu.AddItem("Build Solution".TTR(), (int)BuildMenuOptions.BuildSolution);
|
||||
buildMenu.AddItem("Rebuild Solution".TTR(), (int)BuildMenuOptions.RebuildSolution);
|
||||
buildMenu.AddItem("Clean Solution".TTR(), (int)BuildMenuOptions.CleanSolution);
|
||||
buildMenu.Connect("id_pressed", this, nameof(BuildMenuOptionPressed));
|
||||
|
||||
errorsBtn = new Button
|
||||
_errorsBtn = new Button
|
||||
{
|
||||
HintTooltip = "Show Errors".TTR(),
|
||||
Icon = GetIcon("StatusError", "EditorIcons"),
|
||||
|
@ -134,10 +134,10 @@ namespace GodotTools.Build
|
|||
Pressed = true,
|
||||
FocusMode = FocusModeEnum.None
|
||||
};
|
||||
errorsBtn.Connect("toggled", this, nameof(ErrorsToggled));
|
||||
toolBarHBox.AddChild(errorsBtn);
|
||||
_errorsBtn.Connect("toggled", this, nameof(ErrorsToggled));
|
||||
toolBarHBox.AddChild(_errorsBtn);
|
||||
|
||||
warningsBtn = new Button
|
||||
_warningsBtn = new Button
|
||||
{
|
||||
HintTooltip = "Show Warnings".TTR(),
|
||||
Icon = GetIcon("NodeWarning", "EditorIcons"),
|
||||
|
@ -146,18 +146,18 @@ namespace GodotTools.Build
|
|||
Pressed = true,
|
||||
FocusMode = FocusModeEnum.None
|
||||
};
|
||||
warningsBtn.Connect("toggled", this, nameof(WarningsToggled));
|
||||
toolBarHBox.AddChild(warningsBtn);
|
||||
_warningsBtn.Connect("toggled", this, nameof(WarningsToggled));
|
||||
toolBarHBox.AddChild(_warningsBtn);
|
||||
|
||||
viewLogBtn = new Button
|
||||
_viewLogBtn = new Button
|
||||
{
|
||||
Text = "Show Output".TTR(),
|
||||
ToggleMode = true,
|
||||
Pressed = true,
|
||||
FocusMode = FocusModeEnum.None
|
||||
};
|
||||
viewLogBtn.Connect("toggled", this, nameof(ViewLogToggled));
|
||||
toolBarHBox.AddChild(viewLogBtn);
|
||||
_viewLogBtn.Connect("toggled", this, nameof(ViewLogToggled));
|
||||
toolBarHBox.AddChild(_viewLogBtn);
|
||||
|
||||
BuildOutputView = new BuildOutputView();
|
||||
AddChild(BuildOutputView);
|
||||
|
@ -169,12 +169,12 @@ namespace GodotTools.Build
|
|||
|
||||
if (what == NotificationThemeChanged)
|
||||
{
|
||||
if (buildMenuBtn != null)
|
||||
buildMenuBtn.Icon = GetIcon("Play", "EditorIcons");
|
||||
if (errorsBtn != null)
|
||||
errorsBtn.Icon = GetIcon("StatusError", "EditorIcons");
|
||||
if (warningsBtn != null)
|
||||
warningsBtn.Icon = GetIcon("NodeWarning", "EditorIcons");
|
||||
if (_buildMenuBtn != null)
|
||||
_buildMenuBtn.Icon = GetIcon("Play", "EditorIcons");
|
||||
if (_errorsBtn != null)
|
||||
_errorsBtn.Icon = GetIcon("StatusError", "EditorIcons");
|
||||
if (_warningsBtn != null)
|
||||
_warningsBtn.Icon = GetIcon("NodeWarning", "EditorIcons");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace GodotTools.Build
|
|||
}
|
||||
case BuildTool.JetBrainsMsBuild:
|
||||
{
|
||||
var editorPath = (string)editorSettings.GetSetting(RiderPathManager.EditorPathSettingName);
|
||||
string editorPath = (string)editorSettings.GetSetting(RiderPathManager.EditorPathSettingName);
|
||||
|
||||
if (!File.Exists(editorPath))
|
||||
throw new FileNotFoundException($"Cannot find Rider executable. Tried with path: {editorPath}");
|
||||
|
@ -165,7 +165,9 @@ namespace GodotTools.Build
|
|||
|
||||
// Try to find 15.0 with vswhere
|
||||
|
||||
var envNames = Internal.GodotIs32Bits() ? new[] {"ProgramFiles", "ProgramW6432"} : new[] {"ProgramFiles(x86)", "ProgramFiles"};
|
||||
string[] envNames = Internal.GodotIs32Bits() ?
|
||||
envNames = new[] { "ProgramFiles", "ProgramW6432" } :
|
||||
envNames = new[] { "ProgramFiles(x86)", "ProgramFiles" };
|
||||
|
||||
string vsWherePath = null;
|
||||
foreach (var envName in envNames)
|
||||
|
|
|
@ -73,12 +73,12 @@ namespace GodotTools.Export
|
|||
|
||||
if (platform == OS.Platforms.iOS)
|
||||
{
|
||||
var architectures = GetEnablediOSArchs(features).ToArray();
|
||||
string[] architectures = GetEnablediOSArchs(features).ToArray();
|
||||
CompileAssembliesForiOS(exporter, isDebug, architectures, aotOpts, aotTempDir, assembliesPrepared, bclDir);
|
||||
}
|
||||
else if (platform == OS.Platforms.Android)
|
||||
{
|
||||
var abis = GetEnabledAndroidAbis(features).ToArray();
|
||||
string[] abis = GetEnabledAndroidAbis(features).ToArray();
|
||||
CompileAssembliesForAndroid(exporter, isDebug, abis, aotOpts, aotTempDir, assembliesPrepared, bclDir);
|
||||
}
|
||||
else
|
||||
|
@ -114,7 +114,7 @@ namespace GodotTools.Export
|
|||
ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir);
|
||||
|
||||
// The Godot exporter expects us to pass the abi in the tags parameter
|
||||
exporter.AddSharedObject(soFilePath, tags: new[] {abi});
|
||||
exporter.AddSharedObject(soFilePath, tags: new[] { abi });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,8 @@ namespace GodotTools.Export
|
|||
}
|
||||
else
|
||||
{
|
||||
string outputDataLibDir = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib");
|
||||
string libDir = platform == OS.Platforms.Windows ? "bin" : "lib";
|
||||
string outputDataLibDir = Path.Combine(outputDataDir, "Mono", libDir);
|
||||
File.Copy(tempOutputFilePath, Path.Combine(outputDataLibDir, outputFileName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace GodotTools.Export
|
|||
public class ExportPlugin : EditorExportPlugin
|
||||
{
|
||||
[Flags]
|
||||
enum I18NCodesets
|
||||
private enum I18NCodesets
|
||||
{
|
||||
None = 0,
|
||||
CJK = 1,
|
||||
|
@ -31,6 +31,8 @@ namespace GodotTools.Export
|
|||
All = CJK | MidEast | Other | Rare | West
|
||||
}
|
||||
|
||||
private string _maybeLastExportError;
|
||||
|
||||
private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string bclDir)
|
||||
{
|
||||
var codesets = (I18NCodesets)ProjectSettings.GetSetting("mono/export/i18n_codesets");
|
||||
|
@ -83,8 +85,6 @@ namespace GodotTools.Export
|
|||
GlobalDef("mono/export/aot/android_toolchain_path", "");
|
||||
}
|
||||
|
||||
private string maybeLastExportError;
|
||||
|
||||
private void AddFile(string srcPath, string dstPath, bool remap = false)
|
||||
{
|
||||
// Add file to the PCK
|
||||
|
@ -129,14 +129,14 @@ namespace GodotTools.Export
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
maybeLastExportError = e.Message;
|
||||
_maybeLastExportError = e.Message;
|
||||
|
||||
// 'maybeLastExportError' cannot be null or empty if there was an error, so we
|
||||
// must consider the possibility of exceptions being thrown without a message.
|
||||
if (string.IsNullOrEmpty(maybeLastExportError))
|
||||
maybeLastExportError = $"Exception thrown: {e.GetType().Name}";
|
||||
if (string.IsNullOrEmpty(_maybeLastExportError))
|
||||
_maybeLastExportError = $"Exception thrown: {e.GetType().Name}";
|
||||
|
||||
GD.PushError($"Failed to export project: {maybeLastExportError}");
|
||||
GD.PushError($"Failed to export project: {_maybeLastExportError}");
|
||||
Console.Error.WriteLine(e);
|
||||
// TODO: Do something on error once _ExportBegin supports failing.
|
||||
}
|
||||
|
@ -320,10 +320,10 @@ namespace GodotTools.Export
|
|||
Directory.Delete(aotTempDir, recursive: true);
|
||||
|
||||
// TODO: Just a workaround until the export plugins can be made to abort with errors
|
||||
if (!string.IsNullOrEmpty(maybeLastExportError)) // Check empty as well, because it's set to empty after hot-reloading
|
||||
if (!string.IsNullOrEmpty(_maybeLastExportError)) // Check empty as well, because it's set to empty after hot-reloading
|
||||
{
|
||||
string lastExportError = maybeLastExportError;
|
||||
maybeLastExportError = null;
|
||||
string lastExportError = _maybeLastExportError;
|
||||
_maybeLastExportError = null;
|
||||
|
||||
GodotSharpEditor.Instance.ShowErrorDialog(lastExportError, "Failed to export C# project");
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ namespace GodotTools.Export
|
|||
|
||||
private static string DetermineDataDirNameForProject()
|
||||
{
|
||||
var appName = (string)ProjectSettings.GetSetting("application/config/name");
|
||||
string appName = (string)ProjectSettings.GetSetting("application/config/name");
|
||||
string appNameSafe = appName.ToSafeDirName();
|
||||
return $"data_{appNameSafe}";
|
||||
}
|
||||
|
|
|
@ -21,19 +21,20 @@ namespace GodotTools
|
|||
{
|
||||
public class GodotSharpEditor : EditorPlugin, ISerializationListener
|
||||
{
|
||||
private EditorSettings editorSettings;
|
||||
private EditorSettings _editorSettings;
|
||||
|
||||
private PopupMenu menuPopup;
|
||||
private PopupMenu _menuPopup;
|
||||
|
||||
private AcceptDialog errorDialog;
|
||||
private AcceptDialog _errorDialog;
|
||||
|
||||
private ToolButton bottomPanelBtn;
|
||||
private ToolButton toolBarButton;
|
||||
private ToolButton _bottomPanelBtn;
|
||||
private ToolButton _toolBarButton;
|
||||
|
||||
// TODO Use WeakReference once we have proper serialization.
|
||||
private WeakRef _exportPluginWeak;
|
||||
|
||||
public GodotIdeManager GodotIdeManager { get; private set; }
|
||||
|
||||
private WeakRef exportPluginWeak; // TODO Use WeakReference once we have proper serialization
|
||||
|
||||
public MSBuildPanel MSBuildPanel { get; private set; }
|
||||
|
||||
public bool SkipBuildBeforePlaying { get; set; } = false;
|
||||
|
@ -42,7 +43,7 @@ namespace GodotTools
|
|||
{
|
||||
get
|
||||
{
|
||||
var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name");
|
||||
string projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name");
|
||||
projectAssemblyName = projectAssemblyName.ToSafeDirName();
|
||||
if (string.IsNullOrEmpty(projectAssemblyName))
|
||||
projectAssemblyName = "UnnamedProject";
|
||||
|
@ -123,9 +124,9 @@ namespace GodotTools
|
|||
|
||||
private void _RemoveCreateSlnMenuOption()
|
||||
{
|
||||
menuPopup.RemoveItem(menuPopup.GetItemIndex((int)MenuOptions.CreateSln));
|
||||
bottomPanelBtn.Show();
|
||||
toolBarButton.Show();
|
||||
_menuPopup.RemoveItem(_menuPopup.GetItemIndex((int)MenuOptions.CreateSln));
|
||||
_bottomPanelBtn.Show();
|
||||
_toolBarButton.Show();
|
||||
}
|
||||
|
||||
private void _MenuOptionPressed(MenuOptions id)
|
||||
|
@ -201,9 +202,9 @@ namespace GodotTools
|
|||
|
||||
public void ShowErrorDialog(string message, string title = "Error")
|
||||
{
|
||||
errorDialog.WindowTitle = title;
|
||||
errorDialog.DialogText = message;
|
||||
errorDialog.PopupCenteredMinsize();
|
||||
_errorDialog.WindowTitle = title;
|
||||
_errorDialog.DialogText = message;
|
||||
_errorDialog.PopupCenteredMinsize();
|
||||
}
|
||||
|
||||
private static string _vsCodePath = string.Empty;
|
||||
|
@ -216,7 +217,7 @@ namespace GodotTools
|
|||
[UsedImplicitly]
|
||||
public Error OpenInExternalEditor(Script script, int line, int col)
|
||||
{
|
||||
var editorId = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor");
|
||||
var editorId = (ExternalEditorId)_editorSettings.GetSetting("mono/editor/external_editor");
|
||||
|
||||
switch (editorId)
|
||||
{
|
||||
|
@ -272,7 +273,6 @@ namespace GodotTools
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case ExternalEditorId.VsCode:
|
||||
{
|
||||
if (string.IsNullOrEmpty(_vsCodePath) || !File.Exists(_vsCodePath))
|
||||
|
@ -308,7 +308,7 @@ namespace GodotTools
|
|||
}
|
||||
}
|
||||
|
||||
var resourcePath = ProjectSettings.GlobalizePath("res://");
|
||||
string resourcePath = ProjectSettings.GlobalizePath("res://");
|
||||
args.Add(resourcePath);
|
||||
|
||||
string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath);
|
||||
|
@ -357,7 +357,6 @@ namespace GodotTools
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
@ -368,7 +367,7 @@ namespace GodotTools
|
|||
[UsedImplicitly]
|
||||
public bool OverridesExternalEditor()
|
||||
{
|
||||
return (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor") != ExternalEditorId.None;
|
||||
return (ExternalEditorId)_editorSettings.GetSetting("mono/editor/external_editor") != ExternalEditorId.None;
|
||||
}
|
||||
|
||||
public override bool Build()
|
||||
|
@ -409,8 +408,8 @@ namespace GodotTools
|
|||
|
||||
private void BuildStateChanged()
|
||||
{
|
||||
if (bottomPanelBtn != null)
|
||||
bottomPanelBtn.Icon = MSBuildPanel.BuildOutputView.BuildStateIcon;
|
||||
if (_bottomPanelBtn != null)
|
||||
_bottomPanelBtn.Icon = MSBuildPanel.BuildOutputView.BuildStateIcon;
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
|
@ -424,25 +423,25 @@ namespace GodotTools
|
|||
var editorInterface = GetEditorInterface();
|
||||
var editorBaseControl = editorInterface.GetBaseControl();
|
||||
|
||||
editorSettings = editorInterface.GetEditorSettings();
|
||||
_editorSettings = editorInterface.GetEditorSettings();
|
||||
|
||||
errorDialog = new AcceptDialog();
|
||||
editorBaseControl.AddChild(errorDialog);
|
||||
_errorDialog = new AcceptDialog();
|
||||
editorBaseControl.AddChild(_errorDialog);
|
||||
|
||||
MSBuildPanel = new MSBuildPanel();
|
||||
bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());
|
||||
_bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());
|
||||
|
||||
AddChild(new HotReloadAssemblyWatcher {Name = "HotReloadAssemblyWatcher"});
|
||||
|
||||
menuPopup = new PopupMenu();
|
||||
menuPopup.Hide();
|
||||
menuPopup.SetAsToplevel(true);
|
||||
_menuPopup = new PopupMenu();
|
||||
_menuPopup.Hide();
|
||||
_menuPopup.SetAsToplevel(true);
|
||||
|
||||
AddToolSubmenuItem("C#", menuPopup);
|
||||
AddToolSubmenuItem("C#", _menuPopup);
|
||||
|
||||
var buildSolutionShortcut = (ShortCut)EditorShortcut("mono/build_solution");
|
||||
|
||||
toolBarButton = new ToolButton
|
||||
_toolBarButton = new ToolButton
|
||||
{
|
||||
Text = "Build",
|
||||
HintTooltip = "Build Solution".TTR(),
|
||||
|
@ -450,8 +449,8 @@ namespace GodotTools
|
|||
Shortcut = buildSolutionShortcut,
|
||||
ShortcutInTooltip = true
|
||||
};
|
||||
toolBarButton.Connect("pressed", this, nameof(BuildSolutionPressed));
|
||||
AddControlToContainer(CustomControlContainer.Toolbar, toolBarButton);
|
||||
_toolBarButton.Connect("pressed", this, nameof(BuildSolutionPressed));
|
||||
AddControlToContainer(CustomControlContainer.Toolbar, _toolBarButton);
|
||||
|
||||
if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
|
||||
{
|
||||
|
@ -459,12 +458,12 @@ namespace GodotTools
|
|||
}
|
||||
else
|
||||
{
|
||||
bottomPanelBtn.Hide();
|
||||
toolBarButton.Hide();
|
||||
menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
|
||||
_bottomPanelBtn.Hide();
|
||||
_toolBarButton.Hide();
|
||||
_menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
|
||||
}
|
||||
|
||||
menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));
|
||||
_menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));
|
||||
|
||||
// External editor settings
|
||||
EditorDef("mono/editor/external_editor", ExternalEditorId.None);
|
||||
|
@ -492,7 +491,7 @@ namespace GodotTools
|
|||
$",JetBrains Rider:{(int)ExternalEditorId.Rider}";
|
||||
}
|
||||
|
||||
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
||||
_editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
||||
{
|
||||
["type"] = Variant.Type.Int,
|
||||
["name"] = "mono/editor/external_editor",
|
||||
|
@ -504,7 +503,7 @@ namespace GodotTools
|
|||
var exportPlugin = new ExportPlugin();
|
||||
AddExportPlugin(exportPlugin);
|
||||
exportPlugin.RegisterExportSettings();
|
||||
exportPluginWeak = WeakRef(exportPlugin);
|
||||
_exportPluginWeak = WeakRef(exportPlugin);
|
||||
|
||||
BuildManager.Initialize();
|
||||
RiderPathManager.Initialize();
|
||||
|
@ -517,15 +516,15 @@ namespace GodotTools
|
|||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (exportPluginWeak != null)
|
||||
if (_exportPluginWeak != null)
|
||||
{
|
||||
// We need to dispose our export plugin before the editor destroys EditorSettings.
|
||||
// Otherwise, if the GC disposes it at a later time, EditorExportPlatformAndroid
|
||||
// will be freed after EditorSettings already was, and its device polling thread
|
||||
// will try to access the EditorSettings singleton, resulting in null dereferencing.
|
||||
(exportPluginWeak.GetRef() as ExportPlugin)?.Dispose();
|
||||
(_exportPluginWeak.GetRef() as ExportPlugin)?.Dispose();
|
||||
|
||||
exportPluginWeak.Dispose();
|
||||
_exportPluginWeak.Dispose();
|
||||
}
|
||||
|
||||
GodotIdeManager?.Dispose();
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace GodotTools
|
|||
{
|
||||
public class HotReloadAssemblyWatcher : Node
|
||||
{
|
||||
private Timer watchTimer;
|
||||
private Timer _watchTimer;
|
||||
|
||||
public override void _Notification(int what)
|
||||
{
|
||||
|
@ -27,22 +27,22 @@ namespace GodotTools
|
|||
|
||||
public void RestartTimer()
|
||||
{
|
||||
watchTimer.Stop();
|
||||
watchTimer.Start();
|
||||
_watchTimer.Stop();
|
||||
_watchTimer.Start();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
watchTimer = new Timer
|
||||
_watchTimer = new Timer
|
||||
{
|
||||
OneShot = false,
|
||||
WaitTime = (float)EditorDef("mono/assembly_watch_interval_sec", 0.5)
|
||||
};
|
||||
watchTimer.Connect("timeout", this, nameof(TimerTimeout));
|
||||
AddChild(watchTimer);
|
||||
watchTimer.Start();
|
||||
_watchTimer.Connect("timeout", this, nameof(TimerTimeout));
|
||||
AddChild(_watchTimer);
|
||||
_watchTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,22 +10,22 @@ namespace GodotTools.Ides
|
|||
{
|
||||
public sealed class GodotIdeManager : Node, ISerializationListener
|
||||
{
|
||||
private MessagingServer MessagingServer { get; set; }
|
||||
private MessagingServer _messagingServer;
|
||||
|
||||
private MonoDevelop.Instance monoDevelInstance;
|
||||
private MonoDevelop.Instance vsForMacInstance;
|
||||
private MonoDevelop.Instance _monoDevelInstance;
|
||||
private MonoDevelop.Instance _vsForMacInstance;
|
||||
|
||||
private MessagingServer GetRunningOrNewServer()
|
||||
{
|
||||
if (MessagingServer != null && !MessagingServer.IsDisposed)
|
||||
return MessagingServer;
|
||||
if (_messagingServer != null && !_messagingServer.IsDisposed)
|
||||
return _messagingServer;
|
||||
|
||||
MessagingServer?.Dispose();
|
||||
MessagingServer = new MessagingServer(OS.GetExecutablePath(), ProjectSettings.GlobalizePath(GodotSharpDirs.ResMetadataDir), new GodotLogger());
|
||||
_messagingServer?.Dispose();
|
||||
_messagingServer = new MessagingServer(OS.GetExecutablePath(), ProjectSettings.GlobalizePath(GodotSharpDirs.ResMetadataDir), new GodotLogger());
|
||||
|
||||
_ = MessagingServer.Listen();
|
||||
_ = _messagingServer.Listen();
|
||||
|
||||
return MessagingServer;
|
||||
return _messagingServer;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
|
@ -48,7 +48,7 @@ namespace GodotTools.Ides
|
|||
|
||||
if (disposing)
|
||||
{
|
||||
MessagingServer?.Dispose();
|
||||
_messagingServer?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +113,14 @@ namespace GodotTools.Ides
|
|||
{
|
||||
if (Utils.OS.IsOSX && editorId == ExternalEditorId.VisualStudioForMac)
|
||||
{
|
||||
vsForMacInstance = (vsForMacInstance?.IsDisposed ?? true ? null : vsForMacInstance) ??
|
||||
_vsForMacInstance = (_vsForMacInstance?.IsDisposed ?? true ? null : _vsForMacInstance) ??
|
||||
new MonoDevelop.Instance(solutionPath, MonoDevelop.EditorId.VisualStudioForMac);
|
||||
return vsForMacInstance;
|
||||
return _vsForMacInstance;
|
||||
}
|
||||
|
||||
monoDevelInstance = (monoDevelInstance?.IsDisposed ?? true ? null : monoDevelInstance) ??
|
||||
_monoDevelInstance = (_monoDevelInstance?.IsDisposed ?? true ? null : _monoDevelInstance) ??
|
||||
new MonoDevelop.Instance(solutionPath, MonoDevelop.EditorId.MonoDevelop);
|
||||
return monoDevelInstance;
|
||||
return _monoDevelInstance;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -157,17 +157,17 @@ namespace GodotTools.Ides
|
|||
}
|
||||
}
|
||||
|
||||
public struct EditorPick
|
||||
public readonly struct EditorPick
|
||||
{
|
||||
private readonly string identity;
|
||||
private readonly string _identity;
|
||||
|
||||
public EditorPick(string identity)
|
||||
{
|
||||
this.identity = identity;
|
||||
_identity = identity;
|
||||
}
|
||||
|
||||
public bool IsAnyConnected() =>
|
||||
GodotSharpEditor.Instance.GodotIdeManager.GetRunningOrNewServer().IsAnyConnected(identity);
|
||||
GodotSharpEditor.Instance.GodotIdeManager.GetRunningOrNewServer().IsAnyConnected(_identity);
|
||||
|
||||
private void SendRequest<TResponse>(Request request)
|
||||
where TResponse : Response, new()
|
||||
|
@ -175,7 +175,7 @@ namespace GodotTools.Ides
|
|||
// Logs an error if no client is connected with the specified identity
|
||||
GodotSharpEditor.Instance.GodotIdeManager
|
||||
.GetRunningOrNewServer()
|
||||
.BroadcastRequest<TResponse>(identity, request);
|
||||
.BroadcastRequest<TResponse>(_identity, request);
|
||||
}
|
||||
|
||||
public void SendOpenFile(string file)
|
||||
|
|
|
@ -21,24 +21,26 @@ namespace GodotTools.Ides
|
|||
{
|
||||
public sealed class MessagingServer : IDisposable
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly FileStream metaFile;
|
||||
private string MetaFilePath { get; }
|
||||
private readonly FileStream _metaFile;
|
||||
private string _metaFilePath;
|
||||
|
||||
private readonly SemaphoreSlim peersSem = new SemaphoreSlim(1);
|
||||
private readonly SemaphoreSlim _peersSem = new SemaphoreSlim(1);
|
||||
|
||||
private readonly TcpListener listener;
|
||||
private readonly TcpListener _listener;
|
||||
|
||||
private readonly Dictionary<string, Queue<NotifyAwaiter<bool>>> clientConnectedAwaiters = new Dictionary<string, Queue<NotifyAwaiter<bool>>>();
|
||||
private readonly Dictionary<string, Queue<NotifyAwaiter<bool>>> clientDisconnectedAwaiters = new Dictionary<string, Queue<NotifyAwaiter<bool>>>();
|
||||
private readonly Dictionary<string, Queue<NotifyAwaiter<bool>>> _clientConnectedAwaiters =
|
||||
new Dictionary<string, Queue<NotifyAwaiter<bool>>>();
|
||||
private readonly Dictionary<string, Queue<NotifyAwaiter<bool>>> _clientDisconnectedAwaiters =
|
||||
new Dictionary<string, Queue<NotifyAwaiter<bool>>>();
|
||||
|
||||
public async Task<bool> AwaitClientConnected(string identity)
|
||||
{
|
||||
if (!clientConnectedAwaiters.TryGetValue(identity, out var queue))
|
||||
if (!_clientConnectedAwaiters.TryGetValue(identity, out var queue))
|
||||
{
|
||||
queue = new Queue<NotifyAwaiter<bool>>();
|
||||
clientConnectedAwaiters.Add(identity, queue);
|
||||
_clientConnectedAwaiters.Add(identity, queue);
|
||||
}
|
||||
|
||||
var awaiter = new NotifyAwaiter<bool>();
|
||||
|
@ -48,10 +50,10 @@ namespace GodotTools.Ides
|
|||
|
||||
public async Task<bool> AwaitClientDisconnected(string identity)
|
||||
{
|
||||
if (!clientDisconnectedAwaiters.TryGetValue(identity, out var queue))
|
||||
if (!_clientDisconnectedAwaiters.TryGetValue(identity, out var queue))
|
||||
{
|
||||
queue = new Queue<NotifyAwaiter<bool>>();
|
||||
clientDisconnectedAwaiters.Add(identity, queue);
|
||||
_clientDisconnectedAwaiters.Add(identity, queue);
|
||||
}
|
||||
|
||||
var awaiter = new NotifyAwaiter<bool>();
|
||||
|
@ -77,7 +79,7 @@ namespace GodotTools.Ides
|
|||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
using (await peersSem.UseAsync())
|
||||
using (await _peersSem.UseAsync())
|
||||
{
|
||||
if (IsDisposed) // lock may not be fair
|
||||
return;
|
||||
|
@ -95,19 +97,19 @@ namespace GodotTools.Ides
|
|||
foreach (var connection in Peers)
|
||||
connection.Dispose();
|
||||
Peers.Clear();
|
||||
listener?.Stop();
|
||||
_listener?.Stop();
|
||||
|
||||
metaFile?.Dispose();
|
||||
_metaFile?.Dispose();
|
||||
|
||||
File.Delete(MetaFilePath);
|
||||
File.Delete(_metaFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
public MessagingServer(string editorExecutablePath, string projectMetadataDir, ILogger logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
this._logger = logger;
|
||||
|
||||
MetaFilePath = Path.Combine(projectMetadataDir, GodotIdeMetadata.DefaultFileName);
|
||||
_metaFilePath = Path.Combine(projectMetadataDir, GodotIdeMetadata.DefaultFileName);
|
||||
|
||||
// Make sure the directory exists
|
||||
Directory.CreateDirectory(projectMetadataDir);
|
||||
|
@ -115,13 +117,13 @@ namespace GodotTools.Ides
|
|||
// The Godot editor's file system thread can keep the file open for writing, so we are forced to allow write sharing...
|
||||
const FileShare metaFileShare = FileShare.ReadWrite;
|
||||
|
||||
metaFile = File.Open(MetaFilePath, FileMode.Create, FileAccess.Write, metaFileShare);
|
||||
_metaFile = File.Open(_metaFilePath, FileMode.Create, FileAccess.Write, metaFileShare);
|
||||
|
||||
listener = new TcpListener(new IPEndPoint(IPAddress.Loopback, port: 0));
|
||||
listener.Start();
|
||||
_listener = new TcpListener(new IPEndPoint(IPAddress.Loopback, port: 0));
|
||||
_listener.Start();
|
||||
|
||||
int port = ((IPEndPoint)listener.Server.LocalEndPoint).Port;
|
||||
using (var metaFileWriter = new StreamWriter(metaFile, Encoding.UTF8))
|
||||
int port = ((IPEndPoint)_listener.Server.LocalEndPoint).Port;
|
||||
using (var metaFileWriter = new StreamWriter(_metaFile, Encoding.UTF8))
|
||||
{
|
||||
metaFileWriter.WriteLine(port);
|
||||
metaFileWriter.WriteLine(editorExecutablePath);
|
||||
|
@ -130,30 +132,30 @@ namespace GodotTools.Ides
|
|||
|
||||
private async Task AcceptClient(TcpClient tcpClient)
|
||||
{
|
||||
logger.LogDebug("Accept client...");
|
||||
_logger.LogDebug("Accept client...");
|
||||
|
||||
using (var peer = new Peer(tcpClient, new ServerHandshake(), new ServerMessageHandler(), logger))
|
||||
using (var peer = new Peer(tcpClient, new ServerHandshake(), new ServerMessageHandler(), _logger))
|
||||
{
|
||||
// ReSharper disable AccessToDisposedClosure
|
||||
peer.Connected += () =>
|
||||
{
|
||||
logger.LogInfo("Connection open with Ide Client");
|
||||
_logger.LogInfo("Connection open with Ide Client");
|
||||
|
||||
if (clientConnectedAwaiters.TryGetValue(peer.RemoteIdentity, out var queue))
|
||||
if (_clientConnectedAwaiters.TryGetValue(peer.RemoteIdentity, out var queue))
|
||||
{
|
||||
while (queue.Count > 0)
|
||||
queue.Dequeue().SetResult(true);
|
||||
clientConnectedAwaiters.Remove(peer.RemoteIdentity);
|
||||
_clientConnectedAwaiters.Remove(peer.RemoteIdentity);
|
||||
}
|
||||
};
|
||||
|
||||
peer.Disconnected += () =>
|
||||
{
|
||||
if (clientDisconnectedAwaiters.TryGetValue(peer.RemoteIdentity, out var queue))
|
||||
if (_clientDisconnectedAwaiters.TryGetValue(peer.RemoteIdentity, out var queue))
|
||||
{
|
||||
while (queue.Count > 0)
|
||||
queue.Dequeue().SetResult(true);
|
||||
clientDisconnectedAwaiters.Remove(peer.RemoteIdentity);
|
||||
_clientDisconnectedAwaiters.Remove(peer.RemoteIdentity);
|
||||
}
|
||||
};
|
||||
// ReSharper restore AccessToDisposedClosure
|
||||
|
@ -162,17 +164,17 @@ namespace GodotTools.Ides
|
|||
{
|
||||
if (!await peer.DoHandshake("server"))
|
||||
{
|
||||
logger.LogError("Handshake failed");
|
||||
_logger.LogError("Handshake failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError("Handshake failed with unhandled exception: ", e);
|
||||
_logger.LogError("Handshake failed with unhandled exception: ", e);
|
||||
return;
|
||||
}
|
||||
|
||||
using (await peersSem.UseAsync())
|
||||
using (await _peersSem.UseAsync())
|
||||
Peers.Add(peer);
|
||||
|
||||
try
|
||||
|
@ -181,7 +183,7 @@ namespace GodotTools.Ides
|
|||
}
|
||||
finally
|
||||
{
|
||||
using (await peersSem.UseAsync())
|
||||
using (await _peersSem.UseAsync())
|
||||
Peers.Remove(peer);
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +194,7 @@ namespace GodotTools.Ides
|
|||
try
|
||||
{
|
||||
while (!IsDisposed)
|
||||
_ = AcceptClient(await listener.AcceptTcpClientAsync());
|
||||
_ = AcceptClient(await _listener.AcceptTcpClientAsync());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -204,11 +206,11 @@ namespace GodotTools.Ides
|
|||
public async void BroadcastRequest<TResponse>(string identity, Request request)
|
||||
where TResponse : Response, new()
|
||||
{
|
||||
using (await peersSem.UseAsync())
|
||||
using (await _peersSem.UseAsync())
|
||||
{
|
||||
if (!IsAnyConnected(identity))
|
||||
{
|
||||
logger.LogError("Cannot write request. No client connected to the Godot Ide Server.");
|
||||
_logger.LogError("Cannot write request. No client connected to the Godot Ide Server.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -225,16 +227,19 @@ namespace GodotTools.Ides
|
|||
|
||||
private class ServerHandshake : IHandshake
|
||||
{
|
||||
private static readonly string ServerHandshakeBase = $"{Peer.ServerHandshakeName},Version={Peer.ProtocolVersionMajor}.{Peer.ProtocolVersionMinor}.{Peer.ProtocolVersionRevision}";
|
||||
private static readonly string ClientHandshakePattern = $@"{Regex.Escape(Peer.ClientHandshakeName)},Version=([0-9]+)\.([0-9]+)\.([0-9]+),([_a-zA-Z][_a-zA-Z0-9]{{0,63}})";
|
||||
private static readonly string _serverHandshakeBase =
|
||||
$"{Peer.ServerHandshakeName},Version={Peer.ProtocolVersionMajor}.{Peer.ProtocolVersionMinor}.{Peer.ProtocolVersionRevision}";
|
||||
|
||||
public string GetHandshakeLine(string identity) => $"{ServerHandshakeBase},{identity}";
|
||||
private static readonly string _clientHandshakePattern =
|
||||
$@"{Regex.Escape(Peer.ClientHandshakeName)},Version=([0-9]+)\.([0-9]+)\.([0-9]+),([_a-zA-Z][_a-zA-Z0-9]{{0,63}})";
|
||||
|
||||
public string GetHandshakeLine(string identity) => $"{_serverHandshakeBase},{identity}";
|
||||
|
||||
public bool IsValidPeerHandshake(string handshake, out string identity, ILogger logger)
|
||||
{
|
||||
identity = null;
|
||||
|
||||
var match = Regex.Match(handshake, ClientHandshakePattern);
|
||||
var match = Regex.Match(handshake, _clientHandshakePattern);
|
||||
|
||||
if (!match.Success)
|
||||
return false;
|
||||
|
|
|
@ -10,17 +10,17 @@ namespace GodotTools.Ides.MonoDevelop
|
|||
public class Instance : IDisposable
|
||||
{
|
||||
public DateTime LaunchTime { get; private set; }
|
||||
private readonly string solutionFile;
|
||||
private readonly EditorId editorId;
|
||||
private readonly string _solutionFile;
|
||||
private readonly EditorId _editorId;
|
||||
|
||||
private Process process;
|
||||
private Process _process;
|
||||
|
||||
public bool IsRunning => process != null && !process.HasExited;
|
||||
public bool IsRunning => _process != null && !_process.HasExited;
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
bool newWindow = process == null || process.HasExited;
|
||||
bool newWindow = _process == null || _process.HasExited;
|
||||
|
||||
var args = new List<string>();
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace GodotTools.Ides.MonoDevelop
|
|||
|
||||
if (OS.IsOSX)
|
||||
{
|
||||
string bundleId = BundleIds[editorId];
|
||||
string bundleId = BundleIds[_editorId];
|
||||
|
||||
if (Internal.IsOsxAppBundleInstalled(bundleId))
|
||||
{
|
||||
|
@ -45,18 +45,18 @@ namespace GodotTools.Ides.MonoDevelop
|
|||
}
|
||||
else
|
||||
{
|
||||
command = OS.PathWhich(ExecutableNames[editorId]);
|
||||
command = OS.PathWhich(ExecutableNames[_editorId]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command = OS.PathWhich(ExecutableNames[editorId]);
|
||||
command = OS.PathWhich(ExecutableNames[_editorId]);
|
||||
}
|
||||
|
||||
args.Add("--ipc-tcp");
|
||||
|
||||
if (newWindow)
|
||||
args.Add("\"" + Path.GetFullPath(solutionFile) + "\"");
|
||||
args.Add("\"" + Path.GetFullPath(_solutionFile) + "\"");
|
||||
|
||||
if (command == null)
|
||||
throw new FileNotFoundException();
|
||||
|
@ -65,7 +65,7 @@ namespace GodotTools.Ides.MonoDevelop
|
|||
|
||||
if (newWindow)
|
||||
{
|
||||
process = Process.Start(new ProcessStartInfo
|
||||
_process = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = command,
|
||||
Arguments = string.Join(" ", args),
|
||||
|
@ -88,14 +88,14 @@ namespace GodotTools.Ides.MonoDevelop
|
|||
if (editorId == EditorId.VisualStudioForMac && !OS.IsOSX)
|
||||
throw new InvalidOperationException($"{nameof(EditorId.VisualStudioForMac)} not supported on this platform");
|
||||
|
||||
this.solutionFile = solutionFile;
|
||||
this.editorId = editorId;
|
||||
_solutionFile = solutionFile;
|
||||
_editorId = editorId;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
IsDisposed = true;
|
||||
process?.Dispose();
|
||||
_process?.Dispose();
|
||||
}
|
||||
|
||||
private static readonly IReadOnlyDictionary<EditorId, string> ExecutableNames;
|
||||
|
|
|
@ -11,6 +11,7 @@ using Environment = System.Environment;
|
|||
using File = System.IO.File;
|
||||
using Path = System.IO.Path;
|
||||
using OS = GodotTools.Utils.OS;
|
||||
|
||||
// ReSharper disable UnassignedField.Local
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnassignedField.Global
|
||||
|
@ -53,10 +54,10 @@ namespace GodotTools.Ides.Rider
|
|||
private static RiderInfo[] CollectAllRiderPathsLinux()
|
||||
{
|
||||
var installInfos = new List<RiderInfo>();
|
||||
var home = Environment.GetEnvironmentVariable("HOME");
|
||||
string home = Environment.GetEnvironmentVariable("HOME");
|
||||
if (!string.IsNullOrEmpty(home))
|
||||
{
|
||||
var toolboxRiderRootPath = GetToolboxBaseDir();
|
||||
string toolboxRiderRootPath = GetToolboxBaseDir();
|
||||
installInfos.AddRange(CollectPathsFromToolbox(toolboxRiderRootPath, "bin", "rider.sh", false)
|
||||
.Select(a => new RiderInfo(a, true)).ToList());
|
||||
|
||||
|
@ -65,12 +66,12 @@ namespace GodotTools.Ides.Rider
|
|||
|
||||
if (shortcut.Exists)
|
||||
{
|
||||
var lines = File.ReadAllLines(shortcut.FullName);
|
||||
foreach (var line in lines)
|
||||
string[] lines = File.ReadAllLines(shortcut.FullName);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (!line.StartsWith("Exec=\""))
|
||||
continue;
|
||||
var path = line.Split('"').Where((item, index) => index == 1).SingleOrDefault();
|
||||
string path = line.Split('"').Where((item, index) => index == 1).SingleOrDefault();
|
||||
if (string.IsNullOrEmpty(path))
|
||||
continue;
|
||||
|
||||
|
@ -82,7 +83,7 @@ namespace GodotTools.Ides.Rider
|
|||
}
|
||||
|
||||
// snap install
|
||||
var snapInstallPath = "/snap/rider/current/bin/rider.sh";
|
||||
string snapInstallPath = "/snap/rider/current/bin/rider.sh";
|
||||
if (new FileInfo(snapInstallPath).Exists)
|
||||
installInfos.Add(new RiderInfo(snapInstallPath, false));
|
||||
|
||||
|
@ -98,15 +99,15 @@ namespace GodotTools.Ides.Rider
|
|||
if (folder.Exists)
|
||||
{
|
||||
installInfos.AddRange(folder.GetDirectories("*Rider*.app")
|
||||
.Select(a => new RiderInfo(Path.Combine(a.FullName, "Contents/MacOS/rider"), false))
|
||||
.ToList());
|
||||
.Select(a => new RiderInfo(Path.Combine(a.FullName, "Contents/MacOS/rider"), false))
|
||||
.ToList());
|
||||
}
|
||||
|
||||
// /Users/user/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-1/181.3870.267/Rider EAP.app
|
||||
// should be combined with "Contents/MacOS/rider"
|
||||
var toolboxRiderRootPath = GetToolboxBaseDir();
|
||||
string toolboxRiderRootPath = GetToolboxBaseDir();
|
||||
var paths = CollectPathsFromToolbox(toolboxRiderRootPath, "", "Rider*.app", true)
|
||||
.Select(a => new RiderInfo(Path.Combine(a, "Contents/MacOS/rider"), true));
|
||||
.Select(a => new RiderInfo(Path.Combine(a, "Contents/MacOS/rider"), true));
|
||||
installInfos.AddRange(paths);
|
||||
|
||||
return installInfos.ToArray();
|
||||
|
@ -134,7 +135,7 @@ namespace GodotTools.Ides.Rider
|
|||
{
|
||||
if (OS.IsWindows)
|
||||
{
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
return GetToolboxRiderRootPath(localAppData);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace GodotTools.Ides.Rider
|
|||
if (!paths.Any())
|
||||
return;
|
||||
|
||||
var newPath = paths.Last().Path;
|
||||
string newPath = paths.Last().Path;
|
||||
Globals.EditorDef(EditorPathSettingName, newPath);
|
||||
editorSettings.SetSetting(EditorPathSettingName, newPath);
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ namespace GodotTools.Ides.Rider
|
|||
|
||||
public static bool IsExternalEditorSetToRider(EditorSettings editorSettings)
|
||||
{
|
||||
return editorSettings.HasSetting(EditorPathSettingName) && IsRider((string)editorSettings.GetSetting(EditorPathSettingName));
|
||||
return editorSettings.HasSetting(EditorPathSettingName) &&
|
||||
IsRider((string)editorSettings.GetSetting(EditorPathSettingName));
|
||||
}
|
||||
|
||||
public static bool IsRider(string path)
|
||||
|
@ -66,7 +67,7 @@ namespace GodotTools.Ides.Rider
|
|||
return false;
|
||||
|
||||
var fileInfo = new FileInfo(path);
|
||||
var filename = fileInfo.Name.ToLowerInvariant();
|
||||
string filename = fileInfo.Name.ToLowerInvariant();
|
||||
return filename.StartsWith("rider", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@ namespace GodotTools.Ides.Rider
|
|||
if (!paths.Any())
|
||||
return null;
|
||||
|
||||
var newPath = paths.Last().Path;
|
||||
string newPath = paths.Last().Path;
|
||||
editorSettings.SetSetting(EditorPathSettingName, newPath);
|
||||
Globals.EditorDef(EditorPathSettingName, newPath);
|
||||
return newPath;
|
||||
|
@ -96,8 +97,8 @@ namespace GodotTools.Ides.Rider
|
|||
|
||||
public static void OpenFile(string slnPath, string scriptPath, int line)
|
||||
{
|
||||
var pathFromSettings = GetRiderPathFromSettings();
|
||||
var path = CheckAndUpdatePath(pathFromSettings);
|
||||
string pathFromSettings = GetRiderPathFromSettings();
|
||||
string path = CheckAndUpdatePath(pathFromSettings);
|
||||
|
||||
var args = new List<string>();
|
||||
args.Add(slnPath);
|
||||
|
|
|
@ -39,45 +39,57 @@ namespace GodotTools.Internals
|
|||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResDataDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResMetadataDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResAssembliesBaseDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResAssembliesDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResConfigDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResTempDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResTempAssembliesBaseDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ResTempAssembliesDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_MonoUserDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_MonoLogsDir();
|
||||
|
||||
#region Tools-only
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_MonoSolutionsDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_BuildLogsDirs();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ProjectSlnPath();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_ProjectCsProjPath();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_DataEditorToolsDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_DataEditorPrebuiltApiDir();
|
||||
#endregion
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_DataMonoEtcDir();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string internal_DataMonoLibDir();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace GodotTools.Utils
|
|||
{
|
||||
public static class FsPathUtils
|
||||
{
|
||||
private static readonly string ResourcePath = ProjectSettings.GlobalizePath("res://");
|
||||
private static readonly string _resourcePath = ProjectSettings.GlobalizePath("res://");
|
||||
|
||||
private static bool PathStartsWithAlreadyNorm(this string childPath, string parentPath)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace GodotTools.Utils
|
|||
public static string LocalizePathWithCaseChecked(string path)
|
||||
{
|
||||
string pathNorm = path.NormalizePath() + Path.DirectorySeparatorChar;
|
||||
string resourcePathNorm = ResourcePath.NormalizePath() + Path.DirectorySeparatorChar;
|
||||
string resourcePathNorm = _resourcePath.NormalizePath() + Path.DirectorySeparatorChar;
|
||||
|
||||
if (!pathNorm.PathStartsWithAlreadyNorm(resourcePathNorm))
|
||||
return null;
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace GodotTools.Utils
|
|||
public static class OS
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
static extern string GetPlatformName();
|
||||
private static extern string GetPlatformName();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
static extern bool UnixFileHasExecutableAccess(string filePath);
|
||||
private static extern bool UnixFileHasExecutableAccess(string filePath);
|
||||
|
||||
public static class Names
|
||||
{
|
||||
|
@ -96,7 +96,10 @@ namespace GodotTools.Utils
|
|||
|
||||
public static string PathWhich([NotNull] string name)
|
||||
{
|
||||
return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name);
|
||||
if (IsWindows)
|
||||
return PathWhichWindows(name);
|
||||
|
||||
return PathWhichUnix(name);
|
||||
}
|
||||
|
||||
private static string PathWhichWindows([NotNull] string name)
|
||||
|
@ -119,7 +122,8 @@ namespace GodotTools.Utils
|
|||
}
|
||||
|
||||
string nameExt = Path.GetExtension(name);
|
||||
bool hasPathExt = !string.IsNullOrEmpty(nameExt) && windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);
|
||||
bool hasPathExt = !string.IsNullOrEmpty(nameExt) &&
|
||||
windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list
|
||||
|
||||
|
|
|
@ -939,7 +939,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
|
|||
#define ADD_INTERNAL_CALL(m_icall) \
|
||||
if (!m_icall.editor_only) { \
|
||||
cs_icalls_content.append(MEMBER_BEGIN "[MethodImpl(MethodImplOptions.InternalCall)]\n"); \
|
||||
cs_icalls_content.append(INDENT2 "internal extern static "); \
|
||||
cs_icalls_content.append(INDENT2 "internal static extern "); \
|
||||
cs_icalls_content.append(m_icall.im_type_out + " "); \
|
||||
cs_icalls_content.append(m_icall.name + "("); \
|
||||
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
|
||||
|
@ -1043,7 +1043,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
|
|||
#define ADD_INTERNAL_CALL(m_icall) \
|
||||
if (m_icall.editor_only) { \
|
||||
cs_icalls_content.append(MEMBER_BEGIN "[MethodImpl(MethodImplOptions.InternalCall)]\n"); \
|
||||
cs_icalls_content.append(INDENT2 "internal extern static "); \
|
||||
cs_icalls_content.append(INDENT2 "internal static extern "); \
|
||||
cs_icalls_content.append(m_icall.im_type_out + " "); \
|
||||
cs_icalls_content.append(m_icall.name + "("); \
|
||||
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
|
||||
|
|
|
@ -75,17 +75,17 @@ namespace Godot
|
|||
/// </returns>
|
||||
public bool Encloses(AABB with)
|
||||
{
|
||||
Vector3 src_min = _position;
|
||||
Vector3 src_max = _position + _size;
|
||||
Vector3 dst_min = with._position;
|
||||
Vector3 dst_max = with._position + with._size;
|
||||
Vector3 srcMin = _position;
|
||||
Vector3 srcMax = _position + _size;
|
||||
Vector3 dstMin = with._position;
|
||||
Vector3 dstMax = with._position + with._size;
|
||||
|
||||
return src_min.x <= dst_min.x &&
|
||||
src_max.x > dst_max.x &&
|
||||
src_min.y <= dst_min.y &&
|
||||
src_max.y > dst_max.y &&
|
||||
src_min.z <= dst_min.z &&
|
||||
src_max.z > dst_max.z;
|
||||
return srcMin.x <= dstMin.x &&
|
||||
srcMax.x > dstMax.x &&
|
||||
srcMin.y <= dstMin.y &&
|
||||
srcMax.y > dstMax.y &&
|
||||
srcMin.z <= dstMin.z &&
|
||||
srcMax.z > dstMax.z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -162,7 +162,8 @@ namespace Godot
|
|||
case 7:
|
||||
return new Vector3(_position.x + _size.x, _position.y + _size.y, _position.z + _size.z);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(idx), String.Format("Index is {0}, but a value from 0 to 7 is expected.", idx));
|
||||
throw new ArgumentOutOfRangeException(nameof(idx),
|
||||
$"Index is {idx}, but a value from 0 to 7 is expected.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,15 +174,15 @@ namespace Godot
|
|||
public Vector3 GetLongestAxis()
|
||||
{
|
||||
var axis = new Vector3(1f, 0f, 0f);
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y > max_size)
|
||||
if (_size.y > maxSize)
|
||||
{
|
||||
axis = new Vector3(0f, 1f, 0f);
|
||||
max_size = _size.y;
|
||||
maxSize = _size.y;
|
||||
}
|
||||
|
||||
if (_size.z > max_size)
|
||||
if (_size.z > maxSize)
|
||||
{
|
||||
axis = new Vector3(0f, 0f, 1f);
|
||||
}
|
||||
|
@ -196,15 +197,15 @@ namespace Godot
|
|||
public Vector3.Axis GetLongestAxisIndex()
|
||||
{
|
||||
var axis = Vector3.Axis.X;
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y > max_size)
|
||||
if (_size.y > maxSize)
|
||||
{
|
||||
axis = Vector3.Axis.Y;
|
||||
max_size = _size.y;
|
||||
maxSize = _size.y;
|
||||
}
|
||||
|
||||
if (_size.z > max_size)
|
||||
if (_size.z > maxSize)
|
||||
{
|
||||
axis = Vector3.Axis.Z;
|
||||
}
|
||||
|
@ -218,15 +219,15 @@ namespace Godot
|
|||
/// <returns>The scalar length of the longest axis of the <see cref="AABB"/>.</returns>
|
||||
public real_t GetLongestAxisSize()
|
||||
{
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y > max_size)
|
||||
max_size = _size.y;
|
||||
if (_size.y > maxSize)
|
||||
maxSize = _size.y;
|
||||
|
||||
if (_size.z > max_size)
|
||||
max_size = _size.z;
|
||||
if (_size.z > maxSize)
|
||||
maxSize = _size.z;
|
||||
|
||||
return max_size;
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -236,15 +237,15 @@ namespace Godot
|
|||
public Vector3 GetShortestAxis()
|
||||
{
|
||||
var axis = new Vector3(1f, 0f, 0f);
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y < max_size)
|
||||
if (_size.y < maxSize)
|
||||
{
|
||||
axis = new Vector3(0f, 1f, 0f);
|
||||
max_size = _size.y;
|
||||
maxSize = _size.y;
|
||||
}
|
||||
|
||||
if (_size.z < max_size)
|
||||
if (_size.z < maxSize)
|
||||
{
|
||||
axis = new Vector3(0f, 0f, 1f);
|
||||
}
|
||||
|
@ -259,15 +260,15 @@ namespace Godot
|
|||
public Vector3.Axis GetShortestAxisIndex()
|
||||
{
|
||||
var axis = Vector3.Axis.X;
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y < max_size)
|
||||
if (_size.y < maxSize)
|
||||
{
|
||||
axis = Vector3.Axis.Y;
|
||||
max_size = _size.y;
|
||||
maxSize = _size.y;
|
||||
}
|
||||
|
||||
if (_size.z < max_size)
|
||||
if (_size.z < maxSize)
|
||||
{
|
||||
axis = Vector3.Axis.Z;
|
||||
}
|
||||
|
@ -281,15 +282,15 @@ namespace Godot
|
|||
/// <returns>The scalar length of the shortest axis of the <see cref="AABB"/>.</returns>
|
||||
public real_t GetShortestAxisSize()
|
||||
{
|
||||
real_t max_size = _size.x;
|
||||
real_t maxSize = _size.x;
|
||||
|
||||
if (_size.y < max_size)
|
||||
max_size = _size.y;
|
||||
if (_size.y < maxSize)
|
||||
maxSize = _size.y;
|
||||
|
||||
if (_size.z < max_size)
|
||||
max_size = _size.z;
|
||||
if (_size.z < maxSize)
|
||||
maxSize = _size.z;
|
||||
|
||||
return max_size;
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -300,13 +301,13 @@ namespace Godot
|
|||
/// <returns>A vector representing the support.</returns>
|
||||
public Vector3 GetSupport(Vector3 dir)
|
||||
{
|
||||
Vector3 half_extents = _size * 0.5f;
|
||||
Vector3 ofs = _position + half_extents;
|
||||
Vector3 halfExtents = _size * 0.5f;
|
||||
Vector3 ofs = _position + halfExtents;
|
||||
|
||||
return ofs + new Vector3(
|
||||
dir.x > 0f ? -half_extents.x : half_extents.x,
|
||||
dir.y > 0f ? -half_extents.y : half_extents.y,
|
||||
dir.z > 0f ? -half_extents.z : half_extents.z);
|
||||
dir.x > 0f ? -halfExtents.x : halfExtents.x,
|
||||
dir.y > 0f ? -halfExtents.y : halfExtents.y,
|
||||
dir.z > 0f ? -halfExtents.z : halfExtents.z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -316,7 +317,7 @@ namespace Godot
|
|||
/// <returns>The grown <see cref="AABB"/>.</returns>
|
||||
public AABB Grow(real_t by)
|
||||
{
|
||||
var res = this;
|
||||
AABB res = this;
|
||||
|
||||
res._position.x -= by;
|
||||
res._position.y -= by;
|
||||
|
@ -385,36 +386,36 @@ namespace Godot
|
|||
/// <returns>The clipped <see cref="AABB"/>.</returns>
|
||||
public AABB Intersection(AABB with)
|
||||
{
|
||||
Vector3 src_min = _position;
|
||||
Vector3 src_max = _position + _size;
|
||||
Vector3 dst_min = with._position;
|
||||
Vector3 dst_max = with._position + with._size;
|
||||
Vector3 srcMin = _position;
|
||||
Vector3 srcMax = _position + _size;
|
||||
Vector3 dstMin = with._position;
|
||||
Vector3 dstMax = with._position + with._size;
|
||||
|
||||
Vector3 min, max;
|
||||
|
||||
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
|
||||
if (srcMin.x > dstMax.x || srcMax.x < dstMin.x)
|
||||
{
|
||||
return new AABB();
|
||||
}
|
||||
|
||||
min.x = src_min.x > dst_min.x ? src_min.x : dst_min.x;
|
||||
max.x = src_max.x < dst_max.x ? src_max.x : dst_max.x;
|
||||
min.x = srcMin.x > dstMin.x ? srcMin.x : dstMin.x;
|
||||
max.x = srcMax.x < dstMax.x ? srcMax.x : dstMax.x;
|
||||
|
||||
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
|
||||
if (srcMin.y > dstMax.y || srcMax.y < dstMin.y)
|
||||
{
|
||||
return new AABB();
|
||||
}
|
||||
|
||||
min.y = src_min.y > dst_min.y ? src_min.y : dst_min.y;
|
||||
max.y = src_max.y < dst_max.y ? src_max.y : dst_max.y;
|
||||
min.y = srcMin.y > dstMin.y ? srcMin.y : dstMin.y;
|
||||
max.y = srcMax.y < dstMax.y ? srcMax.y : dstMax.y;
|
||||
|
||||
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
|
||||
if (srcMin.z > dstMax.z || srcMax.z < dstMin.z)
|
||||
{
|
||||
return new AABB();
|
||||
}
|
||||
|
||||
min.z = src_min.z > dst_min.z ? src_min.z : dst_min.z;
|
||||
max.z = src_max.z < dst_max.z ? src_max.z : dst_max.z;
|
||||
min.z = srcMin.z > dstMin.z ? srcMin.z : dstMin.z;
|
||||
max.z = srcMax.z < dstMax.z ? srcMax.z : dstMax.z;
|
||||
|
||||
return new AABB(min, max - min);
|
||||
}
|
||||
|
@ -583,16 +584,16 @@ namespace Godot
|
|||
var end2 = new Vector3(with._size.x, with._size.y, with._size.z) + beg2;
|
||||
|
||||
var min = new Vector3(
|
||||
beg1.x < beg2.x ? beg1.x : beg2.x,
|
||||
beg1.y < beg2.y ? beg1.y : beg2.y,
|
||||
beg1.z < beg2.z ? beg1.z : beg2.z
|
||||
);
|
||||
beg1.x < beg2.x ? beg1.x : beg2.x,
|
||||
beg1.y < beg2.y ? beg1.y : beg2.y,
|
||||
beg1.z < beg2.z ? beg1.z : beg2.z
|
||||
);
|
||||
|
||||
var max = new Vector3(
|
||||
end1.x > end2.x ? end1.x : end2.x,
|
||||
end1.y > end2.y ? end1.y : end2.y,
|
||||
end1.z > end2.z ? end1.z : end2.z
|
||||
);
|
||||
end1.x > end2.x ? end1.x : end2.x,
|
||||
end1.y > end2.y ? end1.y : end2.y,
|
||||
end1.z > end2.z ? end1.z : end2.z
|
||||
);
|
||||
|
||||
return new AABB(min, max - min);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Godot.Collections
|
||||
{
|
||||
class ArraySafeHandle : SafeHandle
|
||||
internal class ArraySafeHandle : SafeHandle
|
||||
{
|
||||
public ArraySafeHandle(IntPtr handle) : base(IntPtr.Zero, true)
|
||||
{
|
||||
|
@ -33,15 +33,15 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public class Array : IList, IDisposable
|
||||
{
|
||||
ArraySafeHandle safeHandle;
|
||||
bool disposed = false;
|
||||
private ArraySafeHandle _safeHandle;
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new empty <see cref="Array"/>.
|
||||
/// </summary>
|
||||
public Array()
|
||||
{
|
||||
safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor());
|
||||
_safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,25 +69,25 @@ namespace Godot.Collections
|
|||
{
|
||||
throw new NullReferenceException($"Parameter '{nameof(array)} cannot be null.'");
|
||||
}
|
||||
safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor_MonoArray(array));
|
||||
_safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor_MonoArray(array));
|
||||
}
|
||||
|
||||
internal Array(ArraySafeHandle handle)
|
||||
{
|
||||
safeHandle = handle;
|
||||
_safeHandle = handle;
|
||||
}
|
||||
|
||||
internal Array(IntPtr handle)
|
||||
{
|
||||
safeHandle = new ArraySafeHandle(handle);
|
||||
_safeHandle = new ArraySafeHandle(handle);
|
||||
}
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
return safeHandle.DangerousGetHandle();
|
||||
return _safeHandle.DangerousGetHandle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -136,16 +136,16 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (safeHandle != null)
|
||||
if (_safeHandle != null)
|
||||
{
|
||||
safeHandle.Dispose();
|
||||
safeHandle = null;
|
||||
_safeHandle.Dispose();
|
||||
_safeHandle = null;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
// IList
|
||||
|
@ -272,67 +272,67 @@ namespace Godot.Collections
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Array_Ctor();
|
||||
internal static extern IntPtr godot_icall_Array_Ctor();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Array_Ctor_MonoArray(System.Array array);
|
||||
internal static extern IntPtr godot_icall_Array_Ctor_MonoArray(System.Array array);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_Dtor(IntPtr ptr);
|
||||
internal static extern void godot_icall_Array_Dtor(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_Array_At(IntPtr ptr, int index);
|
||||
internal static extern object godot_icall_Array_At(IntPtr ptr, int index);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_Array_At_Generic(IntPtr ptr, int index, int elemTypeEncoding, IntPtr elemTypeClass);
|
||||
internal static extern object godot_icall_Array_At_Generic(IntPtr ptr, int index, int elemTypeEncoding, IntPtr elemTypeClass);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_SetAt(IntPtr ptr, int index, object value);
|
||||
internal static extern void godot_icall_Array_SetAt(IntPtr ptr, int index, object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Array_Count(IntPtr ptr);
|
||||
internal static extern int godot_icall_Array_Count(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Array_Add(IntPtr ptr, object item);
|
||||
internal static extern int godot_icall_Array_Add(IntPtr ptr, object item);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_Clear(IntPtr ptr);
|
||||
internal static extern void godot_icall_Array_Clear(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Array_Concatenate(IntPtr left, IntPtr right);
|
||||
internal static extern IntPtr godot_icall_Array_Concatenate(IntPtr left, IntPtr right);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Array_Contains(IntPtr ptr, object item);
|
||||
internal static extern bool godot_icall_Array_Contains(IntPtr ptr, object item);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_CopyTo(IntPtr ptr, System.Array array, int arrayIndex);
|
||||
internal static extern void godot_icall_Array_CopyTo(IntPtr ptr, System.Array array, int arrayIndex);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Array_Duplicate(IntPtr ptr, bool deep);
|
||||
internal static extern IntPtr godot_icall_Array_Duplicate(IntPtr ptr, bool deep);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Array_IndexOf(IntPtr ptr, object item);
|
||||
internal static extern int godot_icall_Array_IndexOf(IntPtr ptr, object item);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_Insert(IntPtr ptr, int index, object item);
|
||||
internal static extern void godot_icall_Array_Insert(IntPtr ptr, int index, object item);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Array_Remove(IntPtr ptr, object item);
|
||||
internal static extern bool godot_icall_Array_Remove(IntPtr ptr, object item);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_RemoveAt(IntPtr ptr, int index);
|
||||
internal static extern void godot_icall_Array_RemoveAt(IntPtr ptr, int index);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static Error godot_icall_Array_Resize(IntPtr ptr, int newSize);
|
||||
internal static extern Error godot_icall_Array_Resize(IntPtr ptr, int newSize);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static Error godot_icall_Array_Shuffle(IntPtr ptr);
|
||||
internal static extern Error godot_icall_Array_Shuffle(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_Generic_GetElementTypeInfo(Type elemType, out int elemTypeEncoding, out IntPtr elemTypeClass);
|
||||
internal static extern void godot_icall_Array_Generic_GetElementTypeInfo(Type elemType, out int elemTypeEncoding, out IntPtr elemTypeClass);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_Array_ToString(IntPtr ptr);
|
||||
internal static extern string godot_icall_Array_ToString(IntPtr ptr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -344,7 +344,7 @@ namespace Godot.Collections
|
|||
/// <typeparam name="T">The type of the array.</typeparam>
|
||||
public class Array<T> : IList<T>, ICollection<T>, IEnumerable<T>
|
||||
{
|
||||
Array objectArray;
|
||||
private Array _objectArray;
|
||||
|
||||
internal static int elemTypeEncoding;
|
||||
internal static IntPtr elemTypeClass;
|
||||
|
@ -359,7 +359,7 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public Array()
|
||||
{
|
||||
objectArray = new Array();
|
||||
_objectArray = new Array();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -372,7 +372,7 @@ namespace Godot.Collections
|
|||
if (collection == null)
|
||||
throw new NullReferenceException($"Parameter '{nameof(collection)} cannot be null.'");
|
||||
|
||||
objectArray = new Array(collection);
|
||||
_objectArray = new Array(collection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -386,7 +386,7 @@ namespace Godot.Collections
|
|||
{
|
||||
throw new NullReferenceException($"Parameter '{nameof(array)} cannot be null.'");
|
||||
}
|
||||
objectArray = new Array(array);
|
||||
_objectArray = new Array(array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -395,22 +395,22 @@ namespace Godot.Collections
|
|||
/// <param name="array">The untyped array to construct from.</param>
|
||||
public Array(Array array)
|
||||
{
|
||||
objectArray = array;
|
||||
_objectArray = array;
|
||||
}
|
||||
|
||||
internal Array(IntPtr handle)
|
||||
{
|
||||
objectArray = new Array(handle);
|
||||
_objectArray = new Array(handle);
|
||||
}
|
||||
|
||||
internal Array(ArraySafeHandle handle)
|
||||
{
|
||||
objectArray = new Array(handle);
|
||||
_objectArray = new Array(handle);
|
||||
}
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
return objectArray.GetPtr();
|
||||
return _objectArray.GetPtr();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -419,7 +419,7 @@ namespace Godot.Collections
|
|||
/// <param name="from">The typed array to convert.</param>
|
||||
public static explicit operator Array(Array<T> from)
|
||||
{
|
||||
return from.objectArray;
|
||||
return from._objectArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -429,7 +429,7 @@ namespace Godot.Collections
|
|||
/// <returns>A new Godot Array.</returns>
|
||||
public Array<T> Duplicate(bool deep = false)
|
||||
{
|
||||
return new Array<T>(objectArray.Duplicate(deep));
|
||||
return new Array<T>(_objectArray.Duplicate(deep));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -439,7 +439,7 @@ namespace Godot.Collections
|
|||
/// <returns><see cref="Error.Ok"/> if successful, or an error code.</returns>
|
||||
public Error Resize(int newSize)
|
||||
{
|
||||
return objectArray.Resize(newSize);
|
||||
return _objectArray.Resize(newSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -447,7 +447,7 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public void Shuffle()
|
||||
{
|
||||
objectArray.Shuffle();
|
||||
_objectArray.Shuffle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -458,7 +458,7 @@ namespace Godot.Collections
|
|||
/// <returns>A new Godot Array with the contents of both arrays.</returns>
|
||||
public static Array<T> operator +(Array<T> left, Array<T> right)
|
||||
{
|
||||
return new Array<T>(left.objectArray + right.objectArray);
|
||||
return new Array<T>(left._objectArray + right._objectArray);
|
||||
}
|
||||
|
||||
// IList<T>
|
||||
|
@ -470,7 +470,7 @@ namespace Godot.Collections
|
|||
public T this[int index]
|
||||
{
|
||||
get { return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass); }
|
||||
set { objectArray[index] = value; }
|
||||
set { _objectArray[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -481,7 +481,7 @@ namespace Godot.Collections
|
|||
/// <returns>The index of the item, or -1 if not found.</returns>
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
return objectArray.IndexOf(item);
|
||||
return _objectArray.IndexOf(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -494,7 +494,7 @@ namespace Godot.Collections
|
|||
/// <param name="item">The item to insert.</param>
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
objectArray.Insert(index, item);
|
||||
_objectArray.Insert(index, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -503,7 +503,7 @@ namespace Godot.Collections
|
|||
/// <param name="index">The index of the element to remove.</param>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
objectArray.RemoveAt(index);
|
||||
_objectArray.RemoveAt(index);
|
||||
}
|
||||
|
||||
// ICollection<T>
|
||||
|
@ -515,7 +515,7 @@ namespace Godot.Collections
|
|||
/// <returns>The number of elements.</returns>
|
||||
public int Count
|
||||
{
|
||||
get { return objectArray.Count; }
|
||||
get { return _objectArray.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<T>.IsReadOnly => false;
|
||||
|
@ -528,7 +528,7 @@ namespace Godot.Collections
|
|||
/// <returns>The new size after adding the item.</returns>
|
||||
public void Add(T item)
|
||||
{
|
||||
objectArray.Add(item);
|
||||
_objectArray.Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -536,7 +536,7 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
objectArray.Clear();
|
||||
_objectArray.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -546,7 +546,7 @@ namespace Godot.Collections
|
|||
/// <returns>Whether or not this array contains the given item.</returns>
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return objectArray.Contains(item);
|
||||
return _objectArray.Contains(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -566,7 +566,7 @@ namespace Godot.Collections
|
|||
// TODO This may be quite slow because every element access is an internal call.
|
||||
// It could be moved entirely to an internal call if we find out how to do the cast there.
|
||||
|
||||
int count = objectArray.Count;
|
||||
int count = _objectArray.Count;
|
||||
|
||||
if (array.Length < (arrayIndex + count))
|
||||
throw new ArgumentException("Destination array was not long enough. Check destIndex and length, and the array's lower bounds.");
|
||||
|
@ -597,7 +597,7 @@ namespace Godot.Collections
|
|||
/// <returns>An enumerator.</returns>
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
int count = objectArray.Count;
|
||||
int count = _objectArray.Count;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -614,6 +614,6 @@ namespace Godot.Collections
|
|||
/// Converts this <see cref="Array{T}"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this array.</returns>
|
||||
public override string ToString() => objectArray.ToString();
|
||||
public override string ToString() => _objectArray.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,9 @@ namespace Godot
|
|||
get => new Vector3(Row0.x, Row1.x, Row2.x);
|
||||
set
|
||||
{
|
||||
this.Row0.x = value.x;
|
||||
this.Row1.x = value.y;
|
||||
this.Row2.x = value.z;
|
||||
Row0.x = value.x;
|
||||
Row1.x = value.y;
|
||||
Row2.x = value.z;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,9 @@ namespace Godot
|
|||
get => new Vector3(Row0.y, Row1.y, Row2.y);
|
||||
set
|
||||
{
|
||||
this.Row0.y = value.x;
|
||||
this.Row1.y = value.y;
|
||||
this.Row2.y = value.z;
|
||||
Row0.y = value.x;
|
||||
Row1.y = value.y;
|
||||
Row2.y = value.z;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,9 +118,9 @@ namespace Godot
|
|||
get => new Vector3(Row0.z, Row1.z, Row2.z);
|
||||
set
|
||||
{
|
||||
this.Row0.z = value.x;
|
||||
this.Row1.z = value.y;
|
||||
this.Row2.z = value.z;
|
||||
Row0.z = value.x;
|
||||
Row1.z = value.y;
|
||||
Row2.z = value.z;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ namespace Godot
|
|||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Basis"/>'s rotation in the form of a
|
||||
/// <see cref="Godot.Quat"/>. See <see cref="GetEuler"/> if you
|
||||
/// <see cref="Quat"/>. See <see cref="GetEuler"/> if you
|
||||
/// need Euler angles, but keep in mind quaternions should generally
|
||||
/// be preferred to Euler angles.
|
||||
/// </summary>
|
||||
|
@ -230,15 +230,15 @@ namespace Godot
|
|||
return orthonormalizedBasis.Quat();
|
||||
}
|
||||
|
||||
internal void SetQuatScale(Quat quat, Vector3 scale)
|
||||
internal void SetQuatScale(Quat quaternion, Vector3 scale)
|
||||
{
|
||||
SetDiagonal(scale);
|
||||
Rotate(quat);
|
||||
Rotate(quaternion);
|
||||
}
|
||||
|
||||
private void Rotate(Quat quat)
|
||||
private void Rotate(Quat quaternion)
|
||||
{
|
||||
this *= new Basis(quat);
|
||||
this *= new Basis(quaternion);
|
||||
}
|
||||
|
||||
private void SetDiagonal(Vector3 diagonal)
|
||||
|
@ -272,7 +272,7 @@ namespace Godot
|
|||
/// The returned vector contains the rotation angles in
|
||||
/// the format (X angle, Y angle, Z angle).
|
||||
///
|
||||
/// Consider using the <see cref="Basis.Quat()"/> method instead, which
|
||||
/// Consider using the <see cref="Quat()"/> method instead, which
|
||||
/// returns a <see cref="Godot.Quat"/> quaternion instead of Euler angles.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Vector3"/> representing the basis rotation in Euler angles.</returns>
|
||||
|
@ -552,7 +552,7 @@ namespace Godot
|
|||
/// <returns>The resulting dot product.</returns>
|
||||
public real_t Tdotx(Vector3 with)
|
||||
{
|
||||
return this.Row0[0] * with[0] + this.Row1[0] * with[1] + this.Row2[0] * with[2];
|
||||
return Row0[0] * with[0] + Row1[0] * with[1] + Row2[0] * with[2];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -562,7 +562,7 @@ namespace Godot
|
|||
/// <returns>The resulting dot product.</returns>
|
||||
public real_t Tdoty(Vector3 with)
|
||||
{
|
||||
return this.Row0[1] * with[0] + this.Row1[1] * with[1] + this.Row2[1] * with[2];
|
||||
return Row0[1] * with[0] + Row1[1] * with[1] + Row2[1] * with[2];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -572,7 +572,7 @@ namespace Godot
|
|||
/// <returns>The resulting dot product.</returns>
|
||||
public real_t Tdotz(Vector3 with)
|
||||
{
|
||||
return this.Row0[2] * with[0] + this.Row1[2] * with[1] + this.Row2[2] * with[2];
|
||||
return Row0[2] * with[0] + Row1[2] * with[1] + Row2[2] * with[2];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -581,7 +581,7 @@ namespace Godot
|
|||
/// <returns>The transposed basis matrix.</returns>
|
||||
public Basis Transposed()
|
||||
{
|
||||
var tr = this;
|
||||
Basis tr = this;
|
||||
|
||||
real_t temp = tr.Row0[1];
|
||||
tr.Row0[1] = tr.Row1[0];
|
||||
|
@ -608,9 +608,9 @@ namespace Godot
|
|||
{
|
||||
return new Vector3
|
||||
(
|
||||
this.Row0.Dot(v),
|
||||
this.Row1.Dot(v),
|
||||
this.Row2.Dot(v)
|
||||
Row0.Dot(v),
|
||||
Row1.Dot(v),
|
||||
Row2.Dot(v)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -627,9 +627,9 @@ namespace Godot
|
|||
{
|
||||
return new Vector3
|
||||
(
|
||||
this.Row0[0] * v.x + this.Row1[0] * v.y + this.Row2[0] * v.z,
|
||||
this.Row0[1] * v.x + this.Row1[1] * v.y + this.Row2[1] * v.z,
|
||||
this.Row0[2] * v.x + this.Row1[2] * v.y + this.Row2[2] * v.z
|
||||
Row0[0] * v.x + Row1[0] * v.y + Row2[0] * v.z,
|
||||
Row0[1] * v.x + Row1[1] * v.y + Row2[1] * v.z,
|
||||
Row0[2] * v.x + Row1[2] * v.y + Row2[2] * v.z
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -749,23 +749,23 @@ namespace Godot
|
|||
/// <summary>
|
||||
/// Constructs a pure rotation basis matrix from the given quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quat">The quaternion to create the basis from.</param>
|
||||
public Basis(Quat quat)
|
||||
/// <param name="quaternion">The quaternion to create the basis from.</param>
|
||||
public Basis(Quat quaternion)
|
||||
{
|
||||
real_t s = 2.0f / quat.LengthSquared;
|
||||
real_t s = 2.0f / quaternion.LengthSquared;
|
||||
|
||||
real_t xs = quat.x * s;
|
||||
real_t ys = quat.y * s;
|
||||
real_t zs = quat.z * s;
|
||||
real_t wx = quat.w * xs;
|
||||
real_t wy = quat.w * ys;
|
||||
real_t wz = quat.w * zs;
|
||||
real_t xx = quat.x * xs;
|
||||
real_t xy = quat.x * ys;
|
||||
real_t xz = quat.x * zs;
|
||||
real_t yy = quat.y * ys;
|
||||
real_t yz = quat.y * zs;
|
||||
real_t zz = quat.z * zs;
|
||||
real_t xs = quaternion.x * s;
|
||||
real_t ys = quaternion.y * s;
|
||||
real_t zs = quaternion.z * s;
|
||||
real_t wx = quaternion.w * xs;
|
||||
real_t wy = quaternion.w * ys;
|
||||
real_t wz = quaternion.w * zs;
|
||||
real_t xx = quaternion.x * xs;
|
||||
real_t xy = quaternion.x * ys;
|
||||
real_t xz = quaternion.x * zs;
|
||||
real_t yy = quaternion.y * ys;
|
||||
real_t yz = quaternion.y * zs;
|
||||
real_t zz = quaternion.z * zs;
|
||||
|
||||
Row0 = new Vector3(1.0f - (yy + zz), xy - wz, xz + wy);
|
||||
Row1 = new Vector3(xy + wz, 1.0f - (xx + zz), yz - wx);
|
||||
|
|
|
@ -127,11 +127,11 @@ namespace Godot
|
|||
}
|
||||
else if (g == max)
|
||||
{
|
||||
h = 2 + (b - r) / delta; // Between cyan & yellow
|
||||
h = 2 + ((b - r) / delta); // Between cyan & yellow
|
||||
}
|
||||
else
|
||||
{
|
||||
h = 4 + (r - g) / delta; // Between magenta & cyan
|
||||
h = 4 + ((r - g) / delta); // Between magenta & cyan
|
||||
}
|
||||
|
||||
h /= 6.0f;
|
||||
|
@ -358,16 +358,16 @@ namespace Godot
|
|||
Color res;
|
||||
|
||||
float sa = 1.0f - over.a;
|
||||
res.a = a * sa + over.a;
|
||||
res.a = (a * sa) + over.a;
|
||||
|
||||
if (res.a == 0)
|
||||
{
|
||||
return new Color(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
res.r = (r * a * sa + over.r * over.a) / res.a;
|
||||
res.g = (g * a * sa + over.g * over.a) / res.a;
|
||||
res.b = (b * a * sa + over.b * over.a) / res.a;
|
||||
res.r = ((r * a * sa) + (over.r * over.a)) / res.a;
|
||||
res.g = ((g * a * sa) + (over.g * over.a)) / res.a;
|
||||
res.b = ((b * a * sa) + (over.b * over.a)) / res.a;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -395,9 +395,9 @@ namespace Godot
|
|||
public Color Darkened(float amount)
|
||||
{
|
||||
Color res = this;
|
||||
res.r = res.r * (1.0f - amount);
|
||||
res.g = res.g * (1.0f - amount);
|
||||
res.b = res.b * (1.0f - amount);
|
||||
res.r *= 1.0f - amount;
|
||||
res.g *= 1.0f - amount;
|
||||
res.b *= 1.0f - amount;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -424,9 +424,9 @@ namespace Godot
|
|||
public Color Lightened(float amount)
|
||||
{
|
||||
Color res = this;
|
||||
res.r = res.r + (1.0f - res.r) * amount;
|
||||
res.g = res.g + (1.0f - res.g) * amount;
|
||||
res.b = res.b + (1.0f - res.b) * amount;
|
||||
res.r += (1.0f - res.r) * amount;
|
||||
res.g += (1.0f - res.g) * amount;
|
||||
res.b += (1.0f - res.b) * amount;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Godot.Collections
|
||||
{
|
||||
class DictionarySafeHandle : SafeHandle
|
||||
internal class DictionarySafeHandle : SafeHandle
|
||||
{
|
||||
public DictionarySafeHandle(IntPtr handle) : base(IntPtr.Zero, true)
|
||||
{
|
||||
|
@ -30,19 +30,17 @@ namespace Godot.Collections
|
|||
/// typed elements allocated in the engine in C++. Useful when
|
||||
/// interfacing with the engine.
|
||||
/// </summary>
|
||||
public class Dictionary :
|
||||
IDictionary,
|
||||
IDisposable
|
||||
public class Dictionary : IDictionary, IDisposable
|
||||
{
|
||||
DictionarySafeHandle safeHandle;
|
||||
bool disposed = false;
|
||||
private DictionarySafeHandle _safeHandle;
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new empty <see cref="Dictionary"/>.
|
||||
/// </summary>
|
||||
public Dictionary()
|
||||
{
|
||||
safeHandle = new DictionarySafeHandle(godot_icall_Dictionary_Ctor());
|
||||
_safeHandle = new DictionarySafeHandle(godot_icall_Dictionary_Ctor());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -61,20 +59,20 @@ namespace Godot.Collections
|
|||
|
||||
internal Dictionary(DictionarySafeHandle handle)
|
||||
{
|
||||
safeHandle = handle;
|
||||
_safeHandle = handle;
|
||||
}
|
||||
|
||||
internal Dictionary(IntPtr handle)
|
||||
{
|
||||
safeHandle = new DictionarySafeHandle(handle);
|
||||
_safeHandle = new DictionarySafeHandle(handle);
|
||||
}
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
return safeHandle.DangerousGetHandle();
|
||||
return _safeHandle.DangerousGetHandle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -82,16 +80,16 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (safeHandle != null)
|
||||
if (_safeHandle != null)
|
||||
{
|
||||
safeHandle.Dispose();
|
||||
safeHandle = null;
|
||||
_safeHandle.Dispose();
|
||||
_safeHandle = null;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -229,17 +227,17 @@ namespace Godot.Collections
|
|||
|
||||
private class DictionaryEnumerator : IDictionaryEnumerator
|
||||
{
|
||||
private readonly Dictionary dictionary;
|
||||
private readonly int count;
|
||||
private int index = -1;
|
||||
private bool dirty = true;
|
||||
private readonly Dictionary _dictionary;
|
||||
private readonly int _count;
|
||||
private int _index = -1;
|
||||
private bool _dirty = true;
|
||||
|
||||
private DictionaryEntry entry;
|
||||
private DictionaryEntry _entry;
|
||||
|
||||
public DictionaryEnumerator(Dictionary dictionary)
|
||||
{
|
||||
this.dictionary = dictionary;
|
||||
count = dictionary.Count;
|
||||
_dictionary = dictionary;
|
||||
_count = dictionary.Count;
|
||||
}
|
||||
|
||||
public object Current => Entry;
|
||||
|
@ -248,19 +246,19 @@ namespace Godot.Collections
|
|||
{
|
||||
get
|
||||
{
|
||||
if (dirty)
|
||||
if (_dirty)
|
||||
{
|
||||
UpdateEntry();
|
||||
}
|
||||
return entry;
|
||||
return _entry;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEntry()
|
||||
{
|
||||
dirty = false;
|
||||
godot_icall_Dictionary_KeyValuePairAt(dictionary.GetPtr(), index, out object key, out object value);
|
||||
entry = new DictionaryEntry(key, value);
|
||||
_dirty = false;
|
||||
godot_icall_Dictionary_KeyValuePairAt(_dictionary.GetPtr(), _index, out object key, out object value);
|
||||
_entry = new DictionaryEntry(key, value);
|
||||
}
|
||||
|
||||
public object Key => Entry.Key;
|
||||
|
@ -269,15 +267,15 @@ namespace Godot.Collections
|
|||
|
||||
public bool MoveNext()
|
||||
{
|
||||
index++;
|
||||
dirty = true;
|
||||
return index < count;
|
||||
_index++;
|
||||
_dirty = true;
|
||||
return _index < _count;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
index = -1;
|
||||
dirty = true;
|
||||
_index = -1;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,67 +289,67 @@ namespace Godot.Collections
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Dictionary_Ctor();
|
||||
internal static extern IntPtr godot_icall_Dictionary_Ctor();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_Dtor(IntPtr ptr);
|
||||
internal static extern void godot_icall_Dictionary_Dtor(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_Dictionary_GetValue(IntPtr ptr, object key);
|
||||
internal static extern object godot_icall_Dictionary_GetValue(IntPtr ptr, object key);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_Dictionary_GetValue_Generic(IntPtr ptr, object key, int valTypeEncoding, IntPtr valTypeClass);
|
||||
internal static extern object godot_icall_Dictionary_GetValue_Generic(IntPtr ptr, object key, int valTypeEncoding, IntPtr valTypeClass);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_SetValue(IntPtr ptr, object key, object value);
|
||||
internal static extern void godot_icall_Dictionary_SetValue(IntPtr ptr, object key, object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Dictionary_Keys(IntPtr ptr);
|
||||
internal static extern IntPtr godot_icall_Dictionary_Keys(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Dictionary_Values(IntPtr ptr);
|
||||
internal static extern IntPtr godot_icall_Dictionary_Values(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Dictionary_Count(IntPtr ptr);
|
||||
internal static extern int godot_icall_Dictionary_Count(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Dictionary_KeyValuePairs(IntPtr ptr, out IntPtr keys, out IntPtr values);
|
||||
internal static extern int godot_icall_Dictionary_KeyValuePairs(IntPtr ptr, out IntPtr keys, out IntPtr values);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_KeyValuePairAt(IntPtr ptr, int index, out object key, out object value);
|
||||
internal static extern void godot_icall_Dictionary_KeyValuePairAt(IntPtr ptr, int index, out object key, out object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_Add(IntPtr ptr, object key, object value);
|
||||
internal static extern void godot_icall_Dictionary_Add(IntPtr ptr, object key, object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_Clear(IntPtr ptr);
|
||||
internal static extern void godot_icall_Dictionary_Clear(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_Contains(IntPtr ptr, object key, object value);
|
||||
internal static extern bool godot_icall_Dictionary_Contains(IntPtr ptr, object key, object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_ContainsKey(IntPtr ptr, object key);
|
||||
internal static extern bool godot_icall_Dictionary_ContainsKey(IntPtr ptr, object key);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Dictionary_Duplicate(IntPtr ptr, bool deep);
|
||||
internal static extern IntPtr godot_icall_Dictionary_Duplicate(IntPtr ptr, bool deep);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_RemoveKey(IntPtr ptr, object key);
|
||||
internal static extern bool godot_icall_Dictionary_RemoveKey(IntPtr ptr, object key);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_Remove(IntPtr ptr, object key, object value);
|
||||
internal static extern bool godot_icall_Dictionary_Remove(IntPtr ptr, object key, object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_TryGetValue(IntPtr ptr, object key, out object value);
|
||||
internal static extern bool godot_icall_Dictionary_TryGetValue(IntPtr ptr, object key, out object value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_TryGetValue_Generic(IntPtr ptr, object key, out object value, int valTypeEncoding, IntPtr valTypeClass);
|
||||
internal static extern bool godot_icall_Dictionary_TryGetValue_Generic(IntPtr ptr, object key, out object value, int valTypeEncoding, IntPtr valTypeClass);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Dictionary_Generic_GetValueTypeInfo(Type valueType, out int valTypeEncoding, out IntPtr valTypeClass);
|
||||
internal static extern void godot_icall_Dictionary_Generic_GetValueTypeInfo(Type valueType, out int valTypeEncoding, out IntPtr valTypeClass);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_Dictionary_ToString(IntPtr ptr);
|
||||
internal static extern string godot_icall_Dictionary_ToString(IntPtr ptr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -362,10 +360,9 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of the dictionary's keys.</typeparam>
|
||||
/// <typeparam name="TValue">The type of the dictionary's values.</typeparam>
|
||||
public class Dictionary<TKey, TValue> :
|
||||
IDictionary<TKey, TValue>
|
||||
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>
|
||||
{
|
||||
private readonly Dictionary objectDict;
|
||||
private readonly Dictionary _objectDict;
|
||||
|
||||
internal static int valTypeEncoding;
|
||||
internal static IntPtr valTypeClass;
|
||||
|
@ -380,7 +377,7 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public Dictionary()
|
||||
{
|
||||
objectDict = new Dictionary();
|
||||
_objectDict = new Dictionary();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -390,7 +387,7 @@ namespace Godot.Collections
|
|||
/// <returns>A new Godot Dictionary.</returns>
|
||||
public Dictionary(IDictionary<TKey, TValue> dictionary)
|
||||
{
|
||||
objectDict = new Dictionary();
|
||||
_objectDict = new Dictionary();
|
||||
|
||||
if (dictionary == null)
|
||||
throw new NullReferenceException($"Parameter '{nameof(dictionary)} cannot be null.'");
|
||||
|
@ -412,17 +409,17 @@ namespace Godot.Collections
|
|||
/// <returns>A new Godot Dictionary.</returns>
|
||||
public Dictionary(Dictionary dictionary)
|
||||
{
|
||||
objectDict = dictionary;
|
||||
_objectDict = dictionary;
|
||||
}
|
||||
|
||||
internal Dictionary(IntPtr handle)
|
||||
{
|
||||
objectDict = new Dictionary(handle);
|
||||
_objectDict = new Dictionary(handle);
|
||||
}
|
||||
|
||||
internal Dictionary(DictionarySafeHandle handle)
|
||||
{
|
||||
objectDict = new Dictionary(handle);
|
||||
_objectDict = new Dictionary(handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -431,12 +428,12 @@ namespace Godot.Collections
|
|||
/// <param name="from">The typed dictionary to convert.</param>
|
||||
public static explicit operator Dictionary(Dictionary<TKey, TValue> from)
|
||||
{
|
||||
return from.objectDict;
|
||||
return from._objectDict;
|
||||
}
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
return objectDict.GetPtr();
|
||||
return _objectDict.GetPtr();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -446,7 +443,7 @@ namespace Godot.Collections
|
|||
/// <returns>A new Godot Dictionary.</returns>
|
||||
public Dictionary<TKey, TValue> Duplicate(bool deep = false)
|
||||
{
|
||||
return new Dictionary<TKey, TValue>(objectDict.Duplicate(deep));
|
||||
return new Dictionary<TKey, TValue>(_objectDict.Duplicate(deep));
|
||||
}
|
||||
|
||||
// IDictionary<TKey, TValue>
|
||||
|
@ -457,8 +454,8 @@ namespace Godot.Collections
|
|||
/// <value>The value at the given <paramref name="key"/>.</value>
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get { return (TValue)Dictionary.godot_icall_Dictionary_GetValue_Generic(objectDict.GetPtr(), key, valTypeEncoding, valTypeClass); }
|
||||
set { objectDict[key] = value; }
|
||||
get { return (TValue)Dictionary.godot_icall_Dictionary_GetValue_Generic(_objectDict.GetPtr(), key, valTypeEncoding, valTypeClass); }
|
||||
set { _objectDict[key] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -468,7 +465,7 @@ namespace Godot.Collections
|
|||
{
|
||||
get
|
||||
{
|
||||
IntPtr handle = Dictionary.godot_icall_Dictionary_Keys(objectDict.GetPtr());
|
||||
IntPtr handle = Dictionary.godot_icall_Dictionary_Keys(_objectDict.GetPtr());
|
||||
return new Array<TKey>(new ArraySafeHandle(handle));
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +477,7 @@ namespace Godot.Collections
|
|||
{
|
||||
get
|
||||
{
|
||||
IntPtr handle = Dictionary.godot_icall_Dictionary_Values(objectDict.GetPtr());
|
||||
IntPtr handle = Dictionary.godot_icall_Dictionary_Values(_objectDict.GetPtr());
|
||||
return new Array<TValue>(new ArraySafeHandle(handle));
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +496,7 @@ namespace Godot.Collections
|
|||
/// <param name="value">The object to add.</param>
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
objectDict.Add(key, value);
|
||||
_objectDict.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -509,7 +506,7 @@ namespace Godot.Collections
|
|||
/// <returns>Whether or not this dictionary contains the given key.</returns>
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return objectDict.Contains(key);
|
||||
return _objectDict.Contains(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -543,14 +540,14 @@ namespace Godot.Collections
|
|||
/// <returns>The number of elements.</returns>
|
||||
public int Count
|
||||
{
|
||||
get { return objectDict.Count; }
|
||||
get { return _objectDict.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly => false;
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
objectDict.Add(item.Key, item.Value);
|
||||
_objectDict.Add(item.Key, item.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -558,12 +555,12 @@ namespace Godot.Collections
|
|||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
objectDict.Clear();
|
||||
_objectDict.Clear();
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return objectDict.Contains(new KeyValuePair<object, object>(item.Key, item.Value));
|
||||
return _objectDict.Contains(new KeyValuePair<object, object>(item.Key, item.Value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -621,6 +618,6 @@ namespace Godot.Collections
|
|||
/// Converts this <see cref="Dictionary{TKey, TValue}"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this dictionary.</returns>
|
||||
public override string ToString() => objectDict.ToString();
|
||||
public override string ToString() => _objectDict.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Godot
|
|||
if (godotObject == null)
|
||||
throw new ArgumentNullException(nameof(godotObject));
|
||||
|
||||
this.Value = godotObject;
|
||||
Value = godotObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -189,16 +189,16 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string[] godot_icall_DynamicGodotObject_SetMemberList(IntPtr godotObject);
|
||||
internal static extern string[] godot_icall_DynamicGodotObject_SetMemberList(IntPtr godotObject);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_DynamicGodotObject_InvokeMember(IntPtr godotObject, string name, object[] args, out object result);
|
||||
internal static extern bool godot_icall_DynamicGodotObject_InvokeMember(IntPtr godotObject, string name, object[] args, out object result);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_DynamicGodotObject_GetMember(IntPtr godotObject, string name, out object result);
|
||||
internal static extern bool godot_icall_DynamicGodotObject_GetMember(IntPtr godotObject, string name, out object result);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_DynamicGodotObject_SetMember(IntPtr godotObject, string name, object value);
|
||||
internal static extern bool godot_icall_DynamicGodotObject_SetMember(IntPtr godotObject, string name, object value);
|
||||
|
||||
#region We don't override these methods
|
||||
|
||||
|
|
|
@ -36,6 +36,6 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static WeakRef godot_icall_Object_weakref(IntPtr obj);
|
||||
internal static extern WeakRef godot_icall_Object_weakref(IntPtr obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -552,70 +552,69 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_GD_bytes2var(byte[] bytes, bool allow_objects);
|
||||
internal static extern object godot_icall_GD_bytes2var(byte[] bytes, bool allowObjects);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_GD_convert(object what, Variant.Type type);
|
||||
internal static extern object godot_icall_GD_convert(object what, Variant.Type type);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_GD_hash(object var);
|
||||
internal static extern int godot_icall_GD_hash(object var);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static Object godot_icall_GD_instance_from_id(ulong instance_id);
|
||||
internal static extern Object godot_icall_GD_instance_from_id(ulong instanceId);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_print(object[] what);
|
||||
internal static extern void godot_icall_GD_print(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_printerr(object[] what);
|
||||
internal static extern void godot_icall_GD_printerr(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_printraw(object[] what);
|
||||
internal static extern void godot_icall_GD_printraw(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_prints(object[] what);
|
||||
internal static extern void godot_icall_GD_prints(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_printt(object[] what);
|
||||
internal static extern void godot_icall_GD_printt(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static float godot_icall_GD_randf();
|
||||
internal static extern float godot_icall_GD_randf();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static uint godot_icall_GD_randi();
|
||||
internal static extern uint godot_icall_GD_randi();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_randomize();
|
||||
|
||||
internal static extern void godot_icall_GD_randomize();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static double godot_icall_GD_rand_range(double from, double to);
|
||||
internal static extern double godot_icall_GD_rand_range(double from, double to);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static uint godot_icall_GD_rand_seed(ulong seed, out ulong newSeed);
|
||||
internal static extern uint godot_icall_GD_rand_seed(ulong seed, out ulong newSeed);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_seed(ulong seed);
|
||||
internal static extern void godot_icall_GD_seed(ulong seed);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_GD_str(object[] what);
|
||||
internal static extern string godot_icall_GD_str(object[] what);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static object godot_icall_GD_str2var(string str);
|
||||
internal static extern object godot_icall_GD_str2var(string str);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_GD_type_exists(string type);
|
||||
internal static extern bool godot_icall_GD_type_exists(string type);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static byte[] godot_icall_GD_var2bytes(object what, bool full_objects);
|
||||
internal static extern byte[] godot_icall_GD_var2bytes(object what, bool fullObjects);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_GD_var2str(object var);
|
||||
internal static extern string godot_icall_GD_var2str(object var);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_pusherror(string type);
|
||||
internal static extern void godot_icall_GD_pusherror(string type);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_GD_pushwarning(string type);
|
||||
internal static extern void godot_icall_GD_pushwarning(string type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ namespace Godot
|
|||
{
|
||||
public class GodotSynchronizationContext : SynchronizationContext
|
||||
{
|
||||
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> _queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
|
||||
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> _queue =
|
||||
new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
|
||||
|
||||
public override void Post(SendOrPostCallback d, object state)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Godot
|
|||
|
||||
try
|
||||
{
|
||||
var stackTrace = new StackTrace(true).ToString();
|
||||
string stackTrace = new StackTrace(true).ToString();
|
||||
GD.PrintErr(stackTrace);
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Godot
|
||||
{
|
||||
static class MarshalUtils
|
||||
internal static class MarshalUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the generic type definition of <paramref name="type"/>
|
||||
|
|
|
@ -40,9 +40,9 @@ namespace Godot
|
|||
public const real_t NaN = real_t.NaN;
|
||||
|
||||
// 0.0174532924f and 0.0174532925199433
|
||||
private const real_t Deg2RadConst = (real_t)0.0174532925199432957692369077M;
|
||||
private const real_t _deg2RadConst = (real_t)0.0174532925199432957692369077M;
|
||||
// 57.29578f and 57.2957795130823
|
||||
private const real_t Rad2DegConst = (real_t)57.295779513082320876798154814M;
|
||||
private const real_t _rad2DegConst = (real_t)57.295779513082320876798154814M;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the absolute value of <paramref name="s"/> (i.e. positive value).
|
||||
|
@ -199,7 +199,7 @@ namespace Godot
|
|||
/// <returns>The same angle expressed in radians.</returns>
|
||||
public static real_t Deg2Rad(real_t deg)
|
||||
{
|
||||
return deg * Deg2RadConst;
|
||||
return deg * _deg2RadConst;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -240,7 +240,7 @@ namespace Godot
|
|||
return Pow(s * 2.0f, -curve) * 0.5f;
|
||||
}
|
||||
|
||||
return (1.0f - Pow(1.0f - (s - 0.5f) * 2.0f, -curve)) * 0.5f + 0.5f;
|
||||
return ((1.0f - Pow(1.0f - ((s - 0.5f) * 2.0f), -curve)) * 0.5f) + 0.5f;
|
||||
}
|
||||
|
||||
return 0f;
|
||||
|
@ -347,7 +347,7 @@ namespace Godot
|
|||
/// <returns>The resulting value of the interpolation.</returns>
|
||||
public static real_t Lerp(real_t from, real_t to, real_t weight)
|
||||
{
|
||||
return from + (to - from) * weight;
|
||||
return from + ((to - from) * weight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -364,7 +364,7 @@ namespace Godot
|
|||
{
|
||||
real_t difference = (to - from) % Mathf.Tau;
|
||||
real_t distance = ((2 * difference) % Mathf.Tau) - difference;
|
||||
return from + distance * weight;
|
||||
return from + (distance * weight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -434,7 +434,10 @@ namespace Godot
|
|||
/// <returns>The value after moving.</returns>
|
||||
public static real_t MoveToward(real_t from, real_t to, real_t delta)
|
||||
{
|
||||
return Abs(to - from) <= delta ? to : from + Sign(to - from) * delta;
|
||||
if (Abs(to - from) <= delta)
|
||||
return to;
|
||||
|
||||
return from + (Sign(to - from) * delta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -518,7 +521,7 @@ namespace Godot
|
|||
/// <returns>The same angle expressed in degrees.</returns>
|
||||
public static real_t Rad2Deg(real_t rad)
|
||||
{
|
||||
return rad * Rad2DegConst;
|
||||
return rad * _rad2DegConst;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -594,7 +597,7 @@ namespace Godot
|
|||
return from;
|
||||
}
|
||||
real_t x = Clamp((weight - from) / (to - from), (real_t)0.0, (real_t)1.0);
|
||||
return x * x * (3 - 2 * x);
|
||||
return x * x * (3 - (2 * x));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -618,7 +621,8 @@ namespace Godot
|
|||
/// <returns>The position of the first non-zero digit.</returns>
|
||||
public static int StepDecimals(real_t step)
|
||||
{
|
||||
double[] sd = new double[] {
|
||||
double[] sd = new double[]
|
||||
{
|
||||
0.9999,
|
||||
0.09999,
|
||||
0.009999,
|
||||
|
@ -629,7 +633,7 @@ namespace Godot
|
|||
0.00000009999,
|
||||
0.000000009999,
|
||||
};
|
||||
double abs = Mathf.Abs(step);
|
||||
double abs = Abs(step);
|
||||
double decs = abs - (int)abs; // Strip away integer part
|
||||
for (int i = 0; i < sd.Length; i++)
|
||||
{
|
||||
|
@ -652,7 +656,7 @@ namespace Godot
|
|||
{
|
||||
if (step != 0f)
|
||||
{
|
||||
return Floor(s / step + 0.5f) * step;
|
||||
return Floor((s / step) + 0.5f) * step;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -691,7 +695,10 @@ namespace Godot
|
|||
public static int Wrap(int value, int min, int max)
|
||||
{
|
||||
int range = max - min;
|
||||
return range == 0 ? min : min + ((value - min) % range + range) % range;
|
||||
if (range == 0)
|
||||
return min;
|
||||
|
||||
return min + ((((value - min) % range) + range) % range);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -707,7 +714,10 @@ namespace Godot
|
|||
public static real_t Wrap(real_t value, real_t min, real_t max)
|
||||
{
|
||||
real_t range = max - min;
|
||||
return IsZeroApprox(range) ? min : min + ((value - min) % range + range) % range;
|
||||
if (IsZeroApprox(range))
|
||||
return min;
|
||||
|
||||
return min + ((((value - min) % range) + range) % range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,16 +41,16 @@ namespace Godot
|
|||
/// </example>
|
||||
public sealed partial class NodePath : IDisposable
|
||||
{
|
||||
private bool disposed = false;
|
||||
private bool _disposed = false;
|
||||
|
||||
internal IntPtr ptr;
|
||||
private IntPtr ptr;
|
||||
|
||||
internal static IntPtr GetPtr(NodePath instance)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new NullReferenceException($"The instance of type {nameof(NodePath)} is null.");
|
||||
|
||||
if (instance.disposed)
|
||||
if (instance._disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
|
@ -72,7 +72,7 @@ namespace Godot
|
|||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (ptr != IntPtr.Zero)
|
||||
|
@ -81,7 +81,7 @@ namespace Godot
|
|||
ptr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
internal NodePath(IntPtr ptr)
|
||||
|
@ -102,7 +102,6 @@ namespace Godot
|
|||
/// </summary>
|
||||
public NodePath() : this(string.Empty) { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a <see cref="NodePath"/> from a string <paramref name="path"/>,
|
||||
/// e.g.: <c>"Path2D/PathFollow2D/Sprite2D:texture:size"</c>.
|
||||
|
@ -134,7 +133,7 @@ namespace Godot
|
|||
/// <param name="path"></param>
|
||||
public NodePath(string path)
|
||||
{
|
||||
this.ptr = godot_icall_NodePath_Ctor(path);
|
||||
ptr = godot_icall_NodePath_Ctor(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -272,36 +271,36 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_NodePath_Ctor(string path);
|
||||
private static extern IntPtr godot_icall_NodePath_Ctor(string path);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_NodePath_Dtor(IntPtr ptr);
|
||||
private static extern void godot_icall_NodePath_Dtor(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_NodePath_operator_String(IntPtr ptr);
|
||||
private static extern string godot_icall_NodePath_operator_String(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_NodePath_get_as_property_path(IntPtr ptr);
|
||||
private static extern IntPtr godot_icall_NodePath_get_as_property_path(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_NodePath_get_concatenated_subnames(IntPtr ptr);
|
||||
private static extern string godot_icall_NodePath_get_concatenated_subnames(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_NodePath_get_name(IntPtr ptr, int arg1);
|
||||
private static extern string godot_icall_NodePath_get_name(IntPtr ptr, int arg1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_NodePath_get_name_count(IntPtr ptr);
|
||||
private static extern int godot_icall_NodePath_get_name_count(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_NodePath_get_subname(IntPtr ptr, int arg1);
|
||||
private static extern string godot_icall_NodePath_get_subname(IntPtr ptr, int arg1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_NodePath_get_subname_count(IntPtr ptr);
|
||||
private static extern int godot_icall_NodePath_get_subname_count(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_NodePath_is_absolute(IntPtr ptr);
|
||||
private static extern bool godot_icall_NodePath_is_absolute(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_NodePath_is_empty(IntPtr ptr);
|
||||
private static extern bool godot_icall_NodePath_is_empty(IntPtr ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Godot
|
|||
{
|
||||
public partial class Object : IDisposable
|
||||
{
|
||||
private bool disposed = false;
|
||||
private bool _disposed = false;
|
||||
|
||||
private const string nativeName = "Object";
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace Godot
|
|||
if (instance == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
if (instance.disposed)
|
||||
if (instance._disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
|
@ -64,7 +64,7 @@ namespace Godot
|
|||
/// </summary>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (ptr != IntPtr.Zero)
|
||||
|
@ -79,10 +79,10 @@ namespace Godot
|
|||
godot_icall_Object_Disposed(this, ptr);
|
||||
}
|
||||
|
||||
this.ptr = IntPtr.Zero;
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -132,19 +132,19 @@ namespace Godot
|
|||
public dynamic DynamicObject => new DynamicGodotObject(this);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Object_Ctor(Object obj);
|
||||
internal static extern IntPtr godot_icall_Object_Ctor(Object obj);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Object_Disposed(Object obj, IntPtr ptr);
|
||||
internal static extern void godot_icall_Object_Disposed(Object obj, IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Reference_Disposed(Object obj, IntPtr ptr, bool isFinalizer);
|
||||
internal static extern void godot_icall_Reference_Disposed(Object obj, IntPtr ptr, bool isFinalizer);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_Object_ToString(IntPtr ptr);
|
||||
internal static extern string godot_icall_Object_ToString(IntPtr ptr);
|
||||
|
||||
// Used by the generated API
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Object_ClassDB_get_method(string type, string method);
|
||||
internal static extern IntPtr godot_icall_Object_ClassDB_get_method(string type, string method);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,9 +156,9 @@ namespace Godot
|
|||
return null;
|
||||
}
|
||||
|
||||
Vector3 result = b._normal.Cross(c._normal) * D +
|
||||
c._normal.Cross(_normal) * b.D +
|
||||
_normal.Cross(b._normal) * c.D;
|
||||
Vector3 result = (b._normal.Cross(c._normal) * D) +
|
||||
(c._normal.Cross(_normal) * b.D) +
|
||||
(_normal.Cross(b._normal) * c.D);
|
||||
|
||||
return result / denom;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ namespace Godot
|
|||
/// <returns>The projected point.</returns>
|
||||
public Vector3 Project(Vector3 point)
|
||||
{
|
||||
return point - _normal * DistanceTo(point);
|
||||
return point - (_normal * DistanceTo(point));
|
||||
}
|
||||
|
||||
// Constants
|
||||
|
@ -292,7 +292,7 @@ namespace Godot
|
|||
public Plane(real_t a, real_t b, real_t c, real_t d)
|
||||
{
|
||||
_normal = new Vector3(a, b, c);
|
||||
this.D = d;
|
||||
D = d;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -303,8 +303,8 @@ namespace Godot
|
|||
/// <param name="d">The plane's distance from the origin. This value is typically non-negative.</param>
|
||||
public Plane(Vector3 normal, real_t d)
|
||||
{
|
||||
this._normal = normal;
|
||||
this.D = d;
|
||||
_normal = normal;
|
||||
D = d;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Godot
|
|||
/// It is similar to <see cref="Basis"/>, which implements matrix
|
||||
/// representation of rotations, and can be parametrized using both
|
||||
/// an axis-angle pair or Euler angles. Basis stores rotation, scale,
|
||||
/// and shearing, while Quat only stores rotation
|
||||
/// and shearing, while Quat only stores rotation.
|
||||
///
|
||||
/// Due to its compactness and the way it is stored in memory, certain
|
||||
/// operations (obtaining axis-angle and performing SLERP, in particular)
|
||||
|
@ -147,10 +147,9 @@ namespace Godot
|
|||
/// <returns>The interpolated quaternion.</returns>
|
||||
public Quat CubicSlerp(Quat b, Quat preA, Quat postB, real_t weight)
|
||||
{
|
||||
real_t t = weight;
|
||||
real_t t2 = (1.0f - t) * t * 2f;
|
||||
Quat sp = Slerp(b, t);
|
||||
Quat sq = preA.Slerpni(postB, t);
|
||||
real_t t2 = (1.0f - weight) * weight * 2f;
|
||||
Quat sp = Slerp(b, weight);
|
||||
Quat sq = preA.Slerpni(postB, weight);
|
||||
return sp.Slerpni(sq, t2);
|
||||
}
|
||||
|
||||
|
@ -161,7 +160,7 @@ namespace Godot
|
|||
/// <returns>The dot product.</returns>
|
||||
public real_t Dot(Quat b)
|
||||
{
|
||||
return x * b.x + y * b.y + z * b.z + w * b.w;
|
||||
return (x * b.x) + (y * b.y) + (z * b.z) + (w * b.w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -308,10 +307,10 @@ namespace Godot
|
|||
// Calculate final values.
|
||||
return new Quat
|
||||
(
|
||||
scale0 * x + scale1 * to1.x,
|
||||
scale0 * y + scale1 * to1.y,
|
||||
scale0 * z + scale1 * to1.z,
|
||||
scale0 * w + scale1 * to1.w
|
||||
(scale0 * x) + (scale1 * to1.x),
|
||||
(scale0 * y) + (scale1 * to1.y),
|
||||
(scale0 * z) + (scale1 * to1.z),
|
||||
(scale0 * w) + (scale1 * to1.w)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -339,10 +338,10 @@ namespace Godot
|
|||
|
||||
return new Quat
|
||||
(
|
||||
invFactor * x + newFactor * to.x,
|
||||
invFactor * y + newFactor * to.y,
|
||||
invFactor * z + newFactor * to.z,
|
||||
invFactor * w + newFactor * to.w
|
||||
(invFactor * x) + (newFactor * to.x),
|
||||
(invFactor * y) + (newFactor * to.y),
|
||||
(invFactor * z) + (newFactor * to.z),
|
||||
(invFactor * w) + (newFactor * to.w)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -361,7 +360,7 @@ namespace Godot
|
|||
#endif
|
||||
var u = new Vector3(x, y, z);
|
||||
Vector3 uv = u.Cross(v);
|
||||
return v + ((uv * w) + u.Cross(uv)) * 2;
|
||||
return v + (((uv * w) + u.Cross(uv)) * 2);
|
||||
}
|
||||
|
||||
// Constants
|
||||
|
@ -416,25 +415,25 @@ namespace Godot
|
|||
/// <param name="eulerYXZ">Euler angles that the quaternion will be rotated by.</param>
|
||||
public Quat(Vector3 eulerYXZ)
|
||||
{
|
||||
real_t half_a1 = eulerYXZ.y * 0.5f;
|
||||
real_t half_a2 = eulerYXZ.x * 0.5f;
|
||||
real_t half_a3 = eulerYXZ.z * 0.5f;
|
||||
real_t halfA1 = eulerYXZ.y * 0.5f;
|
||||
real_t halfA2 = eulerYXZ.x * 0.5f;
|
||||
real_t halfA3 = eulerYXZ.z * 0.5f;
|
||||
|
||||
// R = Y(a1).X(a2).Z(a3) convention for Euler angles.
|
||||
// Conversion to quaternion as listed in https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf (page A-6)
|
||||
// a3 is the angle of the first rotation, following the notation in this reference.
|
||||
|
||||
real_t cos_a1 = Mathf.Cos(half_a1);
|
||||
real_t sin_a1 = Mathf.Sin(half_a1);
|
||||
real_t cos_a2 = Mathf.Cos(half_a2);
|
||||
real_t sin_a2 = Mathf.Sin(half_a2);
|
||||
real_t cos_a3 = Mathf.Cos(half_a3);
|
||||
real_t sin_a3 = Mathf.Sin(half_a3);
|
||||
real_t cosA1 = Mathf.Cos(halfA1);
|
||||
real_t sinA1 = Mathf.Sin(halfA1);
|
||||
real_t cosA2 = Mathf.Cos(halfA2);
|
||||
real_t sinA2 = Mathf.Sin(halfA2);
|
||||
real_t cosA3 = Mathf.Cos(halfA3);
|
||||
real_t sinA3 = Mathf.Sin(halfA3);
|
||||
|
||||
x = sin_a1 * cos_a2 * sin_a3 + cos_a1 * sin_a2 * cos_a3;
|
||||
y = sin_a1 * cos_a2 * cos_a3 - cos_a1 * sin_a2 * sin_a3;
|
||||
z = cos_a1 * cos_a2 * sin_a3 - sin_a1 * sin_a2 * cos_a3;
|
||||
w = sin_a1 * sin_a2 * sin_a3 + cos_a1 * cos_a2 * cos_a3;
|
||||
x = (sinA1 * cosA2 * sinA3) + (cosA1 * sinA2 * cosA3);
|
||||
y = (sinA1 * cosA2 * cosA3) - (cosA1 * sinA2 * sinA3);
|
||||
z = (cosA1 * cosA2 * sinA3) - (sinA1 * sinA2 * cosA3);
|
||||
w = (sinA1 * sinA2 * sinA3) + (cosA1 * cosA2 * cosA3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -478,10 +477,10 @@ namespace Godot
|
|||
{
|
||||
return new Quat
|
||||
(
|
||||
left.w * right.x + left.x * right.w + left.y * right.z - left.z * right.y,
|
||||
left.w * right.y + left.y * right.w + left.z * right.x - left.x * right.z,
|
||||
left.w * right.z + left.z * right.w + left.x * right.y - left.y * right.x,
|
||||
left.w * right.w - left.x * right.x - left.y * right.y - left.z * right.z
|
||||
(left.w * right.x) + (left.x * right.w) + (left.y * right.z) - (left.z * right.y),
|
||||
(left.w * right.y) + (left.y * right.w) + (left.z * right.x) - (left.x * right.z),
|
||||
(left.w * right.z) + (left.z * right.w) + (left.x * right.y) - (left.y * right.x),
|
||||
(left.w * right.w) - (left.x * right.x) - (left.y * right.y) - (left.z * right.z)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -504,10 +503,10 @@ namespace Godot
|
|||
{
|
||||
return new Quat
|
||||
(
|
||||
left.w * right.x + left.y * right.z - left.z * right.y,
|
||||
left.w * right.y + left.z * right.x - left.x * right.z,
|
||||
left.w * right.z + left.x * right.y - left.y * right.x,
|
||||
-left.x * right.x - left.y * right.y - left.z * right.z
|
||||
(left.w * right.x) + (left.y * right.z) - (left.z * right.y),
|
||||
(left.w * right.y) + (left.z * right.x) - (left.x * right.z),
|
||||
(left.w * right.z) + (left.x * right.y) - (left.y * right.x),
|
||||
-(left.x * right.x) - (left.y * right.y) - (left.z * right.z)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -515,10 +514,10 @@ namespace Godot
|
|||
{
|
||||
return new Quat
|
||||
(
|
||||
right.w * left.x + right.y * left.z - right.z * left.y,
|
||||
right.w * left.y + right.z * left.x - right.x * left.z,
|
||||
right.w * left.z + right.x * left.y - right.y * left.x,
|
||||
-right.x * left.x - right.y * left.y - right.z * left.z
|
||||
(right.w * left.x) + (right.y * left.z) - (right.z * left.y),
|
||||
(right.w * left.y) + (right.z * left.x) - (right.x * left.z),
|
||||
(right.w * left.z) + (right.x * left.y) - (right.y * left.x),
|
||||
-(right.x * left.x) - (right.y * left.y) - (right.z * left.z)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -598,7 +597,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this quaternion.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("({0}, {1}, {2}, {3})", x.ToString(), y.ToString(), z.ToString(), w.ToString());
|
||||
return $"({x}, {y}, {z}, {w})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -607,7 +606,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this quaternion.</returns>
|
||||
public string ToString(string format)
|
||||
{
|
||||
return String.Format("({0}, {1}, {2}, {3})", x.ToString(format), y.ToString(format), z.ToString(format), w.ToString(format));
|
||||
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)}, {w.ToString(format)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Godot
|
|||
/// </summary>
|
||||
public sealed partial class RID : IDisposable
|
||||
{
|
||||
private bool disposed = false;
|
||||
private bool _disposed = false;
|
||||
|
||||
internal IntPtr ptr;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Godot
|
|||
if (instance == null)
|
||||
throw new NullReferenceException($"The instance of type {nameof(RID)} is null.");
|
||||
|
||||
if (instance.disposed)
|
||||
if (instance._disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
|
@ -42,7 +42,7 @@ namespace Godot
|
|||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposed)
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (ptr != IntPtr.Zero)
|
||||
|
@ -51,7 +51,7 @@ namespace Godot
|
|||
ptr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
internal RID(IntPtr ptr)
|
||||
|
@ -96,12 +96,12 @@ namespace Godot
|
|||
public override string ToString() => "[RID]";
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_RID_Ctor(IntPtr from);
|
||||
internal static extern IntPtr godot_icall_RID_Ctor(IntPtr from);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_RID_Dtor(IntPtr ptr);
|
||||
internal static extern void godot_icall_RID_Dtor(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_RID_get_id(IntPtr ptr);
|
||||
internal static extern int godot_icall_RID_get_id(IntPtr ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Godot
|
|||
/// <returns>The clipped <see cref="Rect2"/>.</returns>
|
||||
public Rect2 Clip(Rect2 b)
|
||||
{
|
||||
var newRect = b;
|
||||
Rect2 newRect = b;
|
||||
|
||||
if (!Intersects(newRect))
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ namespace Godot
|
|||
/// <returns>The expanded <see cref="Rect2"/>.</returns>
|
||||
public Rect2 Expand(Vector2 to)
|
||||
{
|
||||
var expanded = this;
|
||||
Rect2 expanded = this;
|
||||
|
||||
Vector2 begin = expanded._position;
|
||||
Vector2 end = expanded._position + expanded._size;
|
||||
|
@ -171,7 +171,7 @@ namespace Godot
|
|||
/// <returns>The grown <see cref="Rect2"/>.</returns>
|
||||
public Rect2 Grow(real_t by)
|
||||
{
|
||||
var g = this;
|
||||
Rect2 g = this;
|
||||
|
||||
g._position.x -= by;
|
||||
g._position.y -= by;
|
||||
|
@ -194,7 +194,7 @@ namespace Godot
|
|||
/// <returns>The grown <see cref="Rect2"/>.</returns>
|
||||
public Rect2 GrowIndividual(real_t left, real_t top, real_t right, real_t bottom)
|
||||
{
|
||||
var g = this;
|
||||
Rect2 g = this;
|
||||
|
||||
g._position.x -= left;
|
||||
g._position.y -= top;
|
||||
|
@ -215,7 +215,7 @@ namespace Godot
|
|||
/// <returns>The grown <see cref="Rect2"/>.</returns>
|
||||
public Rect2 GrowMargin(Margin margin, real_t by)
|
||||
{
|
||||
var g = this;
|
||||
Rect2 g = this;
|
||||
|
||||
g = g.GrowIndividual(Margin.Left == margin ? by : 0,
|
||||
Margin.Top == margin ? by : 0,
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace Godot
|
|||
{
|
||||
public class SignalAwaiter : IAwaiter<object[]>, IAwaitable<object[]>
|
||||
{
|
||||
private bool completed;
|
||||
private object[] result;
|
||||
private Action action;
|
||||
private bool _completed;
|
||||
private object[] _result;
|
||||
private Action _action;
|
||||
|
||||
public SignalAwaiter(Object source, string signal, Object target)
|
||||
{
|
||||
|
@ -15,24 +15,24 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static Error godot_icall_SignalAwaiter_connect(IntPtr source, string signal, IntPtr target, SignalAwaiter awaiter);
|
||||
internal static extern Error godot_icall_SignalAwaiter_connect(IntPtr source, string signal, IntPtr target, SignalAwaiter awaiter);
|
||||
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
return completed;
|
||||
return _completed;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCompleted(Action action)
|
||||
{
|
||||
this.action = action;
|
||||
this._action = action;
|
||||
}
|
||||
|
||||
public object[] GetResult()
|
||||
{
|
||||
return result;
|
||||
return _result;
|
||||
}
|
||||
|
||||
public IAwaiter<object[]> GetAwaiter()
|
||||
|
@ -42,19 +42,15 @@ namespace Godot
|
|||
|
||||
internal void SignalCallback(object[] args)
|
||||
{
|
||||
completed = true;
|
||||
result = args;
|
||||
|
||||
if (action != null)
|
||||
{
|
||||
action();
|
||||
}
|
||||
_completed = true;
|
||||
_result = args;
|
||||
_action?.Invoke();
|
||||
}
|
||||
|
||||
internal void FailureCallback()
|
||||
{
|
||||
action = null;
|
||||
completed = true;
|
||||
_action = null;
|
||||
_completed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace Godot
|
|||
/// <returns>The bigrams of this string.</returns>
|
||||
public static string[] Bigrams(this string instance)
|
||||
{
|
||||
var b = new string[instance.Length - 1];
|
||||
string[] b = new string[instance.Length - 1];
|
||||
|
||||
for (int i = 0; i < b.Length; i++)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace Godot
|
|||
public static string Capitalize(this string instance)
|
||||
{
|
||||
string aux = instance.Replace("_", " ").ToLower();
|
||||
var cap = string.Empty;
|
||||
string cap = string.Empty;
|
||||
|
||||
for (int i = 0; i < aux.GetSliceCount(" "); i++)
|
||||
{
|
||||
|
@ -511,20 +511,20 @@ namespace Godot
|
|||
int basepos = instance.Find("://");
|
||||
|
||||
string rs;
|
||||
var @base = string.Empty;
|
||||
string directory = string.Empty;
|
||||
|
||||
if (basepos != -1)
|
||||
{
|
||||
var end = basepos + 3;
|
||||
int end = basepos + 3;
|
||||
rs = instance.Substring(end);
|
||||
@base = instance.Substring(0, end);
|
||||
directory = instance.Substring(0, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (instance.BeginsWith("/"))
|
||||
{
|
||||
rs = instance.Substring(1);
|
||||
@base = "/";
|
||||
directory = "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -535,9 +535,9 @@ namespace Godot
|
|||
int sep = Mathf.Max(rs.FindLast("/"), rs.FindLast("\\"));
|
||||
|
||||
if (sep == -1)
|
||||
return @base;
|
||||
return directory;
|
||||
|
||||
return @base + rs.Substr(0, sep);
|
||||
return directory + rs.Substr(0, sep);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -611,7 +611,7 @@ namespace Godot
|
|||
/// <returns>The hexadecimal representation of this byte.</returns>
|
||||
internal static string HexEncode(this byte b)
|
||||
{
|
||||
var ret = string.Empty;
|
||||
string ret = string.Empty;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
@ -641,7 +641,7 @@ namespace Godot
|
|||
/// <returns>The hexadecimal representation of this byte array.</returns>
|
||||
public static string HexEncode(this byte[] bytes)
|
||||
{
|
||||
var ret = string.Empty;
|
||||
string ret = string.Empty;
|
||||
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
|
@ -831,10 +831,10 @@ namespace Godot
|
|||
return false; // Don't start with number plz
|
||||
}
|
||||
|
||||
bool validChar = instance[i] >= '0' &&
|
||||
instance[i] <= '9' || instance[i] >= 'a' &&
|
||||
instance[i] <= 'z' || instance[i] >= 'A' &&
|
||||
instance[i] <= 'Z' || instance[i] == '_';
|
||||
bool validChar = instance[i] == '_' ||
|
||||
(instance[i] >= 'a' && instance[i] <= 'z') ||
|
||||
(instance[i] >= 'A' && instance[i] <= 'Z') ||
|
||||
(instance[i] >= '0' && instance[i] <= '9');
|
||||
|
||||
if (!validChar)
|
||||
return false;
|
||||
|
@ -1036,7 +1036,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static byte[] godot_icall_String_md5_buffer(string str);
|
||||
internal static extern byte[] godot_icall_String_md5_buffer(string str);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the MD5 hash of the string as a string.
|
||||
|
@ -1050,7 +1050,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_String_md5_text(string str);
|
||||
internal static extern string godot_icall_String_md5_text(string str);
|
||||
|
||||
/// <summary>
|
||||
/// Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
|
||||
|
@ -1228,7 +1228,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_String_rfind(string str, string what, int from);
|
||||
internal static extern int godot_icall_String_rfind(string str, string what, int from);
|
||||
|
||||
/// <summary>
|
||||
/// Perform a search for a substring, but start from the end of the string instead of the beginning.
|
||||
|
@ -1245,7 +1245,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_String_rfindn(string str, string what, int from);
|
||||
internal static extern int godot_icall_String_rfindn(string str, string what, int from);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the right side of the string from a given position.
|
||||
|
@ -1305,7 +1305,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static byte[] godot_icall_String_sha256_buffer(string str);
|
||||
internal static extern byte[] godot_icall_String_sha256_buffer(string str);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the SHA-256 hash of the string as a string.
|
||||
|
@ -1319,7 +1319,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_String_sha256_text(string str);
|
||||
internal static extern string godot_icall_String_sha256_text(string str);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the similarity index of the text compared to this string.
|
||||
|
@ -1374,7 +1374,7 @@ namespace Godot
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static string godot_icall_String_simplify_path(string str);
|
||||
internal static extern string godot_icall_String_simplify_path(string str);
|
||||
|
||||
/// <summary>
|
||||
/// Split the string by a divisor string, return an array of the substrings.
|
||||
|
@ -1425,7 +1425,8 @@ namespace Godot
|
|||
return ret.ToArray();
|
||||
}
|
||||
|
||||
private static readonly char[] _nonPrintable = {
|
||||
private static readonly char[] _nonPrintable =
|
||||
{
|
||||
(char)00, (char)01, (char)02, (char)03, (char)04, (char)05,
|
||||
(char)06, (char)07, (char)08, (char)09, (char)10, (char)11,
|
||||
(char)12, (char)13, (char)14, (char)15, (char)16, (char)17,
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace Godot
|
|||
/// <returns>The resulting transform.</returns>
|
||||
public Transform LookingAt(Vector3 target, Vector3 up)
|
||||
{
|
||||
var t = this;
|
||||
Transform t = this;
|
||||
t.SetLookAt(origin, target, up);
|
||||
return t;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ namespace Godot
|
|||
return new Transform(basis.Scaled(scale), origin * scale);
|
||||
}
|
||||
|
||||
public void SetLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||
private void SetLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||
{
|
||||
// Make rotation matrix
|
||||
// Z vector
|
||||
|
@ -278,9 +278,9 @@ namespace Godot
|
|||
|
||||
return new Vector3
|
||||
(
|
||||
basis.Row0[0] * vInv.x + basis.Row1[0] * vInv.y + basis.Row2[0] * vInv.z,
|
||||
basis.Row0[1] * vInv.x + basis.Row1[1] * vInv.y + basis.Row2[1] * vInv.z,
|
||||
basis.Row0[2] * vInv.x + basis.Row1[2] * vInv.y + basis.Row2[2] * vInv.z
|
||||
(basis.Row0[0] * vInv.x) + (basis.Row1[0] * vInv.y) + (basis.Row2[0] * vInv.z),
|
||||
(basis.Row0[1] * vInv.x) + (basis.Row1[1] * vInv.y) + (basis.Row2[1] * vInv.z),
|
||||
(basis.Row0[2] * vInv.x) + (basis.Row1[2] * vInv.y) + (basis.Row2[2] * vInv.z)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -327,14 +327,14 @@ namespace Godot
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a transformation matrix from the given <paramref name="quat"/>
|
||||
/// Constructs a transformation matrix from the given <paramref name="quaternion"/>
|
||||
/// and <paramref name="origin"/> vector.
|
||||
/// </summary>
|
||||
/// <param name="quat">The <see cref="Quat"/> to create the basis from.</param>
|
||||
/// <param name="quaternion">The <see cref="Quat"/> to create the basis from.</param>
|
||||
/// <param name="origin">The origin vector, or column index 3.</param>
|
||||
public Transform(Quat quat, Vector3 origin)
|
||||
public Transform(Quat quaternion, Vector3 origin)
|
||||
{
|
||||
basis = new Basis(quat);
|
||||
basis = new Basis(quaternion);
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Godot
|
|||
if (det == 0)
|
||||
throw new InvalidOperationException("Matrix determinant is zero and cannot be inverted.");
|
||||
|
||||
var inv = this;
|
||||
Transform2D inv = this;
|
||||
|
||||
real_t temp = inv[0, 0];
|
||||
inv[0, 0] = inv[1, 1];
|
||||
|
@ -176,7 +176,7 @@ namespace Godot
|
|||
/// <returns>The determinant of the basis matrix.</returns>
|
||||
private real_t BasisDeterminant()
|
||||
{
|
||||
return x.x * y.y - x.y * y.x;
|
||||
return (x.x * y.y) - (x.y * y.x);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -238,8 +238,8 @@ namespace Godot
|
|||
else
|
||||
{
|
||||
real_t angle = weight * Mathf.Acos(dot);
|
||||
Vector2 v3 = (v2 - v1 * dot).Normalized();
|
||||
v = v1 * Mathf.Cos(angle) + v3 * Mathf.Sin(angle);
|
||||
Vector2 v3 = (v2 - (v1 * dot)).Normalized();
|
||||
v = (v1 * Mathf.Cos(angle)) + (v3 * Mathf.Sin(angle));
|
||||
}
|
||||
|
||||
// Extract parameters
|
||||
|
@ -263,7 +263,7 @@ namespace Godot
|
|||
/// <returns>The inverse matrix.</returns>
|
||||
public Transform2D Inverse()
|
||||
{
|
||||
var inv = this;
|
||||
Transform2D inv = this;
|
||||
|
||||
// Swap
|
||||
real_t temp = inv.x.y;
|
||||
|
@ -282,13 +282,13 @@ namespace Godot
|
|||
/// <returns>The orthonormalized transform.</returns>
|
||||
public Transform2D Orthonormalized()
|
||||
{
|
||||
var on = this;
|
||||
Transform2D on = this;
|
||||
|
||||
Vector2 onX = on.x;
|
||||
Vector2 onY = on.y;
|
||||
|
||||
onX.Normalize();
|
||||
onY = onY - onX * onX.Dot(onY);
|
||||
onY = onY - (onX * onX.Dot(onY));
|
||||
onY.Normalize();
|
||||
|
||||
on.x = onX;
|
||||
|
@ -314,7 +314,7 @@ namespace Godot
|
|||
/// <returns>The scaled transformation matrix.</returns>
|
||||
public Transform2D Scaled(Vector2 scale)
|
||||
{
|
||||
var copy = this;
|
||||
Transform2D copy = this;
|
||||
copy.x *= scale;
|
||||
copy.y *= scale;
|
||||
copy.origin *= scale;
|
||||
|
@ -331,12 +331,12 @@ namespace Godot
|
|||
|
||||
private real_t Tdotx(Vector2 with)
|
||||
{
|
||||
return this[0, 0] * with[0] + this[1, 0] * with[1];
|
||||
return (this[0, 0] * with[0]) + (this[1, 0] * with[1]);
|
||||
}
|
||||
|
||||
private real_t Tdoty(Vector2 with)
|
||||
{
|
||||
return this[0, 1] * with[0] + this[1, 1] * with[1];
|
||||
return (this[0, 1] * with[0]) + (this[1, 1] * with[1]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -350,7 +350,7 @@ namespace Godot
|
|||
/// <returns>The translated matrix.</returns>
|
||||
public Transform2D Translated(Vector2 offset)
|
||||
{
|
||||
var copy = this;
|
||||
Transform2D copy = this;
|
||||
copy.origin += copy.BasisXform(offset);
|
||||
return copy;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ namespace Godot
|
|||
/// <summary>
|
||||
/// Returns a Vector2 transformed (multiplied) by the inverse transformation matrix.
|
||||
/// </summary>
|
||||
/// <param name="vector">A vector to inversely transform.</param>
|
||||
/// <param name="vector">A Vector2 to inversely transform.</param>
|
||||
/// <param name="transform">The transformation to apply.</param>
|
||||
/// <returns>The inversely transformed Vector2.</returns>
|
||||
public static Vector2 operator *(Vector2 vector, Transform2D transform)
|
||||
|
@ -522,7 +522,7 @@ namespace Godot
|
|||
/// Returns a copy of the given Vector2[] transformed (multiplied) by transformation matrix.
|
||||
/// </summary>
|
||||
/// <param name="transform">The transformation to apply.</param>
|
||||
/// <param name="array">a Vector2[] to transform.</param>
|
||||
/// <param name="array">A Vector2[] to transform.</param>
|
||||
/// <returns>The transformed copy of the Vector2[].</returns>
|
||||
public static Vector2[] operator *(Transform2D transform, Vector2[] array)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Godot
|
|||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public real_t x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
|
@ -191,7 +192,7 @@ namespace Godot
|
|||
/// <returns>The cross product value.</returns>
|
||||
public real_t Cross(Vector2 b)
|
||||
{
|
||||
return x * b.y - y * b.x;
|
||||
return (x * b.y) - (y * b.x);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -214,10 +215,12 @@ namespace Godot
|
|||
real_t t2 = t * t;
|
||||
real_t t3 = t2 * t;
|
||||
|
||||
return 0.5f * (p1 * 2.0f +
|
||||
(-p0 + p2) * t +
|
||||
(2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
|
||||
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
|
||||
return 0.5f * (
|
||||
(p1 * 2.0f) +
|
||||
((-p0 + p2) * t) +
|
||||
(((2.0f * p0) - (5.0f * p1) + (4 * p2) - p3) * t2) +
|
||||
((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -259,7 +262,7 @@ namespace Godot
|
|||
/// <returns>The dot product of the two vectors.</returns>
|
||||
public real_t Dot(Vector2 with)
|
||||
{
|
||||
return x * with.x + y * with.y;
|
||||
return (x * with.x) + (y * with.y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -296,7 +299,7 @@ namespace Godot
|
|||
/// <returns>The length of this vector.</returns>
|
||||
public real_t Length()
|
||||
{
|
||||
return Mathf.Sqrt(x * x + y * y);
|
||||
return Mathf.Sqrt((x * x) + (y * y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -307,7 +310,7 @@ namespace Godot
|
|||
/// <returns>The squared length of this vector.</returns>
|
||||
public real_t LengthSquared()
|
||||
{
|
||||
return x * x + y * y;
|
||||
return (x * x) + (y * y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -372,10 +375,13 @@ namespace Godot
|
|||
/// <returns>The resulting vector.</returns>
|
||||
public Vector2 MoveToward(Vector2 to, real_t delta)
|
||||
{
|
||||
var v = this;
|
||||
var vd = to - v;
|
||||
var len = vd.Length();
|
||||
return len <= delta || len < Mathf.Epsilon ? to : v + vd / len * delta;
|
||||
Vector2 v = this;
|
||||
Vector2 vd = to - v;
|
||||
real_t len = vd.Length();
|
||||
if (len <= delta || len < Mathf.Epsilon)
|
||||
return to;
|
||||
|
||||
return v + (vd / len * delta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -384,7 +390,7 @@ namespace Godot
|
|||
/// <returns>A normalized version of the vector.</returns>
|
||||
public Vector2 Normalized()
|
||||
{
|
||||
var v = this;
|
||||
Vector2 v = this;
|
||||
v.Normalize();
|
||||
return v;
|
||||
}
|
||||
|
@ -454,7 +460,7 @@ namespace Godot
|
|||
throw new ArgumentException("Argument is not normalized", nameof(normal));
|
||||
}
|
||||
#endif
|
||||
return 2 * Dot(normal) * normal - this;
|
||||
return (2 * Dot(normal) * normal) - this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -464,8 +470,11 @@ namespace Godot
|
|||
/// <returns>The rotated vector.</returns>
|
||||
public Vector2 Rotated(real_t phi)
|
||||
{
|
||||
real_t rads = Angle() + phi;
|
||||
return new Vector2(Mathf.Cos(rads), Mathf.Sin(rads)) * Length();
|
||||
real_t sine = Mathf.Sin(phi);
|
||||
real_t cosi = Mathf.Cos(phi);
|
||||
return new Vector2(
|
||||
x * cosi - y * sine,
|
||||
x * sine + y * cosi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -536,7 +545,7 @@ namespace Godot
|
|||
/// <returns>The slid vector.</returns>
|
||||
public Vector2 Slide(Vector2 normal)
|
||||
{
|
||||
return this - normal * Dot(normal);
|
||||
return this - (normal * Dot(normal));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -802,11 +811,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("({0}, {1})", new object[]
|
||||
{
|
||||
x.ToString(),
|
||||
y.ToString()
|
||||
});
|
||||
return $"({x}, {y})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -815,11 +820,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this vector.</returns>
|
||||
public string ToString(string format)
|
||||
{
|
||||
return String.Format("({0}, {1})", new object[]
|
||||
{
|
||||
x.ToString(format),
|
||||
y.ToString(format)
|
||||
});
|
||||
return $"({x.ToString(format)}, {y.ToString(format)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,12 @@ namespace Godot
|
|||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public real_t x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
public real_t y;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Z component. Also accessible by using the index position <c>[2]</c>.
|
||||
/// </summary>
|
||||
|
@ -158,9 +160,9 @@ namespace Godot
|
|||
{
|
||||
return new Vector3
|
||||
(
|
||||
y * b.z - z * b.y,
|
||||
z * b.x - x * b.z,
|
||||
x * b.y - y * b.x
|
||||
(y * b.z) - (z * b.y),
|
||||
(z * b.x) - (x * b.z),
|
||||
(x * b.y) - (y * b.x)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -185,10 +187,10 @@ namespace Godot
|
|||
real_t t3 = t2 * t;
|
||||
|
||||
return 0.5f * (
|
||||
p1 * 2.0f + (-p0 + p2) * t +
|
||||
(2.0f * p0 - 5.0f * p1 + 4f * p2 - p3) * t2 +
|
||||
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3
|
||||
);
|
||||
(p1 * 2.0f) + ((-p0 + p2) * t) +
|
||||
(((2.0f * p0) - (5.0f * p1) + (4f * p2) - p3) * t2) +
|
||||
((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -231,7 +233,7 @@ namespace Godot
|
|||
/// <returns>The dot product of the two vectors.</returns>
|
||||
public real_t Dot(Vector3 b)
|
||||
{
|
||||
return x * b.x + y * b.y + z * b.z;
|
||||
return (x * b.x) + (y * b.y) + (z * b.z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -352,10 +354,13 @@ namespace Godot
|
|||
/// <returns>The resulting vector.</returns>
|
||||
public Vector3 MoveToward(Vector3 to, real_t delta)
|
||||
{
|
||||
var v = this;
|
||||
var vd = to - v;
|
||||
var len = vd.Length();
|
||||
return len <= delta || len < Mathf.Epsilon ? to : v + vd / len * delta;
|
||||
Vector3 v = this;
|
||||
Vector3 vd = to - v;
|
||||
real_t len = vd.Length();
|
||||
if (len <= delta || len < Mathf.Epsilon)
|
||||
return to;
|
||||
|
||||
return v + (vd / len * delta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -364,7 +369,7 @@ namespace Godot
|
|||
/// <returns>A normalized version of the vector.</returns>
|
||||
public Vector3 Normalized()
|
||||
{
|
||||
var v = this;
|
||||
Vector3 v = this;
|
||||
v.Normalize();
|
||||
return v;
|
||||
}
|
||||
|
@ -440,7 +445,7 @@ namespace Godot
|
|||
throw new ArgumentException("Argument is not normalized", nameof(normal));
|
||||
}
|
||||
#endif
|
||||
return 2.0f * Dot(normal) * normal - this;
|
||||
return (2.0f * Dot(normal) * normal) - this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -550,7 +555,7 @@ namespace Godot
|
|||
/// <returns>The slid vector.</returns>
|
||||
public Vector3 Slide(Vector3 normal)
|
||||
{
|
||||
return this - normal * Dot(normal);
|
||||
return this - (normal * Dot(normal));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -872,12 +877,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("({0}, {1}, {2})", new object[]
|
||||
{
|
||||
x.ToString(),
|
||||
y.ToString(),
|
||||
z.ToString()
|
||||
});
|
||||
return $"({x}, {y}, {z})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -886,12 +886,7 @@ namespace Godot
|
|||
/// <returns>A string representation of this vector.</returns>
|
||||
public string ToString(string format)
|
||||
{
|
||||
return String.Format("({0}, {1}, {2})", new object[]
|
||||
{
|
||||
x.ToString(format),
|
||||
y.ToString(format),
|
||||
z.ToString(format)
|
||||
});
|
||||
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue