Cleanup 5

This commit is contained in:
W2.Wizard
2021-02-21 11:50:30 +01:00
parent ee76440477
commit 694b20148d
30 changed files with 93 additions and 103 deletions

View File

@@ -26,8 +26,7 @@ namespace FlaxEditor.Content
{
if (reader.TokenType == JsonToken.String)
{
Guid id;
FlaxEngine.Json.JsonSerializer.ParseID((string)reader.Value, out id);
FlaxEngine.Json.JsonSerializer.ParseID((string)reader.Value, out Guid id);
return Editor.Instance.ContentDatabase.Find(id);
}

View File

@@ -113,8 +113,7 @@ namespace FlaxEditor.Content.Import
extension = extension.ToLower();
// Check if use overriden type
ImportFileEntryHandler createDelegate;
if (FileTypes.TryGetValue(extension, out createDelegate))
if (FileTypes.TryGetValue(extension, out ImportFileEntryHandler createDelegate))
return createDelegate(ref request);
// Use default type

View File

@@ -26,8 +26,7 @@ namespace FlaxEditor.CustomEditors.Editors
private void OnEditEnd()
{
Guid value;
if (Guid.TryParse(_element.Text, out value))
if (Guid.TryParse(_element.Text, out Guid value))
{
SetValue(value);
}

View File

@@ -63,8 +63,7 @@ namespace FlaxEditor.CustomEditors.Editors
float z = ZElement.FloatValue.Value;
var isSliding = XElement.IsSliding || YElement.IsSliding || ZElement.IsSliding;
var token = isSliding ? this : null;
Quaternion value;
Quaternion.Euler(x, y, z, out value);
Quaternion.Euler(x, y, z, out Quaternion value);
SetValue(value, token);
}

View File

@@ -251,8 +251,7 @@ namespace FlaxEditor.GUI.Dialogs
if (_disableEvents)
return;
Color color;
if (Color.TryParseHex(_cHex.Text, out color))
if (Color.TryParseHex(_cHex.Text, out Color color))
SelectedColor = color;
}

View File

@@ -402,8 +402,7 @@ namespace FlaxEditor.GUI.Docking
else if (MouseDownWindow != null && _panel.TabsCount > 1)
{
// Check if mouse left current tab rect
Rectangle currWinRect;
GetTabRect(MouseDownWindow, out currWinRect);
GetTabRect(MouseDownWindow, out Rectangle currWinRect);
if (!currWinRect.Contains(location))
{
int index = _panel.GetTabIndex(MouseDownWindow);

View File

@@ -112,8 +112,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = Editor.Instance.Scene.GetActorNode(id);

View File

@@ -98,8 +98,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = FlaxEngine.Object.Find<Script>(ref id);
@@ -129,8 +128,7 @@ namespace FlaxEditor.GUI.Drag
for (int i = 0; i < ids.Length; i++)
{
// Find element
Guid id;
if (Guid.TryParse(ids[i], out id))
if (Guid.TryParse(ids[i], out Guid id))
{
var obj = FlaxEngine.Object.Find<Script>(ref id);

View File

@@ -117,8 +117,7 @@ namespace FlaxEditor.GUI.Input
protected override void TryGetValue()
{
// Try to parse long
long value;
if (long.TryParse(Text, out value))
if (long.TryParse(Text, out long value))
{
// Set value
Value = value;

View File

@@ -46,8 +46,7 @@ namespace FlaxEditor.Gizmo
// Transform ray into local space of the gizmo
Ray localRay;
Matrix invGizmoWorld;
Matrix.Invert(ref _gizmoWorld, out invGizmoWorld);
Matrix.Invert(ref _gizmoWorld, out Matrix invGizmoWorld);
Vector3.TransformNormal(ref ray.Direction, ref invGizmoWorld, out localRay.Direction);
Vector3.Transform(ref ray.Position, ref invGizmoWorld, out localRay.Position);

View File

@@ -157,9 +157,8 @@ namespace FlaxEditor.Gizmo
_screenScale = vLength.Length / GizmoScaleFactor * gizmoSize;
Matrix.Scaling(_screenScale, out _screenScaleMatrix);
Matrix rotation;
Quaternion orientation = GetSelectedObject(0).Orientation;
Matrix.RotationQuaternion(ref orientation, out rotation);
Matrix.RotationQuaternion(ref orientation, out Matrix rotation);
_localForward = rotation.Forward;
_localUp = rotation.Up;

View File

@@ -124,8 +124,7 @@ namespace FlaxEditor.Modules
/// <param name="skipSettingsDialog">True if skip any popup dialogs showing for import options adjusting. Can be used when importing files from code.</param>
public void Reimport(BinaryAssetItem item, object settings = null, bool skipSettingsDialog = false)
{
string importPath;
if (item != null && !item.GetImportPath(out importPath))
if (item != null && !item.GetImportPath(out string importPath))
{
// Check if input file is missing
if (!System.IO.File.Exists(importPath))

View File

@@ -415,8 +415,7 @@ namespace FlaxEditor.Modules
writer.WriteStartElement("Panel");
float splitterValue;
DockState state = p.TryGetDockState(out splitterValue);
DockState state = p.TryGetDockState(out float splitterValue);
writer.WriteAttributeString("DockState", ((int)state).ToString());
writer.WriteAttributeString("SplitterValue", splitterValue.ToString(CultureInfo.InvariantCulture));
@@ -684,8 +683,7 @@ namespace FlaxEditor.Modules
}
// Check if it's an asset ID
Guid id;
if (Guid.TryParse(typename, out id))
if (Guid.TryParse(typename, out Guid id))
{
var el = Editor.ContentDatabase.Find(id);
if (el != null)

View File

@@ -125,9 +125,8 @@ namespace FlaxEditor.SceneGraph.GUI
}
else
{
QueryFilterHelper.Range[] ranges;
var text = Text;
if (QueryFilterHelper.Match(filterText, text, out ranges))
if (QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges))
{
// Update highlights
if (_highlights == null)

View File

@@ -76,8 +76,7 @@ namespace FlaxEditor.SceneGraph
if (id == Guid.Empty)
return null;
SceneGraphNode result;
Nodes.TryGetValue(id, out result);
Nodes.TryGetValue(id, out SceneGraphNode result);
return result;
}
@@ -88,8 +87,7 @@ namespace FlaxEditor.SceneGraph
/// <returns>The result node.</returns>
public static SceneGraphNode GetNode(Guid id)
{
SceneGraphNode result;
Nodes.TryGetValue(id, out result);
Nodes.TryGetValue(id, out SceneGraphNode result);
if (result == null)
{
var actor = Object.TryFind<Actor>(ref id);

View File

@@ -37,8 +37,7 @@ namespace FlaxEditor.Surface
// Push clipping mask
if (ClipChildren)
{
Rectangle clientArea;
GetDesireClientArea(out clientArea);
GetDesireClientArea(out Rectangle clientArea);
Render2D.PushClip(ref clientArea);
}

View File

@@ -54,8 +54,7 @@ namespace FlaxEditor.Surface
return;
// Get or create context
VisjectSurfaceContext surfaceContext;
if (!_contextCache.TryGetValue(context, out surfaceContext))
if (!_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext))
{
surfaceContext = CreateContext(_context, context);
_context?.Children.Add(surfaceContext);
@@ -119,8 +118,7 @@ namespace FlaxEditor.Surface
}
// Check if has context in cache
VisjectSurfaceContext surfaceContext;
if (_contextCache.TryGetValue(context, out surfaceContext))
if (_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext))
{
// Remove from navigation path
while (ContextStack.Contains(surfaceContext))
@@ -149,8 +147,7 @@ namespace FlaxEditor.Surface
return;
// Check if already in a path
VisjectSurfaceContext surfaceContext;
if (_contextCache.TryGetValue(context, out surfaceContext) && ContextStack.Contains(surfaceContext))
if (_contextCache.TryGetValue(context, out VisjectSurfaceContext surfaceContext) && ContextStack.Contains(surfaceContext))
{
// Change stack
do

View File

@@ -980,10 +980,10 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
float value1;
if (float.TryParse(node.GetAttribute("Split1"), out value1))
if (float.TryParse(node.GetAttribute("Split1"), out float value1))
_split1.SplitterValue = value1;
if (float.TryParse(node.GetAttribute("Split2"), out value1))
_split2.SplitterValue = value1;
}

View File

@@ -282,8 +282,7 @@ namespace FlaxEditor.Tools.Foliage
};
// Try restore painting with the given model ID
bool itemChecked;
if (!Tab.FoliageTypeModelIdsToPaint.TryGetValue(model.ID, out itemChecked))
if (!Tab.FoliageTypeModelIdsToPaint.TryGetValue(model.ID, out bool itemChecked))
{
// Enable by default
itemChecked = true;

View File

@@ -310,10 +310,9 @@ namespace FlaxEditor.Tools.Terrain
throw new InvalidOperationException("Cannot set cursor then no terrain is selected.");
var brushBounds = CursorBrushBounds;
var patchesCount = terrain.PatchesCount;
BoundingBox tmp;
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out tmp);
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
continue;

View File

@@ -329,10 +329,9 @@ namespace FlaxEditor.Tools.Terrain
throw new InvalidOperationException("Cannot set cursor then no terrain is selected.");
var brushBounds = CursorBrushBounds;
var patchesCount = terrain.PatchesCount;
BoundingBox tmp;
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out tmp);
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
continue;

View File

@@ -1691,8 +1691,7 @@ namespace FlaxEditor.Utilities
orientation = Quaternion.LookRotation(dir, Vector3.Cross(Vector3.Cross(dir, Vector3.Up), dir));
Vector3 up = Vector3.Up * orientation;
box.Transformation = Matrix.CreateWorld(min + vec * 0.5f, dir, up);
Matrix inv;
Matrix.Invert(ref box.Transformation, out inv);
Matrix.Invert(ref box.Transformation, out Matrix inv);
Vector3 vecLocal = Vector3.TransformNormal(vec * 0.5f, inv);
box.Extents.X = margin;
box.Extents.Y = margin;

View File

@@ -99,8 +99,7 @@ namespace FlaxEditor.Viewport.Cameras
{
centerMouse = true;
EditorViewport.Input input;
Viewport.GetInput(out input);
Viewport.GetInput(out EditorViewport.Input input);
// Rotate
Viewport.YawPitch += mouseDelta;

View File

@@ -85,8 +85,7 @@ namespace FlaxEditor.Viewport.Cameras
/// <param name="actor">The actor to preview.</param>
public void ShowActor(Actor actor)
{
BoundingSphere sphere;
Editor.GetActorEditorSphere(actor, out sphere);
Editor.GetActorEditorSphere(actor, out BoundingSphere sphere);
ShowSphere(ref sphere);
}
@@ -104,8 +103,7 @@ namespace FlaxEditor.Viewport.Cameras
{
if (actors[i] is ActorNode actor)
{
BoundingSphere sphere;
Editor.GetActorEditorSphere(actor.Actor, out sphere);
Editor.GetActorEditorSphere(actor.Actor, out BoundingSphere sphere);
BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
}
}