Added a bunch of utilities and modfief the character data structue

This commit is contained in:
Sebastian Bularca
2026-03-29 18:31:03 +02:00
parent 4a9c00212a
commit ee97b2fec3
110 changed files with 6752 additions and 169 deletions

View File

@@ -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;