示例#1
0
        internal override void ActionCommand(DateTime atDateTime)
        {
            if (!IsRunning)
            {
                var fcState = _fireControlComponent.GetAbilityState <FireControlAbilityState>();
                if (IsFiring == FireModes.OpenFire)
                {
                    fcState.IsEngaging = true;
                    DateTime dateTimeNow        = _entityCommanding.Manager.ManagerSubpulses.StarSysDateTime;
                    GenericFiringWeaponsDB blob = _entityCommanding.GetDataBlob <GenericFiringWeaponsDB>();
                    if (blob == null)
                    {
                        blob = new GenericFiringWeaponsDB(fcState.GetChildrenInstances());
                        _entityCommanding.SetDataBlob(blob);
                    }
                    else
                    {
                        blob.AddWeapons(fcState.GetChildrenInstances());
                    }

                    //StaticRefLib.ProcessorManager.RunInstanceProcessOnEntity(nameof(WeaponProcessor),_entityCommanding,  dateTimeNow);
                }
                else if (IsFiring == FireModes.CeaseFire)
                {
                    fcState.IsEngaging = false;
                    GenericFiringWeaponsDB blob = _entityCommanding.GetDataBlob <GenericFiringWeaponsDB>();
                }
                IsRunning = true;
            }
        }
示例#2
0
        public static void ProcessWeaponFire(GenericFiringWeaponsDB firingWeapons)
        {
            for (int i = 0; i < firingWeapons.WpnIDs.Length; i++)
            {
                int shotsFired = firingWeapons.ShotsFiredThisTick[i];
                firingWeapons.ShotsFiredThisTick[i] = 0;
                if (shotsFired > 0)
                {
                    var lunchEnt = firingWeapons.OwningEntity;
                    var tgtEnt   = firingWeapons.FireControlStates[i].Target;
                    var force    = firingWeapons.LaunchForces[i];

                    firingWeapons.FireInstructions[i].FireWeapon(lunchEnt, tgtEnt, shotsFired);
                }
            }
        }
示例#3
0
        /// <summary>
        /// updates the non hot process data (which is what the ui reads) for reload state.
        /// this feels a bit janky, would it be better to just include the weapon states in the hot datablob? (GenericFiringWeaponsDB)
        /// </summary>
        /// <param name="reloadingWeapons"></param>
        public static void UpdateReloadState(GenericFiringWeaponsDB reloadingWeapons)
        {
            var entity = reloadingWeapons.OwningEntity;

            if (entity.GetDataBlob <ComponentInstancesDB>().TryGetStates <WeaponState>(out var wpnStates))
            {
                for (int i = 0; i < reloadingWeapons.WpnIDs.Length; i++)
                {
                    foreach (WeaponState wpnState in wpnStates)
                    {
                        if (wpnState.ID == reloadingWeapons.WpnIDs[i])
                        {
                            wpnState.InternalMagCurAmount = reloadingWeapons.InternalMagQty[i];
                        }
                    }
                }
            }
        }
示例#4
0
 public static void ProcessReloadWeapon(GenericFiringWeaponsDB reloadingWeapons)
 {
     for (int i = 0; i < reloadingWeapons.WpnIDs.Length; i++)
     {
         if (reloadingWeapons.WpnIDs[i] == Guid.Empty)
         {
             continue;//just incase a weapon gets removed from the array and leaves an empty spot.
         }
         if (reloadingWeapons.InternalMagQty[i] < reloadingWeapons.InternalMagSizes[i])
         {
             reloadingWeapons.InternalMagQty[i] += Math.Min(reloadingWeapons.ReloadAmountsPerSec[i], reloadingWeapons.InternalMagSizes[i]);
         }
         //if it's reloaded enough to fire at least one shot.
         if (reloadingWeapons.InternalMagQty[i] >= reloadingWeapons.AmountPerShot[i] * reloadingWeapons.MinShotsPerfire[i])
         {
             //if this is not attached to a fire control,
             if (reloadingWeapons.FireControlStates[i] == null)
             {   //and is fully reloaded.
                 if (reloadingWeapons.InternalMagQty[i] >= reloadingWeapons.InternalMagSizes[i])
                 {
                     reloadingWeapons.RemoveWeapons(reloadingWeapons.WpnIDs[i]);//remove it from being processed every second.
                 }
             }
             //if it *is* attached to a firecontrol, and is firing.
             else if (reloadingWeapons.FireControlStates[i].IsEngaging)
             { //then fire
                 int numshots = reloadingWeapons.InternalMagQty[i] / reloadingWeapons.AmountPerShot[i];
                 reloadingWeapons.ShotsFiredThisTick[i] = numshots;
                 int depleteinternalMag = numshots * reloadingWeapons.AmountPerShot[i];
                 reloadingWeapons.InternalMagQty[i] -= depleteinternalMag;
             }
             // if it's attached to firecontrol, but not firing and is fully reloaded
             else if (reloadingWeapons.InternalMagQty[i] >= reloadingWeapons.InternalMagSizes[i])
             {   //remove it from being processed every second.
                 reloadingWeapons.RemoveWeapons(reloadingWeapons.WpnIDs[i]);
             }
         }
     }
 }