public bool TakeCash(int num, bool notifyLowFunds = false) { if (Cash + Resources < num) { if (notifyLowFunds && Game.RunTime > lastNotificationTime + Info.InsufficientFundsNotificationInterval) { lastNotificationTime = Game.RunTime; Game.Sound.PlayNotification(owner.World.Map.Rules, owner, "Speech", Info.InsufficientFundsNotification, owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(Info.InsufficientFundsTextNotification, owner); } return(false); } // Spend ore before cash Resources -= num; Spent += num; if (Resources < 0) { Cash += Resources; Resources = 0; } return(true); }
public void ResolveOrder(Actor self, Order order) { if (!Enabled) { return; } switch (order.OrderString) { case "Taunt": { if (self.World.LocalPlayer != null) { var rules = self.World.Map.Rules; if (rules.Notifications["taunts"].NotificationsPools.Value.ContainsKey(order.TargetString)) { Game.Sound.PlayNotification(rules, self.World.LocalPlayer, "Taunts", order.TargetString, self.Owner.Faction.InternalName); } else { TextNotificationsManager.Debug("{0} is not a valid taunt.", order.TargetString); } } break; } } }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet <TargetableType> types) { if (!info.Types.Overlaps(types)) { return; } if (info.InfiltratedNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName); } if (info.InfiltrationNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner); TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner); infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary { new OwnerInit(infiltrator.Owner) })); }
public Actor[] ActivateParatroopers(WPos target, int facing = -1) { TextNotificationsManager.Debug("SendParatroopersFrom is deprecated. Use TargetParatroopers instead."); var actors = pp.SendParatroopers(Self, target, facing == -1 ? (WAngle?)null : WAngle.FromFacing(facing)); return(actors.Aircraft); }
void Delete(string savePath) { try { File.Delete(savePath); } catch (Exception ex) { TextNotificationsManager.Debug("Failed to delete save file '{0}'. See the logs for details.", savePath); Log.Write("debug", ex.ToString()); return; } if (savePath == selectedSave) { Select(null); } var item = gameList.Children .Select(c => c as ScrollItemWidget) .FirstOrDefault(c => c.ItemKey == savePath); gameList.RemoveChild(item); games.Remove(savePath); }
public override bool Tick(Actor self) { var sellValue = self.GetSellValue(); // Cast to long to avoid overflow when multiplying by the health var hp = health != null ? (long)health.HP : 1L; var maxHP = health != null ? (long)health.MaxHP : 1L; var refund = (int)((sellValue * sellableInfo.RefundPercent * hp) / (100 * maxHP)); refund = playerResources.ChangeCash(refund); foreach (var ns in self.TraitsImplementing <INotifySold>()) { ns.Sold(self); } if (showTicks && refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer)) { self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color, FloatingText.FormatCashTick(refund), 30))); } Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", sellableInfo.Notification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(sellableInfo.TextNotification, self.Owner); self.Dispose(); return(false); }
void OnCrushInner(Actor crusher, int flagTeam, int crusherTeam) { if (Collected) { return; } self.World.Remove(self); Collected = true; var carriesFlag = crusher.TraitOrDefault <CarriesFlag>(); if (carriesFlag != null) { if (self.Owner == crusher.Owner || (flagTeam != 0 && flagTeam == crusherTeam)) { TextNotificationsManager.AddSystemLine("Battlefield Control", crusher.Owner.PlayerName + " has taken their flag."); } else { TextNotificationsManager.AddSystemLine("Battlefield Control", crusher.Owner.PlayerName + " has taken flag of " + (flagTeam == 0 || !spawner.TeamSpawns ? self.Owner.PlayerName : "Team " + flagTeam) + "."); } carriesFlag.GrantCondition(crusher); carriesFlag.TakeFlag(crusher, self); } }
public void OnDiscovered(Actor self, Player discoverer, bool playNotification) { if (!playNotification || discoverer != self.World.RenderPlayer) { return; } // Hack to disable notifications for neutral actors so some custom maps don't need fixing // At this point it's either neutral or an enemy if (!Info.AnnounceNeutrals && !self.AppearsHostileTo(discoverer.PlayerActor)) { return; } // Audio notification if (discoverer != null && !string.IsNullOrEmpty(Info.Notification)) { Game.Sound.PlayNotification(self.World.Map.Rules, discoverer, "Speech", Info.Notification, discoverer.Faction.InternalName); } if (discoverer != null) { TextNotificationsManager.AddTransientLine(Info.TextNotification, discoverer); } // Radar notification if (Info.PingRadar) { radarPings.Value?.Add(() => true, self.CenterPosition, Color.Red, 50); } }
public override void Activate(Actor collector) { TextNotificationsManager.AddSystemLine("Battlefield Control", collector.Owner.PlayerName + " has taken the armageddon crate!"); if (!string.IsNullOrEmpty(Info.Notification)) { foreach (var player in self.World.Players) { // Don't play it twice to the collector, it is already handled in base.Activate() if (collector.Owner == player) { continue; } Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", Info.Notification, collector.Owner.Faction.InternalName); } } var actors = self.World.Actors.Where(a => a.Owner.Playable && a.TraitOrDefault <SSMultiplierManager>() != null); foreach (var actor in actors) { actor.Kill(self, info.DeathTypes); } base.Activate(collector); }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet <TargetableType> types) { if (!info.Types.Overlaps(types)) { return; } if (info.InfiltratedNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName); } if (info.InfiltrationNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner); TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner); var manager = self.Owner.PlayerActor.Trait <SupportPowerManager>(); var powers = manager.GetPowersForActor(self).Where(sp => !sp.Disabled); foreach (var power in powers) { power.ResetTimer(); } }
public virtual void Target() { if (!Ready) { return; } var power = Instances.FirstOrDefault(i => !i.IsTraitPaused); if (power == null) { return; } if (!HasSufficientFunds(power)) { return; } Game.Sound.PlayToPlayer(SoundType.UI, Manager.Self.Owner, Info.SelectTargetSound); Game.Sound.PlayNotification(power.Self.World.Map.Rules, power.Self.Owner, "Speech", Info.SelectTargetSpeechNotification, power.Self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(Info.SelectTargetTextNotification, power.Self.Owner); power.SelectTarget(power.Self, Key, Manager); }
void SetCondition(Actor self, bool granted) { if (granted && conditionToken == Actor.InvalidConditionToken) { conditionToken = self.GrantCondition(Info.Condition); if (Info.EnabledSound != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.EnabledSound, self.Owner.Faction.InternalName); } if (Info.EnabledSpeech != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.EnabledSpeech, self.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(Info.EnabledTextNotification, self.Owner); } else if (!granted && conditionToken != Actor.InvalidConditionToken) { conditionToken = self.RevokeCondition(conditionToken); if (Info.DisabledSound != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.DisabledSound, self.Owner.Faction.InternalName); } if (Info.DisabledSpeech != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.DisabledSpeech, self.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(Info.DisabledTextNotification, self.Owner); } }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet <TargetableType> types) { if (!info.Types.Overlaps(types)) { return; } var targetResources = self.Owner.PlayerActor.Trait <PlayerResources>(); var spyResources = infiltrator.Owner.PlayerActor.Trait <PlayerResources>(); var spyValue = infiltrator.Info.TraitInfoOrDefault <ValuedInfo>(); var toTake = Math.Min(info.Maximum, (targetResources.Cash + targetResources.Resources) * info.Percentage / 100); var toGive = Math.Max(toTake, info.Minimum >= 0 ? info.Minimum : spyValue != null ? spyValue.Cost : 0); targetResources.TakeCash(toTake); spyResources.GiveCash(toGive); if (info.InfiltratedNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName); } if (info.InfiltrationNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner); TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner); if (info.ShowTicks) { self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color, FloatingText.FormatCashTick(toGive), 30))); } }
public void RepairBuilding(Actor self, Player player) { if (IsTraitDisabled || !self.AppearsFriendlyTo(player.PlayerActor)) { return; } // Remove the player if they are already repairing if (Repairers.Remove(player)) { UpdateCondition(self); return; } // Don't add new players if the limit has already been reached if (Repairers.Count >= Info.RepairBonuses.Length - 1) { return; } Repairers.Add(player); Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", Info.RepairingNotification, player.Faction.InternalName); TextNotificationsManager.AddTransientLine(Info.RepairingTextNotification, self.Owner); UpdateCondition(self); }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet <TargetableType> types) { if (!info.Types.Overlaps(types)) { return; } if (info.InfiltratedNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName); } if (info.InfiltrationNotification != null) { Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName); } TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner); TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner); infiltrator.Owner.Shroud.Explore(self.Owner.Shroud); var preventReset = self.Owner.PlayerActor.TraitsImplementing <IPreventsShroudReset>() .Any(p => p.PreventShroudReset(self)); if (!preventReset) { self.Owner.Shroud.ResetExploration(); } }
public static void BotDebug(string s, params object[] args) { if (Game.Settings.Debug.BotDebug) { TextNotificationsManager.Debug(s, args); } }
void INotifyGameSaved.GameSaved(World world) { if (!world.IsReplay) { Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName); TextNotificationsManager.AddTransientLine(info.SavedTextNotification, null); } }
public void SendAirstrikeFrom(CPos from, CPos to) { TextNotificationsManager.Debug("SendAirstrikeFrom is deprecated. Use TargetAirstrike instead."); var i = Self.World.Map.CenterOfCell(from); var j = Self.World.Map.CenterOfCell(to); ap.SendAirstrike(Self, j, (i - j).Yaw); }
void PlayNotification(Actor self) { Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.NewOptionsNotification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(info.NewOptionsTextNotification, self.Owner); triggerNotification = false; tick = 0; }
public virtual void Charging(Actor self, string key) { Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, Info.BeginChargeSound); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.BeginChargeSpeechNotification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(Info.BeginChargeTextNotification, self.Owner); }
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr) { if (!world.IsLoadingGameSave) { Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName); TextNotificationsManager.AddTransientLine(info.TextNotification, null); } }
void RepairTick(Actor self) { var repairsUnits = allRepairsUnits.FirstOrDefault(r => !r.IsTraitDisabled && !r.IsTraitPaused); if (repairsUnits == null) { if (!allRepairsUnits.Any(r => r.IsTraitPaused)) { activeResupplyTypes &= ~ResupplyType.Repair; } return; } if (health.DamageState == DamageState.Undamaged) { if (host.Actor.Owner != self.Owner) { host.Actor.Owner.PlayerActor.TraitOrDefault <PlayerExperience>()?.GiveExperience(repairsUnits.Info.PlayerExperience); } Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(repairsUnits.Info.FinishRepairingTextNotification, self.Owner); activeResupplyTypes &= ~ResupplyType.Repair; return; } if (remainingTicks == 0) { var hpToRepair = repairable != null && repairable.Info.HpPerStep > 0 ? repairable.Info.HpPerStep : repairsUnits.Info.HpPerStep; // Cast to long to avoid overflow when multiplying by the health var value = (long)unitCost * repairsUnits.Info.ValuePercentage; var cost = value == 0 ? 0 : Math.Max(1, (int)(hpToRepair * value / (health.MaxHP * 100L))); if (!played) { played = true; Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.StartRepairingNotification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(repairsUnits.Info.StartRepairingTextNotification, self.Owner); } if (!playerResources.TakeCash(cost, true)) { remainingTicks = 1; return; } self.InflictDamage(host.Actor, new Damage(-hpToRepair, repairsUnits.Info.RepairDamageTypes)); remainingTicks = repairsUnits.Info.Interval; } else { --remainingTicks; } }
public void Debug(string text) { if (string.IsNullOrEmpty(text) || !Game.Settings.Debug.LuaDebug) { return; } TextNotificationsManager.Debug(text); }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(Info.SelectTargetTextNotification, manager.Self.Owner); self.World.OrderGenerator = new SelectSpawnActorPowerTarget(order, manager, this, MouseButton.Left); }
void INotifyDamage.Damaged(Actor self, AttackInfo e) { var localPlayer = self.World.LocalPlayer; if (localPlayer == null || localPlayer.Spectating) { return; } if (e.Attacker == null) { return; } if (e.Attacker.Owner == self.Owner) { return; } if (e.Attacker == self.World.WorldActor) { return; } // Only track last hit against our base if (!self.Info.HasTraitInfo <BuildingInfo>()) { return; } if (e.Attacker.Owner.IsAlliedWith(self.Owner) && e.Damage.Value <= 0) { return; } if (Game.RunTime > lastAttackTime + info.NotifyInterval) { var rules = self.World.Map.Rules; if (self.Owner == localPlayer) { Game.Sound.PlayNotification(rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); TextNotificationsManager.AddTransientLine(info.TextNotification, self.Owner); } else if (localPlayer.IsAlliedWith(self.Owner) && localPlayer != e.Attacker.Owner) { Game.Sound.PlayNotification(rules, localPlayer, "Speech", info.AllyNotification, localPlayer.Faction.InternalName); TextNotificationsManager.AddTransientLine(info.AllyTextNotification, localPlayer); } radarPings?.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); lastAttackTime = Game.RunTime; } }
public override void Activate(Actor collector) { TextNotificationsManager.AddSystemLine("Battlefield Control", collector.Owner.PlayerName + " has reshrouded the map."); foreach (var player in collector.World.Players) { player.Shroud.ResetExploration(); } base.Activate(collector); }
public void DisplayMessage(string text, string prefix = "Mission", Color?color = null) { if (string.IsNullOrEmpty(text)) { return; } var c = color.HasValue ? color.Value : Color.White; TextNotificationsManager.AddMissionLine(prefix, text, c); }
static Order CheckSameOrder(IOrderTargeter iot, Order order) { if (order == null && iot.OrderID != null) { TextNotificationsManager.Debug("BUG: in order targeter - decided on {0} but then didn't order", iot.OrderID); } else if (order != null && iot.OrderID != order.OrderString) { TextNotificationsManager.Debug("BUG: in order targeter - decided on {0} but ordered {1}", iot.OrderID, order.OrderString); } return(order); }
void INotifyTimeLimit.NotifyTimerExpired(Actor self) { if (countdownLabel != null) { countdownLabel.GetText = () => null; } if (!info.SkipTimerExpiredNotification) { TextNotificationsManager.AddSystemLine("Time limit has expired."); } }
void INotifyCapture.OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner, BitSet <CaptureType> captureTypes) { var faction = info.NewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName; Game.Sound.PlayNotification(self.World.Map.Rules, newOwner, "Speech", info.Notification, faction); TextNotificationsManager.AddTransientLine(info.TextNotification, newOwner); var loseFaction = info.LoseNewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName; Game.Sound.PlayNotification(self.World.Map.Rules, oldOwner, "Speech", info.LoseNotification, loseFaction); TextNotificationsManager.AddTransientLine(info.LoseTextNotification, oldOwner); }