more typo fixes

This commit is contained in:
LubieKakao1212 2023-01-19 15:57:13 +01:00
parent bf79b07ea4
commit 36840271af
11 changed files with 67 additions and 20 deletions

View File

@ -176,9 +176,9 @@ namespace NEG.Utils.Achievments
/// </summary> /// </summary>
/// <seealso cref="ToggleAchievmentDefinition"/> /// <seealso cref="ToggleAchievmentDefinition"/>
/// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks> /// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks>
public void SetToggleAchivment(string id) public bool SetToggleAchivment(string id)
{ {
ManipulateAchievment<ToggleAchievmentData>(id, (achievment) => achievment.CompletionState = true); return ManipulateAchievment<ToggleAchievmentData>(id, (achievment) => achievment.CompletionState = true);
} }
/// <summary> /// <summary>
@ -198,9 +198,9 @@ namespace NEG.Utils.Achievments
/// </summary> /// </summary>
/// <seealso cref="IntAchievmentDefinition"/> /// <seealso cref="IntAchievmentDefinition"/>
/// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks> /// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks>
public void SetIntProgress(string id, int progress) public bool SetIntProgress(string id, int progress)
{ {
ManipulateAchievment<IntAchievmentData>(id, (achievment) => achievment.CurrentProgress = progress); return ManipulateAchievment<IntAchievmentData>(id, (achievment) => achievment.CurrentProgress = progress);
} }
/// <summary> /// <summary>
@ -208,9 +208,9 @@ namespace NEG.Utils.Achievments
/// </summary> /// </summary>
/// <seealso cref="IntAchievmentDefinition"/> /// <seealso cref="IntAchievmentDefinition"/>
/// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks> /// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks>
public void ChangeIntProgress(string id, int delta) public bool ChangeIntProgress(string id, int delta)
{ {
ManipulateAchievment<IntAchievmentData>(id, (achievment) => achievment.CurrentProgress += delta); return ManipulateAchievment<IntAchievmentData>(id, (achievment) => achievment.CurrentProgress += delta);
} }
/// <summary> /// <summary>
@ -230,9 +230,9 @@ namespace NEG.Utils.Achievments
/// </summary> /// </summary>
/// <seealso cref="FloatAchievmentDefinition"/> /// <seealso cref="FloatAchievmentDefinition"/>
/// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks> /// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks>
public void SetFloatProgress(string id, float progress) public bool SetFloatProgress(string id, float progress)
{ {
ManipulateAchievment<FloatAchievmentData>(id, (achievment) => achievment.CurrentProgress = progress); return ManipulateAchievment<FloatAchievmentData>(id, (achievment) => achievment.CurrentProgress = progress);
} }
/// <summary> /// <summary>
@ -240,9 +240,9 @@ namespace NEG.Utils.Achievments
/// </summary> /// </summary>
/// <seealso cref="FloatAchievmentDefinition"/> /// <seealso cref="FloatAchievmentDefinition"/>
/// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks> /// <remarks>throws an <see cref="AchievmentException"/> if there is no achievment under id or an <see cref="AchievmentTypeException"/> if achievment under id is of a different type</remarks>
public void ChangeFloatProgress(string id, float delta) public bool ChangeFloatProgress(string id, float delta)
{ {
ManipulateAchievment<FloatAchievmentData>(id, (achievment) => achievment.CurrentProgress += delta); return ManipulateAchievment<FloatAchievmentData>(id, (achievment) => achievment.CurrentProgress += delta);
} }
/// <summary> /// <summary>
@ -290,7 +290,7 @@ namespace NEG.Utils.Achievments
{ {
if (data is not T convetred) if (data is not T convetred)
{ {
throw new AchievmentTypeException($"Attempting to perform an operation on an invalid achievment type. Expected {typeof(T)} got {data.GetType()}", data.Achivment.Id, typeof(T), data.GetType()); throw new AchievmentTypeException($"Attempting to perform an operation on an invalid achievment type. Expected {typeof(T)} got {data.GetType()}", data.Achievment.Id, typeof(T), data.GetType());
} }
return convetred; return convetred;
} }
@ -301,18 +301,20 @@ namespace NEG.Utils.Achievments
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="manipulation">Action to perform on the achievment</param> /// <param name="manipulation">Action to perform on the achievment</param>
private void ManipulateAchievment<T>(string id, Action<T> manipulation) where T : AchievmentData private bool ManipulateAchievment<T>(string id, Action<T> manipulation) where T : AchievmentData
{ {
var data = GetAchievmentForId<T>(id); var data = GetAchievmentForId<T>(id);
if (CheckNotCompleted(data)) if (CheckNotCompleted(data))
{ {
return; return true;
} }
manipulation(data); manipulation(data);
SendUpdateCallbacks(data); SendUpdateCallbacks(data);
return data.IsCompleted;
} }
/// <summary> /// <summary>
@ -324,7 +326,7 @@ namespace NEG.Utils.Achievments
{ {
if (data.IsCompleted) if (data.IsCompleted)
{ {
Debug.LogWarning($"Achievment already completed: {data.Achivment.Id}"); Debug.LogWarning($"Achievment already completed: {data.Achievment.Id}");
} }
return data.IsCompleted; return data.IsCompleted;
} }

View File

@ -5,7 +5,7 @@ using UnityEngine;
namespace NEG.Utils.Achievments namespace NEG.Utils.Achievments
{ {
[CreateAssetMenu(menuName = "Achivments/BaseConfig")] [CreateAssetMenu(menuName = "Achivments/BaseConfig")]
public class AchivmentManagerConfig : ScriptableObject, IAchivmentManagerConfig public class AchievmentManagerConfig : ScriptableObject, IAchivmentManagerConfig
{ {
public const string DefaultAchivmentsCollectionLabel = "Achivments"; public const string DefaultAchivmentsCollectionLabel = "Achivments";

View File

@ -9,13 +9,13 @@ namespace NEG.Utils.Achievments.AchievmentTypes
{ {
public abstract class AchievmentData public abstract class AchievmentData
{ {
public AchievmentDefinition Achivment { get; private set; } public AchievmentDefinition Achievment { get; private set; }
public abstract bool IsCompleted { get; } public abstract bool IsCompleted { get; }
public AchievmentData(AchievmentDefinition achivment) public AchievmentData(AchievmentDefinition achivment)
{ {
Achivment = achivment; Achievment = achivment;
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace NEG.Utils.Achievments.AchievmentTypes
public float ProgressLeft => Def.ProgressRequired - CurrentProgress; public float ProgressLeft => Def.ProgressRequired - CurrentProgress;
private FloatAchievmentDefinition Def => (FloatAchievmentDefinition)Achivment; private FloatAchievmentDefinition Def => (FloatAchievmentDefinition)Achievment;
private float currentProgress; private float currentProgress;

View File

@ -24,7 +24,7 @@ namespace NEG.Utils.Achievments.AchievmentTypes
public int ProgressLeft => Def.ProgressRequired - CurrentProgress; public int ProgressLeft => Def.ProgressRequired - CurrentProgress;
private IntAchievmentDefinition Def => (IntAchievmentDefinition)Achivment; private IntAchievmentDefinition Def => (IntAchievmentDefinition)Achievment;
private int currentProgress; private int currentProgress;

View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NEG.Utils.Achievments
{
public static class Achievments
{
public static AchievmentManager Instance
{
get
{
if (instance == null)
{
instance =
}
}
}
private static AchievmentManager instance;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 696bafd4c06b0a8458f008103441ea7f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

5
Achievments/TODO.txt Normal file
View File

@ -0,0 +1,5 @@
Static Achievments class
Implement Storage again
Fix typos
Merge AchievmentCollection with AchievmentManagerConfig
Static backend constructors

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 94e4aa3c6dc078c4db6a47949655f8a5
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -325,7 +325,7 @@ namespace NEG.Utils.Achievments.Tests
public void AchievmentCompleted(AchievmentData achievment) public void AchievmentCompleted(AchievmentData achievment)
{ {
LastTypeSet = achievment.GetType(); LastTypeSet = achievment.GetType();
LastIdSet = achievment.Achivment.Id; LastIdSet = achievment.Achievment.Id;
} }
public void AchievmentStateChanged(AchievmentData achievment) public void AchievmentStateChanged(AchievmentData achievment)