Modifier frenzy
This commit is contained in:
parent
e9f230d4cc
commit
e8cb681103
16 changed files with 198 additions and 143 deletions
17
scripts/entities/AnimationStatistics.cs
Normal file
17
scripts/entities/AnimationStatistics.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Godot;
|
||||
|
||||
public partial class AnimationStatistics : Node
|
||||
{
|
||||
[Export]
|
||||
private string animationName;
|
||||
[Export]
|
||||
private string trackToFind;
|
||||
private float invokationsPerSecond;
|
||||
public override void _Ready()
|
||||
{
|
||||
var animation = GetParent<AnimationPlayer>().GetAnimation(animationName);
|
||||
|
||||
var track_id = animation.FindTrack(trackToFind,Animation.TrackType.Method);
|
||||
invokationsPerSecond = animation.TrackGetKeyCount(track_id)/ animation.Length;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,18 +48,32 @@ public partial class Previewport : SubViewport
|
|||
if (current_display is Entity entity)
|
||||
entity.DisableBrain();
|
||||
|
||||
string descriptionText;
|
||||
if (resource.isDescriptionParsed == false)
|
||||
{
|
||||
var unparsedDescription = Tr(resource.DescriptionKey);
|
||||
var keys = GetRequestedKeys(unparsedDescription);
|
||||
FillPlaceholders(keys, resource, current_display);
|
||||
descriptionText = ReplaceTextUsingDict(keys, unparsedDescription);
|
||||
|
||||
var unparsedDescription = Tr(resource.DescriptionKey);
|
||||
var keys = GetRequestedKeys(unparsedDescription);
|
||||
FillPlaceholders(keys, resource, current_display);
|
||||
var parsedDescription = ReplaceTextUsingDict(keys, unparsedDescription);
|
||||
resource.parsedDescription = descriptionText;
|
||||
resource.isDescriptionParsed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
descriptionText = resource.parsedDescription;
|
||||
}
|
||||
var rwd = Tr("rwd_" + resource.NameKey);
|
||||
if (rwd == "rwd_" + resource.NameKey)
|
||||
{
|
||||
rwd = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
rwd += "\n";
|
||||
}
|
||||
|
||||
description.Text = rwd + "\n" + parsedDescription;
|
||||
description.Text = rwd + descriptionText;
|
||||
}
|
||||
|
||||
private Dictionary<string, float> GetRequestedKeys(string text)
|
||||
|
|
@ -91,7 +105,7 @@ public partial class Previewport : SubViewport
|
|||
var lookedObject = searchList[0];
|
||||
searchList.RemoveAt(0);
|
||||
|
||||
if(lookedObject is Node lookedNode)
|
||||
if (lookedObject is Node lookedNode)
|
||||
searchList.AddRange(lookedNode.GetChildren());
|
||||
if (lookedObject is Shooter shooter)
|
||||
{
|
||||
|
|
@ -111,17 +125,12 @@ public partial class Previewport : SubViewport
|
|||
|
||||
foreach (var key in placeholderDictionary.Keys)
|
||||
{
|
||||
string modifiers = "";
|
||||
string request = key.Split('|')[0];
|
||||
if (key.Split('|').Length == 2)
|
||||
{
|
||||
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]))
|
||||
if ((namePropertyPair[0] == "?" && lookedObject != searchScene) || (namePropertyPair[0] != "?" && lookedObject is Node node && node.Name != namePropertyPair[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -138,33 +147,54 @@ public partial class Previewport : SubViewport
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Apply any modifiers
|
||||
foreach (var key in placeholderDictionary.Keys)
|
||||
{
|
||||
if (key.Split('|').Length < 2) continue;
|
||||
string[] modifiers = key.Split('|')[1..];
|
||||
|
||||
float value = placeholderDictionary[key];
|
||||
|
||||
foreach (var mod in modifiers)
|
||||
{
|
||||
if (mod != "")
|
||||
{
|
||||
switch (mod[0])
|
||||
{
|
||||
case '%':
|
||||
value *= 100;
|
||||
break;
|
||||
case '*':
|
||||
if (placeholderDictionary.ContainsKey(mod[1..]))
|
||||
{
|
||||
value *= placeholderDictionary[mod[1..]];
|
||||
}
|
||||
else if (float.TryParse(mod[1..], out float result))
|
||||
{
|
||||
value *= result;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
if (placeholderDictionary.ContainsKey(mod[1..]))
|
||||
{
|
||||
value /= placeholderDictionary[mod[1..]];
|
||||
}
|
||||
else if (float.TryParse(mod[1..], out float result))
|
||||
{
|
||||
value /= result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholderDictionary[key] = value;
|
||||
}
|
||||
}
|
||||
private string ReplaceTextUsingDict(Dictionary<string, float> dictionary, string text)
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ public partial class EntityResource : Resource
|
|||
[Export] public CustomSeedpacketFrame CustomFrame;
|
||||
[Export] public int Order = 0;
|
||||
public string internal_id;
|
||||
public string parsedDescription;
|
||||
public bool isDescriptionParsed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue