Beispiel #1
0
    // returns the index of the component version of the data in the cache
    public static int GetOrAddDamageIdx(BulletDamageData damageData)
    {
        if (!damageStatsCache.IsCreated)
        {
            damageStatsCache = new NativeList <BulletDamage>(Allocator.Persistent);
        }

        if (!damageIdx.ContainsKey(damageData))
        {
            damageStatsCache.Add(damageData.ToBulletDamage());
            damageIdx.Add(damageData, damageStatsCache.Length - 1);
        }

        return(damageIdx[damageData]);
    }
Beispiel #2
0
 // copies monobehavior data into component data
 public void Convert(Entity entity, EntityManager dstManager,
                     GameObjectConversionSystem conversionSystem)
 {
     // default damage
     if (damageStats == null)
     {
         dstManager.AddComponentData(entity, new BulletDamage {
             damage      = 1,
             pierceCount = 0
         });
     }
     else
     {
         dstManager.AddComponentData(entity, damageStats.ToBulletDamage());
     }
 }