private void StartWaitingStateIfPossible(Entity weapon)
 {
     if (InputManager.CheckAction(ShotActions.SHOT))
     {
         StateUtils.SwitchEntityState <ShaftWaitingStateComponent>(weapon, this.weaponStates);
     }
 }
 private void MakeQuickShot(Entity weapon)
 {
     StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon, this.weaponStates);
     if (weapon.HasComponent <ShootableComponent>())
     {
         base.ScheduleEvent <BeforeShotEvent>(weapon);
         base.ScheduleEvent <ShotPrepareEvent>(weapon);
     }
 }
 private void MakeAimingShot(Entity weapon, Vector3 workingDir)
 {
     StateUtils.SwitchEntityState <ShaftAimingWorkFinishStateComponent>(weapon, this.weaponStates);
     if (weapon.HasComponent <ShootableComponent>())
     {
         base.ScheduleEvent <BeforeShotEvent>(weapon);
         base.ScheduleEvent(new ShaftAimingShotPrepareEvent(workingDir), weapon);
     }
 }
Example #4
0
        private void AddOrChangeWeaponBlockedComponent(Entity weapon, RaycastHit hitInfo)
        {
            WeaponBlockedComponent component = !weapon.HasComponent <WeaponBlockedComponent>() ? ((WeaponBlockedComponent)weapon.CreateNewComponentInstance(typeof(WeaponBlockedComponent))) : weapon.GetComponent <WeaponBlockedComponent>();

            component.BlockPoint      = PhysicsUtil.GetPulledHitPoint(hitInfo);
            component.BlockGameObject = hitInfo.collider.gameObject;
            component.BlockNormal     = hitInfo.normal;
            StateUtils.SwitchEntityState(weapon, component, this.weaponStates);
        }
        private bool CheckHandleWeaponIntersectionStatus(Entity weapon)
        {
            bool flag = weapon.HasComponent <WeaponUndergroundComponent>();

            if (flag)
            {
                StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon, this.weaponStates);
            }
            return(flag);
        }
 public void CheckWorkFinishState(TimeUpdateEvent evt, ShaftAimingWorkFinishWeaponControllerNode weapon)
 {
     if (weapon.shaftAimingWorkFinishState.FinishTimer < weapon.shaftStateConfig.FinishToIdleTransitionTimeSec)
     {
         weapon.shaftAimingWorkFinishState.FinishTimer += evt.DeltaTime;
     }
     else
     {
         StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon.Entity, this.weaponStates);
     }
 }
 private void StartWorkActivationStateIfPossible(ShaftWaitingWeaponControllerNode weapon, float dt)
 {
     if (!weapon.Entity.HasComponent <WeaponUndergroundComponent>())
     {
         if (weapon.shaftWaitingState.WaitingTimer < weapon.shaftStateConfig.WaitingToActivationTransitionTimeSec)
         {
             weapon.shaftWaitingState.WaitingTimer += dt;
         }
         else if (weapon.weaponEnergy.Energy >= 1f)
         {
             StateUtils.SwitchEntityState <ShaftAimingWorkActivationStateComponent>(weapon.Entity, this.weaponStates);
         }
     }
 }
        private void StartQuickShotIfPossible(ShaftWaitingWeaponControllerNode weapon)
        {
            CooldownTimerComponent cooldownTimer = weapon.cooldownTimer;

            if (weapon.weaponEnergy.Energy < weapon.shaftEnergy.UnloadEnergyPerQuickShot)
            {
                StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon.Entity, this.weaponStates);
            }
            else if (cooldownTimer.CooldownTimerSec > 0f)
            {
                StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon.Entity, this.weaponStates);
            }
            else
            {
                this.MakeQuickShot(weapon.Entity);
            }
        }
Example #9
0
 private void ValidateShot(Entity weapon, MuzzleLogicAccessor muzzlePoint, TankNode tank, ShotValidateComponent shotValidate)
 {
     if (this.IsWeaponUnderground(muzzlePoint, shotValidate.UnderGroundValidateMask, tank, shotValidate.RaycastExclusionGameObjects))
     {
         StateUtils.SwitchEntityState <WeaponUndergroundComponent>(weapon, this.weaponStates);
     }
     else
     {
         RaycastHit hit;
         if (this.IsWeaponBlocked(muzzlePoint, shotValidate.BlockValidateMask, out hit, shotValidate.RaycastExclusionGameObjects))
         {
             this.AddOrChangeWeaponBlockedComponent(weapon, hit);
         }
         else
         {
             StateUtils.SwitchEntityState <WeaponUnblockedComponent>(weapon, this.weaponStates);
         }
     }
 }
 public void CheckWorkActivationState(TimeUpdateEvent evt, ShaftAimingWorkActivationWeaponControllerNode weapon)
 {
     if (!this.CheckHandleWeaponIntersectionStatus(weapon.Entity))
     {
         if (!InputManager.CheckAction(ShotActions.SHOT))
         {
             this.MakeQuickShot(weapon.Entity);
         }
         else if (weapon.shaftAimingWorkActivationState.ActivationTimer < weapon.shaftStateConfig.ActivationToWorkingTransitionTimeSec)
         {
             weapon.shaftAimingWorkActivationState.ActivationTimer += evt.DeltaTime;
         }
         else
         {
             MuzzleLogicAccessor accessor = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);
             ShaftAimingWorkingStateComponent component = new ShaftAimingWorkingStateComponent {
                 InitialEnergy    = weapon.weaponEnergy.Energy,
                 WorkingDirection = accessor.GetFireDirectionWorld()
             };
             StateUtils.SwitchEntityState(weapon.Entity, component, this.weaponStates);
         }
     }
 }
 public void CheckWeaponStateOnInactiveTank(NodeRemoveEvent evt, SelfActiveTankNode tank, [JoinByTank] ShaftWeaponNode weapon)
 {
     StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon.Entity, this.weaponStates);
 }
 public void InitIdleState(NodeAddedEvent evt, ShaftWeaponNode weapon)
 {
     StateUtils.SwitchEntityState <ShaftIdleStateComponent>(weapon.Entity, this.weaponStates);
 }
Example #13
0
 public void Init(NodeAddedEvent evt, ActiveTankNode activeTank, [JoinByTank, Context] WeaponNode weaponNode)
 {
     StateUtils.SwitchEntityState <WeaponUnblockedComponent>(weaponNode.Entity, this.weaponStates);
 }