private void AddBuffsOnSpawn(SmartEntity target) { if (target.TroopComp == null) { return; } string[] spawnApplyBuffs = target.TroopComp.TroopType.SpawnApplyBuffs; if (spawnApplyBuffs == null || spawnApplyBuffs.Length == 0) { return; } ArmorType armorType = BuffController.DeduceArmorType(target); if (armorType == ArmorType.Invalid) { return; } IDataController dataController = Service.Get <IDataController>(); int i = 0; int num = spawnApplyBuffs.Length; while (i < num) { BuffTypeVO buffTypeVO = dataController.Get <BuffTypeVO>(spawnApplyBuffs[i]); if (buffTypeVO.ApplyToSelf) { this.TryAddBuffStack(target, buffTypeVO, armorType, BuffVisualPriority.Default); } i++; } }
public int ApplyHealthFragment(IHealthComponent healthComponent, HealthFragment fragment, List <int> damageMultipliers, int damagePercentage, bool fromSplash, bool fromBeam, SmartEntity source) { if (healthComponent == null || healthComponent.IsDead() || damagePercentage == 0) { return(0); } int health = healthComponent.Health; int num = fragment.Quantity; if (fromSplash) { num = fragment.SplashQuantity; } int rawDamage = num; if (damageMultipliers != null) { int healthMultiplier = this.GetHealthMultiplier(healthComponent, damageMultipliers); num = num * healthMultiplier / 100; } SmartEntity target = (SmartEntity)((ComponentBase)healthComponent).Entity; BuffController buffController = Service.Get <BuffController>(); if (fragment.Type == HealthType.Healing) { buffController.ApplyActiveBuffs(target, BuffModify.HealDefense, ref damagePercentage, 100); } else { buffController.ApplyActiveBuffs(target, BuffModify.Defense, ref damagePercentage, 100); if (fromSplash) { buffController.ApplyActiveBuffs(target, BuffModify.SplashDefense, ref damagePercentage, 100); } } num = IntMath.GetPercent(damagePercentage, num); if (fragment.Type == HealthType.Healing) { healthComponent.Health += num; if (healthComponent.Health > healthComponent.MaxHealth) { healthComponent.Health = healthComponent.MaxHealth; } } else { healthComponent.Health -= num; if (healthComponent.Health <= 0) { healthComponent.Health = 0; } } int num2 = healthComponent.Health - health; EntityHealthChangedData cookie = new EntityHealthChangedData(source, target, num2, rawDamage, fromBeam); Service.Get <EventManager>().SendEvent(EventId.EntityHealthChanged, cookie); this.HandleHealthChange(healthComponent, num2); return(num2); }
private void ApplyBuffFromBullet(Bullet bullet) { SmartEntity target = bullet.Target; ProjectileTypeVO projectileType = bullet.ProjectileType; if (target == null || target.TeamComp == null || projectileType == null) { return; } if (target.HealthComp == null || target.HealthComp.IsDead()) { return; } string[] applyBuffs = projectileType.ApplyBuffs; if (applyBuffs == null || applyBuffs.Length == 0) { return; } ArmorType armorType = BuffController.DeduceArmorType(target); if (armorType == ArmorType.Invalid) { return; } bool flag = bullet.Owner == target; bool flag2 = !flag && bullet.OwnerTeam == target.TeamComp.TeamType; IDataController dataController = Service.Get <IDataController>(); int i = 0; int num = applyBuffs.Length; while (i < num) { BuffTypeVO buffTypeVO = dataController.Get <BuffTypeVO>(applyBuffs[i]); if (flag) { if (buffTypeVO.ApplyToSelf) { goto IL_B9; } } else if (flag2) { if (buffTypeVO.ApplyToAllies) { goto IL_B9; } } else if (buffTypeVO.ApplyToEnemies) { goto IL_B9; } IL_C4: i++; continue; IL_B9: this.TryAddBuffStack(target, buffTypeVO, armorType, BuffVisualPriority.Default); goto IL_C4; } }
public static void AddEquipmentBuffs(List <string> attackerEquipment, List <string> defenderEquipment) { BuffController buffController = Service.BuffController; buffController.ClearEquipmentBuffs(); StaticDataController staticDataController = Service.StaticDataController; if (attackerEquipment != null) { int i = 0; int count = attackerEquipment.Count; while (i < count) { EquipmentVO equipmentVO = staticDataController.Get <EquipmentVO>(attackerEquipment[i]); string[] effectUids = equipmentVO.EffectUids; if (effectUids != null) { int j = 0; int num = effectUids.Length; while (j < num) { EquipmentEffectVO effectVO = staticDataController.Get <EquipmentEffectVO>(effectUids[j]); buffController.AddAttackerEquipmentBuff(effectVO); j++; } } i++; } } if (defenderEquipment != null) { int k = 0; int count2 = defenderEquipment.Count; while (k < count2) { EquipmentVO equipmentVO2 = staticDataController.Get <EquipmentVO>(defenderEquipment[k]); string[] effectUids2 = equipmentVO2.EffectUids; if (effectUids2 != null) { int l = 0; int num2 = effectUids2.Length; while (l < num2) { EquipmentEffectVO effectVO2 = staticDataController.Get <EquipmentEffectVO>(effectUids2[l]); buffController.AddDefenderEquipmentBuff(effectVO2); l++; } } k++; } } }
private void OnRemovingBuff(Buff buff, SmartEntity target) { string vFXAssetForTarget = GameUtils.GetVFXAssetForTarget(buff.BuffType, target); if (!string.IsNullOrEmpty(vFXAssetForTarget) && target.SizeComp != null) { Service.FXManager.StopParticlesAndRemoveAttachedFXFromEntity(target, BuffController.MakeFXAttachmentTag(buff.BuffType.BuffID)); } if (!string.IsNullOrEmpty(buff.BuffType.ShaderName)) { this.RestoreShadersAfterBuff(target); if (this.shaderSwappedBuffs.ContainsKey(target)) { this.shaderSwappedBuffs.Remove(target); } } }
private void AddMaxHealthWarBuff(SmartEntity entity, WarBuffVO warBuffVO) { IDataController dataController = Service.Get <IDataController>(); BuildingComponent buildingComp = entity.BuildingComp; if (buildingComp == null) { return; } bool flag = buildingComp.BuildingType.Type == BuildingType.HQ || buildingComp.BuildingType.Type == BuildingType.Wall; HealthComponent healthComp = entity.HealthComp; if (flag && healthComp != null) { BuffTypeVO buffType = dataController.Get <BuffTypeVO>(warBuffVO.BuildingBuffUid); this.TryAddBuffStack(entity, buffType, BuffController.DeduceArmorType(entity), BuffVisualPriority.SquadWars); } }
private void ApplyBuildingEquipmentBuffs(SmartEntity entity) { if (entity.TeamComp == null || entity.BuildingComp == null) { return; } IDataController dataController = Service.Get <IDataController>(); List <EquipmentEffectVO> equipmentBuffsForTeam = this.GetEquipmentBuffsForTeam(entity.TeamComp.TeamType); int num = (equipmentBuffsForTeam != null) ? equipmentBuffsForTeam.Count : 0; for (int i = 0; i < num; i++) { EquipmentEffectVO equipmentEffectVO = equipmentBuffsForTeam[i]; if (equipmentEffectVO.BuffUids != null && equipmentEffectVO.AffectedBuildingIds != null) { string buildingID = entity.BuildingComp.BuildingType.BuildingID; int j = 0; int num2 = equipmentEffectVO.AffectedBuildingIds.Length; while (j < num2) { if (equipmentEffectVO.AffectedBuildingIds[j] == buildingID) { int k = 0; int num3 = equipmentEffectVO.BuffUids.Length; while (k < num3) { BuffTypeVO buffType = dataController.Get <BuffTypeVO>(equipmentEffectVO.BuffUids[k]); this.TryAddBuffStack(entity, buffType, BuffController.DeduceArmorType(entity), BuffVisualPriority.Equipment); k++; } break; } j++; } } } }
private void OnAddedBuff(Buff buff, SmartEntity target) { bool flag = false; if (target.GameObjectViewComp == null || target.GameObjectViewComp.MainGameObject == null) { flag = true; } string vFXAssetForTarget = GameUtils.GetVFXAssetForTarget(buff.BuffType, target); if (!string.IsNullOrEmpty(vFXAssetForTarget)) { SizeComponent sizeComp = target.SizeComp; if (sizeComp != null) { if (!flag) { int num = (sizeComp.Width > sizeComp.Depth) ? sizeComp.Depth : sizeComp.Width; string assetName = string.Format(vFXAssetForTarget, num); Vector3 offset = BuffController.DeduceBuffAssetOffset(buff.BuffType, target); bool pinToCenterOfMass = buff.BuffType.OffsetType == BuffAssetOffset.Top; Service.FXManager.CreateAndAttachFXToEntity(target, assetName, BuffController.MakeFXAttachmentTag(buff.BuffType.BuffID), null, pinToCenterOfMass, offset, true); } else { this.AddEntityToRecheckVisualAfterLoadList(target, buff); } } } if (!string.IsNullOrEmpty(buff.BuffType.ShaderName)) { bool flag2 = false; if (this.shaderSwappedBuffs.ContainsKey(target)) { Buff buff2 = this.shaderSwappedBuffs[target]; if (buff2.VisualPriority <= buff.VisualPriority) { this.shaderSwappedBuffs[target] = buff; flag2 = true; } } else { this.shaderSwappedBuffs.Add(target, buff); flag2 = true; } if (!flag2) { return; } if (!flag) { Shader shader = Service.AssetManager.Shaders.GetShader(this.shaderSwappedBuffs[target].BuffType.ShaderName); if (shader != null) { this.SwapShadersForAppliedBuff(target, shader); } } else { this.AddEntityToRecheckVisualAfterLoadList(target, this.shaderSwappedBuffs[target]); } } }
public unsafe static long $Invoke28(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(BuffController.MakeFXAttachmentTag(Marshal.PtrToStringUni(*(IntPtr *)args)))); }
public unsafe static long $Invoke24(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(BuffController.DeduceBuffAssetOffset((BuffTypeVO)GCHandledObjects.GCHandleToObject(*args), (SmartEntity)GCHandledObjects.GCHandleToObject(args[1])))); }
public unsafe static long $Invoke23(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(BuffController.DeduceArmorType((SmartEntity)GCHandledObjects.GCHandleToObject(*args)))); }