public static void Postfix(TurnDirector __instance)
            {
                var combat = __instance.Combat;

                var contractID = __instance.Combat.ActiveContract.Override.ContractTypeValue.Name;

                ModInit.modLog.LogMessage($"ActiveContract.Override.ContractTypeValue.Name: {contractID}");

                var opforID        = __instance.Combat.ActiveContract.Override.targetTeam.FactionValue.Name;
                var opAllyID       = __instance.Combat.ActiveContract.Override.targetsAllyTeam.FactionValue.Name;
                var hostiletoALLID = __instance.Combat.ActiveContract.Override.hostileToAllTeam.FactionValue.Name;

                var playerUnits = combat.AllActors.Where(x => x.team.IsLocalPlayer).ToList();

                foreach (var actor in playerUnits)
                {
                    actor.StatCollection.AddStatistic <bool>(ModInit.modSettings.dummyOpForStat, false);
                    if (!playerUnits.Any(x => x.GetPilot().IsPlayerCharacter))
                    {
                        SpecManager.ApplyStratComs(actor);
                    }
                    var p = actor.GetPilot();
                    if (!p.pilotDef.PilotTags.Any(x => x.StartsWith(spGUID)))
                    {
                        SpecHolder.HolderInstance.AddToMaps(p);
                    }
                    var pKey = actor.GetPilot().FetchGUID();

                    if (!SpecHolder.HolderInstance.OpForKillsTEMPTracker.ContainsKey(pKey))
                    {
                        SpecHolder.HolderInstance.OpForKillsTEMPTracker.Add(pKey, new Dictionary <string, int>());
                        ModInit.modLog.LogMessage($"{p.Callsign} was missing OpForKillsTEMPTracker. Adding an empty one.");
                    }

                    if (ModInit.modSettings.WhiteListOpFor.Contains(opforID) && !SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].ContainsKey(opforID))
                    {
                        SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].Add(opforID, 0);
                        ModInit.modLog.LogMessage($"Initializing {p.Callsign}'s OpForKillsTEMPTracker for target team {opforID}.");
                    }

                    if (ModInit.modSettings.WhiteListOpFor.Contains(opAllyID) && string.IsNullOrEmpty(opAllyID) && !SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].ContainsKey(opAllyID))
                    {
                        SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].Add(opAllyID, 0);
                        ModInit.modLog.LogMessage($"Initializing {p.Callsign}'s OpForKillsTEMPTracker for targets ally team {opAllyID}.");
                    }

                    if (ModInit.modSettings.WhiteListOpFor.Contains(hostiletoALLID) && string.IsNullOrEmpty(hostiletoALLID) && !SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].ContainsKey(hostiletoALLID))
                    {
                        SpecHolder.HolderInstance.OpForKillsTEMPTracker[pKey].Add(hostiletoALLID, 0);
                        ModInit.modLog.LogMessage($"Initializing {p.Callsign}'s OpForKillsTEMPTracker for hostile to all team {hostiletoALLID}.");
                    }

                    SpecManager.ManagerInstance.GatherPassiveMissionSpecs(actor, contractID);

                    SpecManager.ManagerInstance.GatherPassiveOpforSpecs(actor, opforID);
                }
            }
Ejemplo n.º 2
0
        private void Initialize(string kernelName, IKernelSpecManager specManager, IChannelFactory channelFactory, ILogger logger)
        {
            this.Logger                = logger ?? new DefaultLogger();
            this.HashHelper            = new HashHelper();
            this.SpecManager           = specManager ?? (new KernelSpecManager());
            this.Spec                  = SpecManager.GetKernelSpec(kernelName);
            this.ConnectionInformation = new KernelConnection();
            this.ChannelFactory        = channelFactory;

            this.Debug = false;
        }
Ejemplo n.º 3
0
    public void Init()
    {
        healthSystem = GetComponent <HealthSystem>();
        battleSystem = GetComponent <BattleSystem>();
        actionSystem = GetComponent <ActionSystem>();
        moveSystem   = GetComponent <MoveSystem>();

        specManager    = GetComponent <SpecManager>();
        graphicManager = GetComponent <GraphicManager>();
        guardManager   = GetComponent <GuardManager>();

        healthSystem.Init();
        battleSystem.Init();
        graphicManager.Init();
    }