Adds a bunch more move scripts
This commit is contained in:
17
PkmnLib.Dynamic/Events/DialogEvent.cs
Normal file
17
PkmnLib.Dynamic/Events/DialogEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace PkmnLib.Dynamic.Events;
|
||||
|
||||
public class DialogEvent : IEventData
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public EventBatchId BatchId { get; init; } = new();
|
||||
|
||||
public DialogEvent(string message, Dictionary<string, object>? parameters = null)
|
||||
{
|
||||
Message = message;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public Dictionary<string, object>? Parameters { get; set; }
|
||||
}
|
||||
@@ -93,7 +93,14 @@ public interface IPokemon : IScriptSource
|
||||
float WeightInKg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the Pokemon in meters.
|
||||
/// Sets the weight of the Pokémon in kilograms. Returns whether the weight was changed.
|
||||
/// </summary>
|
||||
/// <param name="weightInKg">The new weight in kilograms</param>
|
||||
/// <returns></returns>
|
||||
public bool ChangeWeightInKgBy(float weightInKg);
|
||||
|
||||
/// <summary>
|
||||
/// The height of the Pokémon in meters.
|
||||
/// </summary>
|
||||
float HeightInMeters { get; set; }
|
||||
|
||||
@@ -543,6 +550,18 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
/// <inheritdoc />
|
||||
public float WeightInKg { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ChangeWeightInKgBy(float weightInKg)
|
||||
{
|
||||
if (WeightInKg <= 0.1f)
|
||||
return false;
|
||||
var newWeight = WeightInKg + weightInKg;
|
||||
if (newWeight <= 0.1f)
|
||||
newWeight = 0.1f;
|
||||
WeightInKg = newWeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public float HeightInMeters { get; set; }
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ public static class ScriptUtils
|
||||
/// </summary>
|
||||
public static StringKey ResolveName(this Script script) => ResolveName(script.GetType());
|
||||
|
||||
public static StringKey ResolveName<T>() where T : Script => ResolveName(typeof(T));
|
||||
|
||||
/// <summary>
|
||||
/// Resolve name from the <see cref="ScriptAttribute"/> of the given type.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,8 +14,15 @@ namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
/// </summary>
|
||||
public abstract class Script
|
||||
{
|
||||
internal event Action<Script>? OnRemoveEvent;
|
||||
|
||||
private int _suppressCount;
|
||||
|
||||
public void RemoveSelf()
|
||||
{
|
||||
OnRemoveEvent?.Invoke(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of a script is its unique identifier.
|
||||
/// If not overridden, this will resolve the name from the <see cref="ScriptAttribute"/> of the
|
||||
|
||||
@@ -79,6 +79,7 @@ public class ScriptSet : IScriptSet
|
||||
return existing;
|
||||
}
|
||||
|
||||
script.OnRemoveEvent += s => Remove(s.Name);
|
||||
var container = new ScriptContainer(script);
|
||||
_scripts.Add(container);
|
||||
return container;
|
||||
@@ -97,6 +98,7 @@ public class ScriptSet : IScriptSet
|
||||
var script = instantiation();
|
||||
if (script is null)
|
||||
return null;
|
||||
script.OnRemoveEvent += s => Remove(s.Name);
|
||||
var container = new ScriptContainer(script);
|
||||
_scripts.Add(container);
|
||||
return container;
|
||||
@@ -111,6 +113,7 @@ public class ScriptSet : IScriptSet
|
||||
var script = _scripts.FirstOrDefault(s => s.Script?.Name == scriptKey);
|
||||
if (script is null)
|
||||
return;
|
||||
script.Script?.OnRemove();
|
||||
_scripts.Remove(script);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user