Example #1
0
        /// <summary>
        /// Spawn a weapon based on the approprate weapon ID
        /// </summary>
        /// <param name="projectileID"></param>
        /// <param name="spawnAmount"></param>
        public static Entity CreateWeapon(int weaponID, float3 spawnPos, quaternion spawnRot, uint ownerID, float muzzleOffset)
        {
            // -------------------
            // create visuals here
            // Make new method ---
            // -------------------


#if UNITY_EDITOR
            if (debugGroupID > 65000)
            {
                debugGroupID = 0;
            }
            debugGroupID     += 1;
            debugIndividualID = 0;
#endif

            Entity weaponEntity;

            // create the entity to clone from
            weaponEntity = EntityManager.CreateEntity(Archetype);

            SetComponents(weaponEntity, weaponID, spawnPos, spawnRot, Parameters.GetWeaponDataByID(weaponID), ownerID, muzzleOffset);

            return(weaponEntity);
        }
Example #2
0
        protected override void OnUpdate()
        {
            Entities.WithAll <EquippedTag>().ForEach((Entity entity, ref Weapon weapon, ref BurstFire burst, ref WeaponState state, ref ShootFrom shootFrom, ref OwnerID owner) =>
            {
                // if we are TRYING to and CAN burst
                if (state.IsShooting && burst.Value < 0)
                {
                    ProjectileFactory.CreateProjectiles(Parameters.GetWeaponDataByID(weapon.ID).projectileId, shootFrom.Position, shootFrom.Rotation, owner.Value);

                    // Restart timer and increase our burst count
                    burst.Value  = burst.ResetValue;
                    burst.Count += 1;

                    // If we are done bursting now, stop bursting
                    if (burst.Count >= burst.MaxCount)
                    {
                        state.IsShooting = false;
                    }

                    // TODO: Setup actioning on it
                }
            });
        }