forked from Shardstone/trail-into-darkness
Added a bunch of utilities and modfief the character data structue
This commit is contained in:
@@ -12,6 +12,22 @@ namespace Nox.Game {
|
||||
EntityStats Stats { get; }
|
||||
}
|
||||
|
||||
public enum StatType {
|
||||
None,
|
||||
Health,
|
||||
Stamina,
|
||||
Level,
|
||||
Experience
|
||||
}
|
||||
|
||||
public enum AttributeType {
|
||||
None,
|
||||
Might,
|
||||
Reflex,
|
||||
Knowledge,
|
||||
Perception
|
||||
}
|
||||
|
||||
public enum CharacterRole {
|
||||
None,
|
||||
Protagonist,
|
||||
@@ -33,29 +49,57 @@ namespace Nox.Game {
|
||||
Tunneler
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class Stat {
|
||||
private readonly StatType health;
|
||||
public StatType type;
|
||||
public int value;
|
||||
public Stat(StatType health, int value) {
|
||||
this.health = health;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record Attribute {
|
||||
private readonly int values;
|
||||
public AttributeType attribute;
|
||||
public int value;
|
||||
public Attribute(AttributeType attributeType, int values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class EntityAttributes {
|
||||
public int might;
|
||||
public int reflex;
|
||||
public int knowledge;
|
||||
public int perception;
|
||||
public Attribute[] attributes = {
|
||||
new(AttributeType.Might, 1),
|
||||
new(AttributeType.Reflex, 1),
|
||||
new(AttributeType.Knowledge, 1),
|
||||
new(AttributeType.Perception, 1)
|
||||
};
|
||||
|
||||
public static EntityAttributes operator +(EntityAttributes a, EntityAttributes b) {
|
||||
return new EntityAttributes {
|
||||
might = a.might + b.might,
|
||||
reflex = a.reflex + b.reflex,
|
||||
knowledge = a.knowledge + b.knowledge,
|
||||
perception = a.perception + b.perception
|
||||
attributes = a.attributes
|
||||
.Select(attr => new Attribute(attr.attribute, attr.value + b.attributes
|
||||
.First(attr2 => attr2.attribute == attr.attribute).value))
|
||||
.ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class EntityStats {
|
||||
public int health;
|
||||
public int stamina;
|
||||
public int level;
|
||||
public int experience;
|
||||
public Stat[] stats = {
|
||||
new(StatType.Health, 0),
|
||||
new(StatType.Stamina, 0),
|
||||
new(StatType.Level, 1),
|
||||
new(StatType.Experience, 0)
|
||||
};
|
||||
|
||||
public int GetValue(StatType statType) {
|
||||
return stats.First(stat => stat.type == statType).value;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -65,8 +109,8 @@ namespace Nox.Game {
|
||||
public CharacterRace race;
|
||||
public CharacterClass @class;
|
||||
public CharacterRole role;
|
||||
[SerializeField] EntityAttributes attributes;
|
||||
[SerializeField] EntityStats stats;
|
||||
[SerializeField] private EntityAttributes attributes;
|
||||
[SerializeField] private EntityStats stats;
|
||||
public PerksData perksData = new();
|
||||
public ModifiersData activeModifiers = new();
|
||||
|
||||
@@ -77,15 +121,8 @@ namespace Nox.Game {
|
||||
role = role,
|
||||
race = race,
|
||||
@class = @class,
|
||||
attributes = new EntityAttributes {
|
||||
might = attributes?.might ?? 1,
|
||||
reflex = attributes?.reflex ?? 1,
|
||||
knowledge = attributes?.knowledge ?? 1
|
||||
},
|
||||
stats = new EntityStats {
|
||||
health = stats?.health ?? 1,
|
||||
stamina = stats?.stamina ?? 1
|
||||
},
|
||||
attributes = new EntityAttributes(),
|
||||
stats = new EntityStats(),
|
||||
perksData = new PerksData(),
|
||||
activeModifiers = new ModifiersData()
|
||||
};
|
||||
@@ -100,6 +137,7 @@ namespace Nox.Game {
|
||||
get => displayName;
|
||||
set => displayName = value;
|
||||
}
|
||||
|
||||
public EntityAttributes Attributes {
|
||||
get => attributes;
|
||||
set => attributes = value;
|
||||
|
||||
Reference in New Issue
Block a user