Ejemplo n.º 1
0
    // Lets you convert the editor data representation to the entity optimal runtime representation
    public void Convert(Entity entity, EntityManager dstManager,
                        GameObjectConversionSystem conversionSystem)
    {
        Assert.IsTrue(period > 0);

        // add a TimePassed component
        int timeIdx        = TimePassedUtility.AddDefault(entity, dstManager);
        int volleyCountIdx = TimePassedUtility.AddDefault(entity, dstManager);

        Entity    bulletEnt = conversionSystem.GetPrimaryEntity(bullet);
        AutoShoot shootData = new AutoShoot
        {
            // The referenced prefab will already be converted due to DeclareReferencedPrefabs.
            // so just look up the entity version in the conversion system
            bullet           = bulletEnt,
            startDelay       = startDelay,
            cooldownDuration = cooldownDuration,
            period           = period,
            pattern          = pattern,
            count            = count,

            sourceOffset = new float3(sourceOffset.x, sourceOffset.y, 0),
            numVolleys   = numVolleys,
            angle        = math.radians(angle),
            aimStyle     = aimStyle,
            centerAngle  = math.radians(centerAngle),

            timeIdx        = timeIdx,
            volleyCountIdx = volleyCountIdx,

            moveStatsIdx   = AutoShootUtility.GetOrAddMovementIdx(movementStats),
            damageStatsIdx = AutoShootUtility.GetOrAddDamageIdx(damageStats)
        };

        DynamicBuffer <AutoShootBuffer> buffer = AutoShootUtility.GetOrAddBuffer(entity, dstManager);

        buffer.Add(new AutoShootBuffer {
            val = shootData
        });
    }
Ejemplo n.º 2
0
 protected override void OnDestroy()
 {
     AutoShootUtility.ClearCaches();
 }