forked from Shardstone/trail-into-darkness
added more utilty packges
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jovian.Utilities;
|
||||
|
||||
namespace Nox.Game {
|
||||
public interface IModfiersFactory {
|
||||
IReadOnlyCollection<ModifierDefinition> GetAll();
|
||||
ModifierDefinition GetById(ModifierIds modifierId);
|
||||
ModifierDefinition GetById(Guid modifierId);
|
||||
IReadOnlyCollection<ModifierDefinition> GetModifiersFor(CharacterDefinition character);
|
||||
bool TryAddModifier(CharacterDefinition character, string modiferId);
|
||||
}
|
||||
@@ -20,7 +21,6 @@ namespace Nox.Game {
|
||||
|
||||
[Serializable]
|
||||
public sealed class ModifierDefinition {
|
||||
[ReadOnlyField]
|
||||
public System.Guid id = Guid.NewGuid();
|
||||
public StatType statType;
|
||||
public AttributeType attributeType;
|
||||
@@ -44,7 +44,7 @@ namespace Nox.Game {
|
||||
public IReadOnlyCollection<ModifierDefinition> GetAll() {
|
||||
return modifiersRegistry.modifiersData.modifiers;
|
||||
}
|
||||
public ModifierDefinition GetById(ModifierIds modifierId) {
|
||||
public ModifierDefinition GetById(Guid modifierId) {
|
||||
return modifiersRegistry.modifiersData.modifiers.FirstOrDefault(m => m.id == modifierId);
|
||||
}
|
||||
public IReadOnlyCollection<ModifierDefinition> GetModifiersFor(CharacterDefinition character) {
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace Nox.Game {
|
||||
|
||||
public interface IPerkFactory {
|
||||
IReadOnlyCollection<PerkDefinition> GetAll();
|
||||
PerkDefinition GetById(PerksIds perkId);
|
||||
PerkDefinition GetById(Guid perkId);
|
||||
IReadOnlyCollection<PerkDefinition> GetPerksFor(CharacterDefinition character);
|
||||
bool TryAddPerk(CharacterDefinition character, PerksIds perkId);
|
||||
bool TryAddPerk(CharacterDefinition character, Guid perkId);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PerkDefinition {
|
||||
public PerksIds id;
|
||||
public Guid id;
|
||||
public string name;
|
||||
public ModifiersData modifiers = new ();
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace Nox.Game {
|
||||
}
|
||||
|
||||
public sealed class PerkFactory : IPerkFactory {
|
||||
private readonly Dictionary<PerksIds, PerkDefinition> perkPool = new ();
|
||||
private readonly Dictionary<Guid, PerkDefinition> perkPool = new ();
|
||||
|
||||
public PerkFactory(PerksRegistry perksRegistry) {
|
||||
if(!perksRegistry) {
|
||||
@@ -40,7 +40,7 @@ namespace Nox.Game {
|
||||
return perkPool.Values.ToList();
|
||||
}
|
||||
|
||||
public PerkDefinition GetById(PerksIds perkId) {
|
||||
public PerkDefinition GetById(Guid perkId) {
|
||||
perkPool.TryGetValue(perkId, out var perk);
|
||||
return perk;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace Nox.Game {
|
||||
return perkPool.Values.Where(p => !ownedPerkIds.Contains(p.id)).ToList();
|
||||
}
|
||||
|
||||
public bool TryAddPerk(CharacterDefinition character, PerksIds perkId) {
|
||||
public bool TryAddPerk(CharacterDefinition character, Guid perkId) {
|
||||
if(character == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user