private static void ResolveUseEffects(Entity user, Entity usable, EncounterState state) { // We keep this logic here instead of in the component itself because the component should have only state data. That said // we shouldn't keep it, like, *here* here, 'least not indefinitely. var useEffectHeal = usable.GetComponent <UseEffectHealComponent>(); if (useEffectHeal != null) { var restored = user.GetComponent <DefenderComponent>().RestoreHP(useEffectHeal.Healpower); state.LogMessage(string.Format("{0} restored {1} HP to {2}!", usable.EntityName, restored, user.EntityName)); } var useEffectAddIntel = usable.GetComponent <UseEffectAddIntelComponent>(); if (useEffectAddIntel != null) { // Kinda funny because player's the only one for which this effect is meaningful so we just grab player it's fiiiiiine state.Player.GetComponent <PlayerComponent>().RegisterIntel(useEffectAddIntel.TargetDungeonLevel); state.LogMessage(string.Format("Discovered intel for [b]sector {0}[/b]!", useEffectAddIntel.TargetDungeonLevel)); } var useEffectBoostPower = usable.GetComponent <UseEffectBoostPowerComponent>(); if (useEffectBoostPower != null) { state.LogMessage(String.Format("Attack power boosted by {0} for duration {1}!", useEffectBoostPower.BoostPower, useEffectBoostPower.Duration)); var statusEffectTracker = user.GetComponent <StatusEffectTrackerComponent>(); statusEffectTracker.AddEffect(new StatusEffectTimedPowerBoost( boostPower: useEffectBoostPower.BoostPower, startTick: state.CurrentTick, endTick: state.CurrentTick + useEffectBoostPower.Duration )); } var useEffectBoostSpeed = usable.GetComponent <UseEffectBoostSpeedComponent>(); if (useEffectBoostSpeed != null) { state.LogMessage(String.Format("Speed boosted by {0} for duration {1}!", useEffectBoostSpeed.BoostPower, useEffectBoostSpeed.Duration)); var statusEffectTracker = user.GetComponent <StatusEffectTrackerComponent>(); statusEffectTracker.AddEffect(new StatusEffectTimedSpeedBoost( boostPower: useEffectBoostSpeed.BoostPower, startTick: state.CurrentTick, endTick: state.CurrentTick + useEffectBoostSpeed.Duration )); } var useEffectEMP = usable.GetComponent <UseEffectEMPComponent>(); if (useEffectEMP != null) { state.LogMessage(String.Format("EMP detonated in radius {0} - disables {1} turns!", useEffectEMP.Radius, useEffectEMP.DisableTurns)); var userPosition = user.GetComponent <PositionComponent>().EncounterPosition; for (int x = userPosition.X - useEffectEMP.Radius; x <= userPosition.X + useEffectEMP.Radius; x++) { for (int y = userPosition.Y - useEffectEMP.Radius; y <= userPosition.Y + useEffectEMP.Radius; y++) { var distance = userPosition.DistanceTo(x, y); if (distance <= useEffectEMP.Radius && state.IsInBounds(x, y)) { var entitiesAtPosition = state.EntitiesAtPosition(x, y); foreach (var entity in entitiesAtPosition) { var speedComponent = entity.GetComponent <SpeedComponent>(); var statusTracker = entity.GetComponent <StatusEffectTrackerComponent>(); if (entity != user && speedComponent != null && statusTracker != null) { var disableTicks = speedComponent.Speed * useEffectEMP.DisableTurns; statusTracker.AddEffect(new StatusEffectTimedDisable(state.CurrentTick, state.CurrentTick + disableTicks)); state.LogMessage(String.Format("{0} was disabled for {1} ticks!", entity.EntityName, disableTicks)); } } } } } } }