stop fucking formatting my files godot

This commit is contained in:
Snorre 2025-04-05 17:03:51 +02:00
parent c8139edf2a
commit f8f1cbaab7
5 changed files with 105 additions and 109 deletions

View file

@ -22,6 +22,10 @@ project/assembly_name="nordic25"
import/blender/enabled=false
[rendering]
renderer/rendering_method="mobile"
[xr]
openxr/enabled=true

View file

@ -48,6 +48,7 @@ transform = Transform3D(1, 0, 0, 0, -0.837394, -0.546599, 0, 0.546599, -0.837394
shape = SubResource("CapsuleShape3D_74lek")
[node name="Player" parent="." instance=ExtResource("2_iyx0m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.576159)
[node name="test pellet" parent="." instance=ExtResource("3_iyx0m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00932735, 0.01, -0.0187979)

View file

@ -3,45 +3,48 @@ using Godot;
public partial class Mouth : XRCamera3D
{
[Export]
public float MaxEatWeight = 1.0f;
[Export]
public float MaxEatWeight = 1.0f;
[Export]
public float EatGrowthFactor = 0.1f;
[Export]
public float EatGrowthFactor = 0.1f;
[Export]
public XRHand RightHand;
[Export]
public XRHand LeftHand;
[Export]
public XRHand RightHand;
[Export]
public XRHand LeftHand;
public override void _Ready()
{
UpdateWeights();
}
public override void _Ready()
{
UpdateWeights();
}
public void EnterMouth(Node node)
{
try
{
RigidBody3D body = (RigidBody3D)node;
if (body.Mass > MaxEatWeight)
return;
public void EnterMouth(Node node)
{
try
{
RigidBody3D body = (RigidBody3D)node;
if (body.Mass > MaxEatWeight)
return;
UpdateWeights(body.Mass);
UpdateWeights(body.Mass);
}
catch (System.InvalidCastException)
{
// dont give a shit
}
}
}
catch (System.InvalidCastException)
{
// dont give a shit
}
}
void UpdateWeights(float mass = 0f)
{
MaxEatWeight += (mass / MaxEatWeight) * EatGrowthFactor;
((XROrigin3D)GetParent()).WorldScale = 1.0f / MaxEatWeight;
RightHand.Strength = MaxEatWeight;
LeftHand.Strength = MaxEatWeight;
}
void UpdateWeights(float mass = 0f)
{
GD.Print("Ate ", mass, "kg");
MaxEatWeight += (mass / MaxEatWeight) * EatGrowthFactor;
float WorldScale = 1.0f / MaxEatWeight;
((XROrigin3D)GetParent()).WorldScale = WorldScale;
RightHand.Strength = MaxEatWeight;
LeftHand.Strength = MaxEatWeight;
GD.Print("New MaxEatWeight: ", MaxEatWeight);
GD.Print("New WorldScale: ", WorldScale);
}
}

View file

@ -3,76 +3,64 @@ using System.Collections.Generic;
public partial class XRHand : XRController3D
{
List<Generic6DofJoint3D> joints = new();
List<PinJoint3D> joints = new();
[Export]
StaticBody3D body;
[Export]
StaticBody3D body;
[Export]
public float Strength = 1.0f;
[Export]
public float Strength = 1.0f;
public override void _Process(double delta)
{
if ((bool)GetInput("trigger_click"))
{
}
else if (joints.Count > 0)
{
}
}
public void OnPress(string name)
{
if (name == "select_button")
{
var query = new PhysicsShapeQueryParameters3D();
var sphere = new SphereShape3D();
sphere.Radius = 0.1f;
query.Shape = sphere;
query.CollideWithBodies = true;
query.CollideWithAreas = false;
query.Transform = ((Node3D)GetParent()).GlobalTransform;
var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query);
foreach (var fuckingcollider in overlaps)
{
RigidBody3D body = null;
try
{
body = (RigidBody3D)fuckingcollider["collider"];
}
catch (System.InvalidCastException)
{
continue;
}
public void OnPress(string name)
{
if (name == "select_button")
{
var query = new PhysicsShapeQueryParameters3D();
var sphere = new SphereShape3D();
sphere.Radius = 0.1f;
query.Shape = sphere;
query.CollideWithBodies = true;
query.CollideWithAreas = false;
query.Transform = ((Node3D)GetParent()).GlobalTransform;
var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query);
foreach (var fuckingcollider in overlaps)
{
RigidBody3D body = null;
try
{
body = (RigidBody3D)fuckingcollider["collider"];
}
catch (System.InvalidCastException)
{
continue;
}
if (body.Mass > Strength)
continue;
if (body.Mass > Strength)
{
continue;
}
PinJoint3D joint = new();
joint.NodeA = GetPathTo(body);
joint.NodeB = body.GetPath();
joints.Add(joint);
AddChild(joint);
}
}
}
Generic6DofJoint3D joint = new();
joint.NodeA = GetPathTo(body);
joint.NodeB = body.GetPath();
joints.Add(joint);
AddChild(joint);
}
}
}
public void OnRelease(string name)
{
if (name == "select_button")
{
foreach (var joint in joints)
joint.QueueFree();
joints.Clear();
}
}
public void OnRelease(string name)
{
if (name == "select_button")
{
foreach (var joint in joints)
joint.QueueFree();
joints.Clear();
}
}
public void OnFloat(string name, float value)
{
// GD.Print("Float input:");
// GD.Print(name);
// GD.Print(value);
}
public void OnFloat(string name, float value)
{
// GD.Print("Float input:");
// GD.Print(name);
// GD.Print(value);
}
}

View file

@ -3,17 +3,17 @@ using System;
public partial class XrOrigin3d : XROrigin3D
{
private XRInterface _xrInterface;
private XRInterface _xrInterface;
public override void _Ready()
{
_xrInterface = XRServer.FindInterface("OpenXR");
if (_xrInterface == null || !_xrInterface.IsInitialized())
GD.PushError("Failed to initialize OpenXR");
public override void _Ready()
{
_xrInterface = XRServer.FindInterface("OpenXR");
if (_xrInterface == null || !_xrInterface.IsInitialized())
GD.PushError("Failed to initialize OpenXR");
GD.PushError("OpenXR Initialized successfully");
GD.Print("OpenXR Initialized successfully");
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
GetViewport().UseXR = true;
}
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
GetViewport().UseXR = true;
}
}