Default to .NET collections

main
copygirl 12 months ago
parent 116b09b047
commit 2d70ece0cf
  1. 2
      assets/shaders/ReplacePalette.cs
  2. 14
      player/PickupController.cs
  3. 7
      scripts/globals/GlobalUsings.cs

@ -7,7 +7,7 @@ public partial class ReplacePalette : Node3D
}
static Shader _paletteShader;
static System.Collections.Generic.Dictionary<Texture2D, TextureInfo> _textureCache = [];
static Dictionary<Texture2D, TextureInfo> _textureCache = [];
[Export] public Texture2D Palette { get; set; }

@ -141,6 +141,7 @@ public partial class PickupController : Node3D
}
}
record class RayResult(CollisionObject3D Collider, Vector3 Position, Vector3 Normal);
RayResult RayToMouseCursor(PhysicsLayer collisionMask)
{
var camera = _player.Camera.Camera;
@ -155,14 +156,11 @@ public partial class PickupController : Node3D
query.Exclude = HasItemsHeld ? [ CurrentItem.GetRid() ] : [];
var result = GetWorld3D().DirectSpaceState.IntersectRay(query);
return (result.Count > 0) ? new(result) : null;
}
class RayResult(Dictionary dict)
{
public CollisionObject3D Collider { get; } = dict["collider"].As<CollisionObject3D>();
public Vector3 Position { get; } = (Vector3)dict["position"];
public Vector3 Normal { get; } = (Vector3)dict["normal"];
return (result.Count > 0) ? new(
result["collider"].As<CollisionObject3D>(),
(Vector3)result["position"],
(Vector3)result["normal"]
) : null;
}
enum OutlineMode { Disable, Enable, Exclusive }

@ -1,6 +1,11 @@
// These usings are included by default in every source file.
// See: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive#global-modifier
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using Godot;
global using Godot.Collections;
global using static Godot.GD;
global using static Godot.Mathf;

Loading…
Cancel
Save