private void AddUnitFields(TileInfoGroupUI group, BaseUnit unit) { Damageable d = unit.GetPropertyOfType <Damageable>() as Damageable; Supplyable s = unit.GetPropertyOfType <Supplyable>() as Supplyable; CanFire f = unit.GetAbilitieOfType <CanFire>() as CanFire; int health = 0; int ammo = 0; int supply = 0; if (d) { health = d.Health; } if (f) { ammo = f.Settings.Ammo; } if (s) { supply = s.Supply; } group.UpdateOrAddField(_iconRef.HeartIcon, health.ToString(), 0); group.UpdateOrAddField(_iconRef.AmmoIcon, ammo.ToString(), 1); group.UpdateOrAddField(_iconRef.SupplyIcon, supply.ToString(), 2); }
//Hook by replacing method body of ModuleScoop.ControlInputManual() internal static void ControlInputManual(ModuleWeapon module, int aim, int fire) { bool shouldFireDefault = (fire != 0) && (Time.timeScale != 0f); var shouldFireEvent = new CanFireEvent <ModuleWeapon>(module, shouldFireDefault); CanFire?.Invoke(shouldFireEvent); bool performBehaviour = true; if (shouldFireEvent.Fire) { var fireEvent = new FireEvent <ModuleWeapon>(module); OnFire?.Invoke(fireEvent); performBehaviour = fireEvent.PerformVanillaBehaviour; #warning Remove duplicate versions of this } if (performBehaviour) { module.AimControl = aim; module.FireControl = shouldFireEvent.Fire; module.m_TargetPosition = Vector3.zero; if (module.FireControl && module.block.tank && module.block.tank.beam.IsActive && !Mode <ModeMain> .inst.TutorialLockBeam) { module.block.tank.beam.EnableBeam(false, false); } } }
//Hook by replacing method body of ModuleScoop.ControlInput() internal static void ControlInput(ModuleScoop module, int aim, int fire) { bool shouldFireDefault = (fire != 0); var shouldFireEvent = new CanFireEvent <ModuleScoop>(module, shouldFireDefault); CanFire?.Invoke(shouldFireEvent); bool performBehaviour = true; if (shouldFireEvent.Fire) { var fireEvent = new FireEvent <ModuleScoop>(module); OnFire?.Invoke(fireEvent); performBehaviour = fireEvent.PerformVanillaBehaviour; #warning Remove duplicate versions of this } if (performBehaviour) { /*if (module.actuator.isPlaying) * { * return; * } * if (!module.m_Lifted && shouldFireEvent.Fire) * { * module.actuator.Play(module.m_LiftAnim.name); * module.m_Lifted = true; * return; * } * if (module.m_Lifted && (!shouldFireEvent.Fire || (module.m_UpAndDownMode && shouldFireEvent.Fire))) * { * module.actuator.Play(module.m_DropAnim.name); * module.m_Lifted = false; * }*/ } }
public bool PerformCanFire() { var canFire = true; OnCanFire(ref canFire); CanFire?.Invoke(this, ref canFire); return(canFire); }
FireState(CanFire cf, Selection selection, PlayerInputState iS, MapEntetiesManager entetiesManager) { _selection = selection; _fireComponent = cf; _entetiesManager = entetiesManager; iS.IsCancelAction = Cancel; iS.IsConfirmedAction = Confirm; }
public void Confirm() { //Get references BaseUnit other = _entetiesManager.GetEntitieOfType <BaseUnit>(_selection.Position) as BaseUnit; Damageable dThis = _fireComponent.Unit.GetPropertyOfType <Damageable>() as Damageable; CanFire fThis = _fireComponent; Damageable dOther = other.GetPropertyOfType <Damageable>() as Damageable; CanFire fOther = other.GetAbilitieOfType <CanFire>() as CanFire; if (!(fThis && dOther)) { Debug.LogWarning("Cant attck because one of units doesnt have necessary components"); return; } // Calclulate damage int baseDamade = _fireComponent.Settings.DamageToBaseUnitTypeDict[fOther.Settings.Type].BaseDamage; float damagePercent = DamageCalculator.OriginalFormula( baseDamade, dThis.Health, 0, dOther.Health ); dOther.ModifyHealth(-(int)Mathf.Floor(damagePercent / 10)); //Attack back if can if (fOther) { baseDamade = fOther.Settings.DamageToBaseUnitTypeDict[fThis.Settings.Type].BaseDamage; damagePercent = DamageCalculator.OriginalFormula( baseDamade, dOther.Health, 0, dThis.Health ); dThis.ModifyHealth(-(int)Mathf.Floor(damagePercent / 10)); } fThis.GetComponent <BaseUnit>().ChangeState(UnitStates.Wait); }
//Hook by replacing method body of ModuleDrill.ControlInput() internal static void ControlInput(ModuleDrill module, int aim, int fire) { bool shouldFireDefault = (fire != 0); var shouldFireEvent = new CanFireEvent <ModuleDrill>(module, shouldFireDefault); CanFire?.Invoke(shouldFireEvent); bool performBehaviour = true; if (shouldFireEvent.Fire) { var fireEvent = new FireEvent <ModuleDrill>(module); OnFire?.Invoke(fireEvent); performBehaviour = fireEvent.PerformVanillaBehaviour; } if (performBehaviour) { module.m_Spinning = shouldFireEvent.Fire; } }
//Hook by replacing method body of ModuleHammer.ControlInput() internal static void ControlInput(ModuleHammer module, int aim, int fire) { bool shouldFireDefault = (fire != 0); var shouldFireEvent = new CanFireEvent <ModuleHammer>(module, shouldFireDefault); CanFire?.Invoke(shouldFireEvent); bool performBehaviour = true; if (shouldFireEvent.Fire) { var fireEvent = new FireEvent <ModuleHammer>(module); OnFire?.Invoke(fireEvent); performBehaviour = fireEvent.PerformVanillaBehaviour; #warning Remove duplicate versions of this } if (performBehaviour) { //module.state.enabled = shouldFireEvent.Fire; } }
public List <TileEntity> GetAllEnemiesInRange(BaseUnit u, CanFire f) { return(GetAllEnemiesInRange(u.Position, f.Settings.Range, u.Team)); }