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