Example #1
0
        virtual public void FirePrimary(AttackSource src)
        {
            if (_primaryPrjDef == null)
            {
                return;
            }
            Transform t = _launchNode.GlobalTransform;

            SpawnPatterns.FillPattern(t, _primaryPatternDef, _launchTransforms);

            for (int i = 0; i < _primaryPatternDef.count; ++i)
            {
                Transform       launchT = _launchTransforms[i];
                PointProjectile prj     = Main.i.factory.SpawnProjectile(_primaryPrjDef.prefabPath);
                if (prj == null)
                {
                    Console.WriteLine($"Got no prj instance"); return;
                }
                prj.Launch(launchT.origin, -launchT.basis.z, _primaryPrjDef, src.ignoreBody, src.team);
            }
            // check for reload
            //_roundsLoaded--;
            //if (_roundsLoaded <= 0)
            //{
            //    _tick = _weaponDef.magazineReloadTime;
            //    _isReloading = true;
            //}
            //else
            //{
            _tick = _weaponDef.primaryRefireTime;
            //}
            _lastTickMax = _tick;
        }
Example #2
0
 virtual protected void CheckTriggers(bool primaryOn, bool secondaryOn, AttackSource src)
 {
     if (primaryOn && _primaryPrjDef != null)
     {
         FirePrimary(src);
     }
     //else if (secondaryOn && _secondaryPrjDef != null)
     //{ FireSecondary(src); }
 }
Example #3
0
        virtual public void FireSecondary(AttackSource src)
        {
            //if (_secondaryPrjDef == null) { return; }

            /*
             * int numShots = _roundsLoaded;
             * _roundsLoaded = 0;
             * _isReloading = true;
             * _tick = _weaponDef.magazineReloadTime;
             * int numPellets = _weaponDef.primaryPrjCount * numShots;
             *
             * Transform t = _launchNode.GlobalTransform;
             * // fill all angles, although we may be using less anyway.
             * ZqfGodotUtils.FillSpreadAngles(t, _secondarySpread, 2000, 1200);
             * for (int i = 0; i < numPellets; ++i)
             * {
             *  PointProjectile prj = Main.i.factory.SpawnProjectile(_secondaryPrjDef.prefabPath);
             *  if (prj == null) { Console.WriteLine($"Got no prj instance"); return; }
             *  prj.Launch(t.origin, _secondarySpread[i], _secondaryPrjDef, src.ignoreBody, src.team);
             *  _tick = _weaponDef.secondaryRefireTime;
             * }
             */
        }
Example #4
0
        virtual public void FireSecondary(AttackSource src)
        {
            if (_secondaryPrjDef == null)
            {
                return;
            }
            Transform t = _launchNode.GlobalTransform;

            ZqfGodotUtils.FillSpreadAngles(
                t, _secondarySpread, _weaponDef.secondarySpread.x, _weaponDef.secondarySpread.y);
            for (int i = 0; i < _secondarySpread.Count; ++i)
            {
                PointProjectile prj = Main.i.factory.SpawnProjectile(_secondaryPrjDef.prefabPath);
                if (prj == null)
                {
                    Console.WriteLine($"Got no prj instance"); return;
                }
                //prj.Launch(_launchNode.GlobalTransform, _primaryPrjDef, _ignoreBody);

                prj.Launch(t.origin, _secondarySpread[i], _secondaryPrjDef, src.ignoreBody, src.team);
                _tick        = _weaponDef.secondaryRefireTime;
                _lastTickMax = _tick;
            }
        }
Example #5
0
 virtual protected void CommonTick(float delta, bool primaryOn, bool secondaryOn, AttackSource src)
 {
     if (_tick > 0)
     {
         _tick -= delta;
     }
     else
     {
         // check for reloading finish
         if (_isReloading == true)
         {
             _isReloading  = false;
             _roundsLoaded = _weaponDef.magazineSize;
         }
         CheckTriggers(primaryOn, secondaryOn, src);
     }
 }