- Edited
I am creating a solution where player could pick up items that give different bonuses.
for example
item 1 gives +1 max HP
item 2 gives +3 max HP
item 3 gives -10 max HP
...
Each item in game is represented by a resource, that could be simplified as:
public partial class Mod : Resource
{
[Export]
public string Id { get; set; } = "default name"; // name
[Export]
//public Resource[] Effects { get; set; } = new Resource[0];
public Effect[] Effects { get; set; } = new Effect[0];
}
The effect class is represented also by a resource that contains a modification key (which stat of the user it affects) and a value (by how much it affects the stat):
public partial class Effect : Resource
{
[Export]
public EffectTypeEnum Type { get; set; }
[Export]
public int Value { get; set; } = 1;
}
public enum EffectTypeEnum
{
StatHP,
StatArmor,
StatRangedDamage,
StatCritChance,
}
what I would like to achieve is to be able to add/stack effects onto the item in the editor, however whenever I add a new item into array - it has no properties of the Effect
:
see that I cannot set any of the properties of the Effect
resource after adding new elements..
the solution that actually worked is to use this public Resource[] Effects { get; set; } = new Resource[0];
line instead, then create a new Resource
(s) of type Effect
and dragging the resource to an array:
in the example above I create 3 effect resources, each modifies the HP stat to some extent.
Now, this is the problem I would like to solve! Given that I have hundreds of items in game (lets be optimistic) and each item modifies HP stat to a different value - I don't want to create 100 resources that modify HP stat to a different value! Ideally I would like to just add an effect to an array as in attempt nr.1 and assign it the magnitude by which the value of a stat must be affected. Is there a way to accomplish it? Or is this a limitation of a Godot?
Ideas or solutions are appreciated
In my example I am using C# and a latest godot 4.0x.