Пример #1
0
        public static void DeclareWar(IMyFaction OwnFaction, IMyFaction HostileFaction, TimeSpan TruceDelay)
        {
            if (!PeaceTimers.ContainsKey(OwnFaction))
            {
                if (AllowThrowingErrors)
                {
                    throw new Exception($"PeaceTimers dictionary error: can't find {OwnFaction.Tag} key!");
                }
                return;
            }

            DateTime PeaceTime = DateTime.Now.Add(TruceDelay);

            var timerdict = PeaceTimers[OwnFaction];

            if (!timerdict.ContainsKey(HostileFaction))
            {
                timerdict.Add(HostileFaction, PeaceTime);
            }
            else
            {
                timerdict[HostileFaction] = PeaceTime;
            }

            if (!OwnFaction.IsHostileTo(HostileFaction))
            {
                OwnFaction.DeclareWar(HostileFaction, Print: true);
            }

            DebugWrite($"DeclareWarTimer[{OwnFaction.Tag}]", $"Added peace timer. Current time: {DateTime.Now.ToString("HH:mm:ss")} | Calmdown at: {PeaceTime.ToString("HH:mm:ss")} | Calmdown delay: {TruceDelay.ToString()}");
        }