Statistics done
This commit is contained in:
parent
6fbae10750
commit
e9f230d4cc
17 changed files with 218 additions and 153 deletions
16
scripts/entities/EatingStatistics.cs
Normal file
16
scripts/entities/EatingStatistics.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class EatingStatistics : Node
|
||||
{
|
||||
[Export]
|
||||
private string animationName;
|
||||
private float bitesPerSecond;
|
||||
public override void _Ready()
|
||||
{
|
||||
var animation = GetParent<AnimationPlayer>().GetAnimation(animationName);
|
||||
|
||||
var track_id = animation.FindTrack("../../Eatbox",Animation.TrackType.Method);
|
||||
bitesPerSecond = animation.TrackGetKeyCount(track_id)/ animation.Length;
|
||||
}
|
||||
}
|
||||
1
scripts/entities/EatingStatistics.cs.uid
Normal file
1
scripts/entities/EatingStatistics.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dw7v3s4kbu7ma
|
||||
|
|
@ -53,8 +53,13 @@ public partial class Previewport : SubViewport
|
|||
var keys = GetRequestedKeys(unparsedDescription);
|
||||
FillPlaceholders(keys, resource, current_display);
|
||||
var parsedDescription = ReplaceTextUsingDict(keys, unparsedDescription);
|
||||
var rwd = Tr("rwd_" + resource.NameKey);
|
||||
if (rwd == "rwd_" + resource.NameKey)
|
||||
{
|
||||
rwd = "";
|
||||
}
|
||||
|
||||
description.Text = Tr("rwd_" + resource.NameKey) + "\n" + parsedDescription;
|
||||
description.Text = rwd + "\n" + parsedDescription;
|
||||
}
|
||||
|
||||
private Dictionary<string, float> GetRequestedKeys(string text)
|
||||
|
|
@ -105,27 +110,61 @@ public partial class Previewport : SubViewport
|
|||
}
|
||||
|
||||
foreach (var key in placeholderDictionary.Keys)
|
||||
{
|
||||
string modifiers = "";
|
||||
string request = key.Split('|')[0];
|
||||
if (key.Split('|').Length == 2)
|
||||
{
|
||||
var namePropertyPair = key.Split('.');
|
||||
Variant property;
|
||||
if (namePropertyPair.Length == 2)
|
||||
{
|
||||
if ((namePropertyPair[0] == "?" && lookedObject != searchScene)||(namePropertyPair[0] != "?" && lookedObject is Node node && node.Name != namePropertyPair[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
property = lookedObject.Get(namePropertyPair[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = lookedObject.Get(namePropertyPair[0]);
|
||||
}
|
||||
if (property.VariantType == Variant.Type.Nil)
|
||||
modifiers = key.Split('|')[1];
|
||||
}
|
||||
var namePropertyPair = request.Split('.');
|
||||
Variant property;
|
||||
if (namePropertyPair.Length == 2)
|
||||
{
|
||||
if ((namePropertyPair[0] == "?" && lookedObject != searchScene)||(namePropertyPair[0] != "?" && lookedObject is Node node && node.Name != namePropertyPair[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
placeholderDictionary[key] = property.As<float>();
|
||||
property = lookedObject.Get(namePropertyPair[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = lookedObject.Get(namePropertyPair[0]);
|
||||
}
|
||||
if (property.VariantType == Variant.Type.Nil)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float value = property.As<float>();
|
||||
|
||||
if (modifiers != "")
|
||||
{
|
||||
foreach (var c in modifiers)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '%':
|
||||
value *= 100;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
value *= c - '0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholderDictionary[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private string ReplaceTextUsingDict(Dictionary<string, float> dictionary, string text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue