private void CreateTestEntities(EntityArchetype attributeArchetype, EntityArchetype attributeModifierArchetype) { var rand = new Random(1); for (var i = 0; i < 100; i++) { var defaultAttributes = new AttributeValues() { BaseValue = new MyPlayerAttributes <uint> { Health = 100, Mana = 10, MaxHealth = 100, MaxMana = 10, Speed = 5 } }; var entity = CreatePlayerEntity(EntityManager, defaultAttributes); for (var j = 0; j < 100; j++) { var context = new GameplayEffectContextComponent() { Source = entity, Target = entity }; var attributesModifier = new MyDurationalGameplayAttributeModifier() { Attribute = (EMyPlayerAttribute)(rand.NextInt(0, 5)), Operator = (EMyAttributeModifierOperator)(rand.NextInt(1, 1)), Value = (half)rand.NextFloat(0, 10) }; CreateGameplayEffect(EntityManager, context, attributesModifier); } } }
public static Entity CreateGameplayEffect(EntityManager dstManager, GameplayEffectContextComponent context, MyDurationalGameplayAttributeModifier modifier) { var attributeModifierArchetype = dstManager.CreateArchetype(typeof(GameplayEffectContextComponent), typeof(MyDurationalGameplayAttributeModifier)); var entity = dstManager.CreateEntity(attributeModifierArchetype); dstManager.SetComponentData(entity, context); dstManager.SetComponentData(entity, modifier); return(entity); }