forked from Shardstone/trail-into-darkness
Added some data
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Nox.Game {
|
||||
[CreateAssetMenu(fileName = "CharacterBaseSettings", menuName = "Nox/Database/Entities/CharacterBaseSettings")]
|
||||
public class CharacterBaseSettings: ScriptableObject {
|
||||
[Header("Character Creation Defaults")]
|
||||
public DistributionPointsPerClass distributionPointsPerClass;
|
||||
public DistributionPointsPerClass[] distributionPointsPerClass;
|
||||
public EntityAttributes defaultEntityAttributes;
|
||||
public EntityStats defaultEntityStats;
|
||||
public PerksData defaultPerksData;
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
namespace Nox.Game {
|
||||
public interface IModfiersFactory {
|
||||
IReadOnlyCollection<ModifierDefinition> GetAll();
|
||||
ModifierDefinition GetById(string modifierId);
|
||||
ModifierDefinition GetById(ModifierIds modifierId);
|
||||
IReadOnlyCollection<ModifierDefinition> GetModifiersFor(CharacterDefinition character);
|
||||
bool TryAddModifier(CharacterDefinition character, string modiferId);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Nox.Game {
|
||||
|
||||
[Serializable]
|
||||
public sealed class ModifierDefinition {
|
||||
public string id;
|
||||
public ModifierIds id;
|
||||
public ModifierType type;
|
||||
public float value;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Nox.Game {
|
||||
public IReadOnlyCollection<ModifierDefinition> GetAll() {
|
||||
return modifiersRegistry.modifiersData.modifiers;
|
||||
}
|
||||
public ModifierDefinition GetById(string modifierId) {
|
||||
public ModifierDefinition GetById(ModifierIds modifierId) {
|
||||
return modifiersRegistry.modifiersData.modifiers.FirstOrDefault(m => m.id == modifierId);
|
||||
}
|
||||
public IReadOnlyCollection<ModifierDefinition> GetModifiersFor(CharacterDefinition character) {
|
||||
|
||||
11
Assets/Code/GameState/Entities/ModifiersPerksList.cs
Normal file
11
Assets/Code/GameState/Entities/ModifiersPerksList.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Nox.Game {
|
||||
public enum ModifierIds {
|
||||
generic_mgt_health_multiplier,
|
||||
warrior_mgt_health_multiplier,
|
||||
generic_mgt_mana_multiplier,
|
||||
generic_kno_mana_multiplier
|
||||
}
|
||||
|
||||
public enum PerksIds{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc2631d096794cea9ae7c9cd82a38c53
|
||||
timeCreated: 1774366047
|
||||
@@ -6,14 +6,14 @@ namespace Nox.Game {
|
||||
|
||||
public interface IPerkFactory {
|
||||
IReadOnlyCollection<PerkDefinition> GetAll();
|
||||
PerkDefinition GetById(string perkId);
|
||||
PerkDefinition GetById(PerksIds perkId);
|
||||
IReadOnlyCollection<PerkDefinition> GetPerksFor(CharacterDefinition character);
|
||||
bool TryAddPerk(CharacterDefinition character, string perkId);
|
||||
bool TryAddPerk(CharacterDefinition character, PerksIds perkId);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PerkDefinition {
|
||||
public string id;
|
||||
public PerksIds id;
|
||||
public string name;
|
||||
public ModifiersData modifiers = new ();
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace Nox.Game {
|
||||
}
|
||||
|
||||
public sealed class PerkFactory : IPerkFactory {
|
||||
private readonly Dictionary<string, PerkDefinition> perkPool = new ();
|
||||
private readonly Dictionary<PerksIds, PerkDefinition> perkPool = new ();
|
||||
|
||||
public PerkFactory(PerksRegistry perksRegistry) {
|
||||
if(!perksRegistry) {
|
||||
@@ -40,11 +40,7 @@ namespace Nox.Game {
|
||||
return perkPool.Values.ToList();
|
||||
}
|
||||
|
||||
public PerkDefinition GetById(string perkId) {
|
||||
if(string.IsNullOrWhiteSpace(perkId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PerkDefinition GetById(PerksIds perkId) {
|
||||
perkPool.TryGetValue(perkId, out var perk);
|
||||
return perk;
|
||||
}
|
||||
@@ -55,15 +51,14 @@ namespace Nox.Game {
|
||||
}
|
||||
|
||||
var ownedPerkIds = character.perksData.perks
|
||||
.Where(p => p != null && !string.IsNullOrWhiteSpace(p.id))
|
||||
.Select(p => p.id)
|
||||
.ToHashSet();
|
||||
|
||||
return perkPool.Values.Where(p => !ownedPerkIds.Contains(p.id)).ToList();
|
||||
}
|
||||
|
||||
public bool TryAddPerk(CharacterDefinition character, string perkId) {
|
||||
if(character == null || string.IsNullOrWhiteSpace(perkId)) {
|
||||
public bool TryAddPerk(CharacterDefinition character, PerksIds perkId) {
|
||||
if(character == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,7 +66,7 @@ namespace Nox.Game {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!perkPool.TryGetValue(perkId, out PerkDefinition perk)) {
|
||||
if(!perkPool.TryGetValue(perkId, out var perk)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user