Example #1
0
        public void RunEncounterRules(LogicBlock.LogicType type, RunPayload payload = null)
        {
            if (EncounterRules != null)
            {
                switch (type)
                {
                case LogicBlock.LogicType.RESOURCE_REQUEST: {
                    EncounterRules.Run(LogicBlock.LogicType.RESOURCE_REQUEST, payload);
                    break;
                }

                case LogicBlock.LogicType.CONTRACT_OVERRIDE_MANIPULATION: {
                    EncounterRules.Run(LogicBlock.LogicType.CONTRACT_OVERRIDE_MANIPULATION, payload);
                    break;
                }

                case LogicBlock.LogicType.ENCOUNTER_MANIPULATION: {
                    EncounterRules.Run(LogicBlock.LogicType.ENCOUNTER_MANIPULATION, payload);
                    break;
                }

                case LogicBlock.LogicType.SCENE_MANIPULATION: {
                    EncounterRules.Run(LogicBlock.LogicType.SCENE_MANIPULATION, payload);
                    break;
                }

                default: {
                    Main.Logger.LogError($"[RunEncounterRules] Unknown type of '{type.ToString()}'");
                    break;
                }
                }
            }
        }
Example #2
0
        public override void Run(RunPayload payload)
        {
            Main.LogDebug("[EndCombatTrigger] Setting up trigger");
            EncounterLayerData   encounterData = MissionControl.Instance.EncounterLayerData;
            SmartTriggerResponse trigger       = new SmartTriggerResponse();

            trigger.inputMessage   = onMessage;
            trigger.designName     = $"End combat on '{onMessage}'";
            trigger.conditionalbox = new EncounterConditionalBox(conditional);

            DesignResult result = null;

            if (type == EndCombatType.RETREAT)
            {
                result = ScriptableObject.CreateInstance <EndCombatRetreatResult>();
            }
            else
            {
                // Fallback to the only end combat we currently have - Retreat
                result = ScriptableObject.CreateInstance <EndCombatRetreatResult>();
            }

            trigger.resultList.contentsBox.Add(new EncounterResultBox(result));
            encounterData.responseGroup.triggerList.Add(trigger);
        }
Example #3
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db = new DataLayer.EPSEntities();
            Employee emp             = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();

            try
            {
                Utilities util = new Utilities();

                String emailServer = util.GetParam("SMTPServer", "smtp (email) server name");
                String from        = util.GetParam("EmailFrom", "email address to send from");
                String to          = util.GetParam("WifiAdminEmailAddress", "email address for the wifi admin");
                String body        = util.GetParam("WifiAdminNotifyBody", "message to wifi admin to notify them of a disabled employee");
                String subject     = util.GetParam("WifiAdminNotifySubject", "subject line for the email to send the wifi admin to notify them of a disabled employee");

                util.SendEmail(EmpID, from, to, null, null, subject, body);

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("The email was sent to '{0}' regarding {1} {2}.", to, emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #4
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db   = new DataLayer.EPSEntities();
            Utilities             util = new Utilities();

            Employee emp    = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
            String   domain = util.GetParam("ADDomain", "Active Directory Domain name");

            String Script = "";

            try
            {
                Script = "Set-ADUser " + emp.Username + " -Replace @{msExchHideFromAddressLists=\"TRUE\"}";

                String result = util.RunPSScript(Script);

                if (!String.IsNullOrEmpty(result))
                {
                    throw new Exception(result);
                }

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("{0} {1} was hidden from the Exchange address lists.", emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}... Script Run: {1}", ex.Message, Script), TimeDone = DateTime.Now
                });
            }
        }
Example #5
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db = new DataLayer.EPSEntities();
            Employee emp             = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();

            try
            {
                Utilities util = new Utilities();

                String emailServer = util.GetParam("SMTPServer", "smtp (email) server name");
                String from        = util.GetParam("EmailFrom", "email address to send from");
                String to          = util.GetParam("HelpDeskEmail", "email address to send to for helpdesk tickets");
                String body        = util.GetParam("ClonedLaptopBody", "message to create a helpdesk ticket for cloned laptops");
                String subject     = util.GetParam("ClonedLaptopSubject", "subject line to create a helpdesk ticket for cloned laptops");

                util.SendEmail(EmpID, from, to, null, null, subject, body);

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("The email was sent to '{0}' regarding {1} {2} for their cloned laptop.", to, emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #6
0
        public override void Run(RunPayload payload)
        {
            if (!GetObjectReferences())
            {
                return;
            }

            this.payload = payload;
            SaveSpawnPositions(lance);
            Main.Logger.Log($"[SpawnLanceMembersAroundTarget] Attempting for '{lance.name}'");
            CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat;

            Vector3 validOrientationTargetPosition = GetClosestValidPathFindingHex(orientationTarget, orientationTarget.transform.position, $"OrientationTarget.{orientationTarget.name}");

            lance.transform.position = validOrientationTargetPosition;

            List <GameObject> spawnPoints = lance.FindAllContains("SpawnPoint");

            foreach (GameObject spawnPoint in spawnPoints)
            {
                bool success = SpawnLanceMember(spawnPoint, validOrientationTargetPosition, lookTarget, lookDirection);
                if (!success)
                {
                    break;
                }
            }

            invalidSpawnLocations.Clear();
        }
Example #7
0
 private void RunGeneralLogic(IEnumerable <LogicBlock> logicBlocks, RunPayload payload)
 {
     foreach (LogicBlock logicBlock in logicBlocks)
     {
         logicBlock.Run(payload);
     }
 }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddExtraLanceMembers] Adding extra lance units to lance");
            ContractOverride contractOverride = ((ContractOverridePayload)payload).ContractOverride;

            TeamOverride targetTeamOverride   = contractOverride.targetTeam;
            TeamOverride employerTeamOverride = contractOverride.employerTeam;

            if (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_EnemyLanceSizeOverride))
            {
                int lanceSizeOverride = Main.Settings.ActiveContractSettings.GetInt(ContractSettingsOverrides.ExtendedLances_EnemyLanceSizeOverride);
                Main.Logger.Log($"[AddExtraLanceMembers] Using contract-specific settings override for contract '{MissionControl.Instance.CurrentContract.Name}'. Enemy lance size will be '{lanceSizeOverride}'.");
                IncreaseLanceMembers(contractOverride, targetTeamOverride, lanceSizeOverride);
            }
            else
            {
                IncreaseLanceMembers(contractOverride, targetTeamOverride);
            }

            if (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_AllyLanceSizeOverride))
            {
                int lanceSizeOverride = Main.Settings.ActiveContractSettings.GetInt(ContractSettingsOverrides.ExtendedLances_AllyLanceSizeOverride);
                Main.Logger.Log($"[AddExtraLanceMembers] Using contract-specific settings override for contract '{MissionControl.Instance.CurrentContract.Name}'. Ally lance size will be '{lanceSizeOverride}'.");
                IncreaseLanceMembers(contractOverride, employerTeamOverride, lanceSizeOverride);
            }
            else
            {
                IncreaseLanceMembers(contractOverride, employerTeamOverride);
            }
        }
Example #9
0
        public virtual void Run(LogicBlock.LogicType type, RunPayload payload)
        {
            IEnumerable <LogicBlock> logicBlocks = EncounterLogic.Where(logic => logic.Type == type);

            switch (type)
            {
            case LogicBlock.LogicType.RESOURCE_REQUEST:
                State = EncounterState.RUNNING;
                RunGeneralLogic(logicBlocks, payload);
                break;

            case LogicBlock.LogicType.CONTRACT_OVERRIDE_MANIPULATION:
                RunGeneralLogic(logicBlocks, payload);
                break;

            case LogicBlock.LogicType.ENCOUNTER_MANIPULATION:
                RunGeneralLogic(logicBlocks, payload);
                break;

            case LogicBlock.LogicType.SCENE_MANIPULATION:
                RunSceneManipulationLogic(logicBlocks, payload);
                MissionControl.Instance.IsMCLoadingFinished = true;
                break;

            default:
                Main.Logger.LogError($"[EncounterRules] Unknown logic type '{type}'");
                break;
            }
        }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddDialogueChunk] Adding encounter structure");
            EncounterLayerData     encounterLayerData = MissionControl.Instance.EncounterLayerData;
            DialogueChunkGameLogic dialogChunk        = ChunkFactory.CreateDialogueChunk($"Chunk_Dialog_{dialogChunkName}");

            dialogChunk.encounterObjectGuid = System.Guid.NewGuid().ToString();
            dialogChunk.notes = debugDescription;

            DialogueGameLogic dialogueGameLogic;

            if (fromDialogueBucket)
            {
                dialogueGameLogic = DialogueFactory.CreateBucketDialogLogic(dialogChunk.gameObject, dialogChunkName, dialogueBucketId);
            }
            else if (dialogueOverride != null)
            {
                dialogueGameLogic = DialogueFactory.CreateDialogLogic(dialogChunk.gameObject, dialogChunkName, dialogueOverride);
            }
            else
            {
                dialogueGameLogic = DialogueFactory.CreateDialogLogic(dialogChunk.gameObject, dialogChunkName, cameraTargetGuid, presetDialog, castDef);
            }

            dialogueGameLogic.encounterObjectGuid = dialogueGuid;
        }
Example #11
0
        public override void Run(RunPayload payload)
        {
            Main.LogDebug("[ChunkTrigger] Setting up trigger");
            EncounterLayerData   encounterData = MissionControl.Instance.EncounterLayerData;
            SmartTriggerResponse trigger       = new SmartTriggerResponse();

            trigger.inputMessage   = onMessage;
            trigger.designName     = $"Initiate chunk on {(MessageTypes)onMessage}";
            trigger.conditionalbox = new EncounterConditionalBox(conditional);

            PositionRegionResult positionRegionResult = ScriptableObject.CreateInstance <PositionRegionResult>();

            positionRegionResult.RegionName = "Region_Withdraw";

            FailObjectivesResult failObjectivesResult = ScriptableObject.CreateInstance <FailObjectivesResult>();

            failObjectivesResult.ObjectiveNameWhiteList.Add("Objective_Withdraw");

            HACK_ActivateChunkResult activateChunkResult = ScriptableObject.CreateInstance <HACK_ActivateChunkResult>();
            EncounterChunkRef        encounterChunkRef   = new EncounterChunkRef();

            encounterChunkRef.EncounterObjectGuid = chunkGuid;
            activateChunkResult.encounterChunk    = encounterChunkRef;

            trigger.resultList.contentsBox.Add(new EncounterResultBox(positionRegionResult));
            trigger.resultList.contentsBox.Add(new EncounterResultBox(failObjectivesResult));
            trigger.resultList.contentsBox.Add(new EncounterResultBox(activateChunkResult));
            encounterData.responseGroup.triggerList.Add(trigger);
        }
Example #12
0
        public override void Run(RunPayload payload)
        {
            if (!GetObjectReferences())
            {
                return;
            }

            SaveSpawnPositions(lance);
            Main.Logger.Log($"[SpawnLanceAnywhere] Attemping for '{lance.name}'");
            CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat;

            Init();

            // Cluster units to make a tigher spread - makes hitting a successful spawn position generally easier
            if (clusterUnits)
            {
                Main.LogDebug($"[SpawnLanceAnywhere] Clustering lance '{lance.name}'");
                ClusterLanceMembers(lance);
                clusterUnits = false;
                Main.LogDebug($"[SpawnLanceAnywhere] Finished clustering lance '{lance.name}'");
            }

            if (TotalAttemptCount > TotalAttemptMax)
            {
                HandleFallback(payload, this.lanceKey, this.orientationTargetKey);
                return;
            }

            Vector3 newPosition = GetRandomPositionWithinBounds();

            newPosition = GetClosestValidPathFindingHex(null, newPosition, $"NewSpawnPosition.{lance.name}", IsLancePlayerLance(lanceKey) ? orientationTarget.transform.position : Vector3.zero, 2);
            Main.LogDebug($"[SpawnLanceAnywhere] Attempting selection of random position in bounds. Selected position '{newPosition}'");
            lance.transform.position = newPosition;

            if (useOrientationTarget)
            {
                RotateToTarget(lance, orientationTarget);
            }

            if (IsDistanceSetupValid(newPosition))
            {
                if (!AreLanceMemberSpawnsValid(lance, validOrientationTargetPosition))
                {
                    CheckAttempts();
                    Run(payload);
                }
                else
                {
                    Main.Logger.Log("[SpawnLanceAnywhere] Lance spawn complete");
                    CorrectLanceMemberSpawns(lance);
                }
            }
            else
            {
                Main.Logger.Log("[SpawnLanceAnywhere] Spawn is too close to the target. Selecting a new spawn.");
                CheckAttempts();
                Run(payload);
            }
        }
Example #13
0
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddCustomPlayerLanceExtraSpawnPoints] Adding extra player lance spawn points to handle more player units");
            Contract   contract      = MissionControl.Instance.CurrentContract;
            GameObject playerSpawnGo = GetPlayerSpawn();

            IncreaseLanceSpawnPoints(playerSpawnGo);
        }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddExtraLanceSpawnPoints] Adding lance spawn points to match contract override data");
            Contract           contract           = MissionControl.Instance.CurrentContract;
            EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData;
            ContractOverride   contractOverride   = contract.Override;

            lancesToSkip  = (List <string>)state.GetObject("LancesToSkip");
            lanceSpawners = new List <LanceSpawnerGameLogic>(encounterLayerData.gameObject.GetComponentsInChildren <LanceSpawnerGameLogic>());

            // Backwards compatibility between EL v1 and v2 for renaming of key
            string targetKey   = (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_TargetLanceSizeOverride)) ? ContractSettingsOverrides.ExtendedLances_TargetLanceSizeOverride : ContractSettingsOverrides.ExtendedLances_EnemyLanceSizeOverride;
            string employerKey = (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_EmployerLanceSizeOverride)) ? ContractSettingsOverrides.ExtendedLances_EmployerLanceSizeOverride : ContractSettingsOverrides.ExtendedLances_AllyLanceSizeOverride;

            PrepareIncreaseLanceMembers(contractOverride, contractOverride.targetTeam, targetKey, "Target");
            PrepareIncreaseLanceMembers(contractOverride, contractOverride.employerTeam, employerKey, "Employer");

            if (Main.Settings.ExtendedLances.EnableForTargetAlly)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.targetsAllyTeam, ContractSettingsOverrides.ExtendedLances_TargetAllyLanceSizeOverride, "TargetAlly");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceSpawnPoints] [{contractOverride.targetsAllyTeam}] TargetAlly is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForEmployerAlly)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.employersAllyTeam, ContractSettingsOverrides.ExtendedLances_EmployerAllyLanceSizeOverride, "EmployerAlly");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceSpawnPoints] [{contractOverride.employersAllyTeam}] EmployerAlly is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForHostileToAll)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.hostileToAllTeam, ContractSettingsOverrides.ExtendedLances_HostileToAllLanceSizeOverride, "HostileToAll");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceSpawnPoints] [{contractOverride.hostileToAllTeam}] HostileToAll is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForNeutralToAll)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.neutralToAllTeam, ContractSettingsOverrides.ExtendedLances_NeutralToAllLanceSizeOverride, "NeutralToAll");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceSpawnPoints] [{contractOverride.neutralToAllTeam}] NeutralToAll is 'false' so will not increase lance members");
            }

            state.Set("ExtraLanceSpawnKeys", spawnKeys);
        }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddDestroyWholeUnitChunk] Adding encounter structure");
            EncounterLayerData     encounterLayerData = MissionControl.Instance.EncounterLayerData;
            DestroyWholeLanceChunk destroyWholeChunk  = ChunkFactory.CreateDestroyWholeLanceChunk();

            destroyWholeChunk.encounterObjectGuid = System.Guid.NewGuid().ToString();

            this.objectiveLabel = MissionControl.Instance.CurrentContract.Interpolate(this.objectiveLabel).ToString();

            bool spawnOnActivation             = true;
            LanceSpawnerGameLogic lanceSpawner = LanceSpawnerFactory.CreateLanceSpawner(
                destroyWholeChunk.gameObject,
                spawnerName,
                lanceGuid,
                teamGuid,
                spawnOnActivation,
                SpawnUnitMethodType.InstantlyAtSpawnPoint,
                unitGuids
                );
            LanceSpawnerRef lanceSpawnerRef = new LanceSpawnerRef(lanceSpawner);

            bool showProgress = true;
            DestroyLanceObjective objective = ObjectiveFactory.CreateDestroyLanceObjective(
                objectiveGuid,
                destroyWholeChunk.gameObject,
                lanceSpawnerRef,
                lanceGuid,
                objectiveLabel,
                showProgress,
                ProgressFormat.PERCENTAGE_COMPLETE,
                "The primary objective to destroy the enemy lance",
                priority,
                displayToUser,
                ObjectiveMark.AttackTarget,
                contractObjectiveGameLogicGuid,
                Main.Settings.ActiveAdditionalLances.GetRewards()
                );

            if (isPrimary)
            {
                AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, true);
            }
            else
            {
                AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, false);
            }

            DestroyLanceObjectiveRef destroyLanceObjectiveRef = new DestroyLanceObjectiveRef();

            destroyLanceObjectiveRef.encounterObject = objective;

            destroyWholeChunk.lanceSpawner     = lanceSpawnerRef;
            destroyWholeChunk.destroyObjective = destroyLanceObjectiveRef;
        }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddExtraLanceMembers] Adding extra lance units to lance");
            ContractOverride contractOverride = ((ContractOverridePayload)payload).ContractOverride;

            TeamOverride targetTeamOverride   = contractOverride.targetTeam;
            TeamOverride employerTeamOverride = contractOverride.employerTeam;

            IncreaseLanceMembers(contractOverride, targetTeamOverride);
            IncreaseLanceMembers(contractOverride, employerTeamOverride);
        }
Example #17
0
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[DoesChunkExist] Checking if '{this.chunkName}' exists");
            GameObject encounterLayerGameObject = MissionControl.Instance.EncounterLayerGameObject;
            GameObject result = encounterLayerGameObject.FindRecursive(this.chunkName);

            if (result != null)
            {
                state.Set($"{chunkName}_Exists", true);
            }
        }
        public override void Run(RunPayload payload)
        {
            if (!GetObjectReferences())
            {
                return;
            }

            SaveSpawnPositions(new List <GameObject>()
            {
                target
            });
            Main.Logger.Log($"[SpawnObjectAnywhere] Attemping for '{target.name}'");
            CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat;

            Init();

            if (TotalAttemptCount > TotalAttemptMax)
            {
                HandleFallback(payload, this.objectKey, this.orientationTargetKey);
                return;
            }

            Vector3 newPosition = GetRandomPositionWithinBounds();

            newPosition = GetClosestValidPathFindingHex(null, newPosition, $"NewSpawnPosition.{target.name}", IsLancePlayerLance(objectKey) ? orientationTarget.transform.position : Vector3.zero, 2);
            Main.LogDebug($"[SpawnObjectAnywhere] Attempting selection of random position in bounds. Selected position '{newPosition}'");
            target.transform.position = newPosition;

            if (useOrientationTarget)
            {
                RotateToTarget(target, orientationTarget);
            }

            if (IsDistanceSetupValid(newPosition))
            {
                if (!IsObjectSpawnValid(target, validOrientationTargetPosition))
                {
                    CheckAttempts();
                    Run(payload);
                }
                else
                {
                    Main.Logger.Log("[SpawnObjectAnywhere] Object spawn complete");
                    Vector3 spawnPointPosition = target.transform.position.GetClosestHexLerpedPointOnGrid();
                    target.transform.position = spawnPointPosition;
                }
            }
            else
            {
                Main.Logger.Log("[SpawnObjectAnywhere] Object spawn is too close to the target. Selecting a new spawn.");
                CheckAttempts();
                Run(payload);
            }
        }
Example #19
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db = new DataLayer.EPSEntities();
            Employee emp             = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();

            try
            {
                Utilities util = new Utilities();

                String      myName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                LibraryItem li     = db.LibraryItems.Where(l => l.LibraryPath.EndsWith(myName + ".dll")).FirstOrDefault();

                String htmlOptions = li.HtmlOptions;

                Employee manager = db.Employees.Where(e => e.EmpID == emp.ReportsTo).FirstOrDefault();

                if (manager == null)
                {
                    throw new Exception(String.Format("There is no manager assigned to {0} {1}.", emp.FirstName, emp.LastName));
                }

                if (String.IsNullOrEmpty(manager.Email))
                {
                    throw new Exception(String.Format("The manager assigned to {0} {1} does not have an email set.", emp.FirstName, emp.LastName));
                }

                String emailServer = util.GetParam("SMTPServer", "smtp (email) server name");
                String from        = util.GetParam("EmailFrom", "email address to send from");
                String to          = manager.Email;
                String body        = util.GetParam("FinalDisableNotifyBody", "message to disable distro group to notify them of a disabled employee");
                String subject     = util.GetParam("FinalDisableNotifySubject", "subject line for the email to send the disable distro group to notify them of a disabled employee");

                List <RunPayloadItem> thisPL = RunPayload.RunPayloadItems.Where(p => p.ItemID == li.ItemID).ToList();

                string numDays      = thisPL.Where(p => p.ElementID == "NumDays").FirstOrDefault().ElementValue;
                string ticketNumber = thisPL.Where(p => p.ElementID == "TicketNumber").FirstOrDefault().ElementValue;

                body = body.Replace("[NumDays]", numDays);
                body = body.Replace("[TicketNumber]", ticketNumber);

                util.SendEmail(EmpID, from, to, null, null, subject, body);

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("The email was sent to '{0}' regarding {1} {2} for their final notification.", manager.Email, emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #20
0
        public override void Run(RunPayload payload)
        {
            Main.LogDebug($"[GenericTrigger] Setting up trigger '{this.name}'");
            EncounterLayerData   encounterData = MissionControl.Instance.EncounterLayerData;
            SmartTriggerResponse trigger       = new SmartTriggerResponse();

            trigger.inputMessage   = onMessage;
            trigger.designName     = $"{description} on {onMessage}";
            trigger.conditionalbox = new EncounterConditionalBox(conditional);

            trigger.resultList.contentsBox = this.results;
            encounterData.responseGroup.triggerList.Add(trigger);
        }
Example #21
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db   = new DataLayer.EPSEntities();
            Utilities             util = new Utilities();

            try
            {
                Employee emp       = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
                String   domain    = util.GetParam("ADDomain", "Active Directory domain");
                String   adminName = util.GetParam("ADUsername", "Active Directory admin user");
                String   password  = util.GetParam("ADPassword", "Active Directory admin user password");

                PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, adminName, password);
                UserPrincipal    user    = UserPrincipal.FindByIdentity
                                               (context, emp.Username);

                if (user == null)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 4, ResultText = String.Format("{0} could not be found in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                int firstIndex = user.Description.IndexOf("**");

                if (firstIndex > -1)
                {
                    int lastIndex = user.Description.IndexOf("**", firstIndex + 3) + 2;

                    if (lastIndex > -1)
                    {
                        int count = lastIndex - firstIndex;

                        String newDesc = user.Description.Remove(firstIndex, count);

                        user.Description = newDesc;
                        user.Save();
                    }
                }

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("Employee: {0} {1} had the description cleared in Active Directory.", emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[MaximiseBoundarySize.Run] Setting Boundary Size to '{size}'");
            EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData;

            if (size > 0f)
            {
                SetBoundarySizeToCustom(encounterLayerData, size);
            }
            else if (size >= 0.5f) // If you're going to extend by 4 times (50% width and depth) you might as well go full map
            {
                MatchBoundarySizeToMapSize(encounterLayerData);
            }
        }
Example #23
0
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddContractObjectiveToEncounter] Adding Contract Objective to Encounter");
            ContractObjectiveGameLogic contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.gameObject.AddComponent <ContractObjectiveGameLogic>();
            ContractObjectiveOverride  contractObjectiveOverride  = MissionControl.Instance.CurrentContract.Override.contractObjectiveList.First(
                item => item.GUID == contractObjectiveOverrideGuid
                );

            contractObjectiveGameLogic.title               = contractObjectiveOverride.title;
            contractObjectiveGameLogic.description         = contractObjectiveOverride.description;
            contractObjectiveGameLogic.forPlayer           = contractObjectiveOverride.forPlayer;
            contractObjectiveGameLogic.primary             = contractObjectiveOverride.isPrimary;
            contractObjectiveGameLogic.encounterObjectGuid = contractObjectiveOverrideGuid;
        }
Example #24
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db   = new DataLayer.EPSEntities();
            Utilities             util = new Utilities();

            try
            {
                String      myName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                LibraryItem li     = db.LibraryItems.Where(l => l.LibraryPath.EndsWith(myName + ".dll")).FirstOrDefault();

                String htmlOptions = li.HtmlOptions;

                Employee emp       = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
                String   domain    = util.GetParam("ADDomain", "Active Directory domain");
                String   adminName = util.GetParam("ADUsername", "Active Directory admin user");
                String   password  = util.GetParam("ADPassword", "Active Directory admin user password");

                PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, adminName, password);
                UserPrincipal    user    = UserPrincipal.FindByIdentity
                                               (context, emp.Username);

                List <RunPayloadItem> thisPL = RunPayload.RunPayloadItems.Where(p => p.ItemID == li.ItemID).ToList();

                string techName     = thisPL.Where(p => p.ElementID == "TechInit").FirstOrDefault().ElementValue;
                string ticketNumber = thisPL.Where(p => p.ElementID == "TicketNumber").FirstOrDefault().ElementValue;

                if (user == null)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 4, ResultText = String.Format("{0} could not be found in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                String CurrentDesc = user.Description;

                user.Description = String.Format("{3} ** Disabled on {0} by {1}. Ticket Number: {2} **", DateTime.Now.ToString("MM/dd/yyyy"), techName, ticketNumber, CurrentDesc);
                user.Save();

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("Employee: {0} {1} had the description updated in Active Directory.", emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #25
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db   = new DataLayer.EPSEntities();
            Utilities             util = new Utilities();

            try
            {
                Employee emp       = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
                String   domain    = util.GetParam("ADDomain", "Active Directory domain");
                String   adminName = util.GetParam("ADUsername", "Active Directory admin user");
                String   password  = util.GetParam("ADPassword", "Active Directory admin user password");

                if (domain == null)
                {
                    throw new Exception("The Active Directory domain is not configured in the parameters table");
                }

                PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, adminName, password);
                UserPrincipal    user    = UserPrincipal.FindByIdentity
                                               (context, emp.Username);

                if (user == null)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 4, ResultText = String.Format("{0} could not be found in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                if (user.Enabled == false)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 5, ResultText = String.Format("{0} was already disabled in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                user.Enabled = false;
                user.Save();

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("Employee: {0} {1} was disabled in Active Directory.", emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #26
0
        public override void Run(RunPayload payload)
        {
            GetObjectReferences();
            Main.Logger.Log($"[LookAwayFromTarget] For {focus.name} to look away from {orientationTarget.name}");

            if (isLance)
            {
                SaveSpawnPositions(focus);
            }
            RotateAwayFromTarget(focus, orientationTarget);
            if (isLance)
            {
                RestoreLanceMemberSpawnPositions(focus);
            }
        }
Example #27
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db   = new DataLayer.EPSEntities();
            Utilities             util = new Utilities();

            try
            {
                Employee emp             = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
                String   domain          = util.GetParam("ADDomain", "Active Directory domain");
                String   adminName       = util.GetParam("ADUsername", "Active Directory admin user");
                String   password        = util.GetParam("ADPassword", "Active Directory admin user password");
                String   defaultPassword = String.Format("AA{0}^", Guid.NewGuid().ToString());

                PrincipalContext context = new PrincipalContext(ContextType.Domain, domain, adminName, password);
                UserPrincipal    user    = UserPrincipal.FindByIdentity(context, emp.Username);

                if (user == null)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 4, ResultText = String.Format("{0} could not be found in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                if (user.AccountExpirationDate == null)
                {
                    return(new Utilities.ItemRunResult {
                        ResultID = 5, ResultText = String.Format("{0} was not expired in Active Directory.", emp.Username), TimeDone = DateTime.Now
                    });
                }

                user.AccountExpirationDate = null;
                user.Save();

                user.SetPassword(defaultPassword);
                user.ExpirePasswordNow();
                user.Save();

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("{0} {1} was removed from expiration in Active Directory.", emp.FirstName, emp.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }
Example #28
0
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddExtraLanceMembers] Adding extra lance units to lance");
            ContractOverride contractOverride = ((ContractOverridePayload)payload).ContractOverride;

            // Backwards compatibility between EL v1 and v2 for renaming of key
            string targetKey   = (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_TargetLanceSizeOverride)) ? ContractSettingsOverrides.ExtendedLances_TargetLanceSizeOverride : ContractSettingsOverrides.ExtendedLances_EnemyLanceSizeOverride;
            string employerKey = (Main.Settings.ActiveContractSettings.Has(ContractSettingsOverrides.ExtendedLances_EmployerLanceSizeOverride)) ? ContractSettingsOverrides.ExtendedLances_EmployerLanceSizeOverride : ContractSettingsOverrides.ExtendedLances_AllyLanceSizeOverride;

            PrepareIncreaseLanceMembers(contractOverride, contractOverride.targetTeam, targetKey, "Target");
            PrepareIncreaseLanceMembers(contractOverride, contractOverride.employerTeam, employerKey, "Employer");

            if (Main.Settings.ExtendedLances.EnableForTargetAlly)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.targetsAllyTeam, ContractSettingsOverrides.ExtendedLances_TargetAllyLanceSizeOverride, "TargetAlly");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceMembers] [{contractOverride.targetsAllyTeam}] TargetAlly is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForEmployerAlly)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.employersAllyTeam, ContractSettingsOverrides.ExtendedLances_EmployerAllyLanceSizeOverride, "EmployerAlly");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceMembers] [{contractOverride.employersAllyTeam}] EmployerAlly is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForHostileToAll)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.hostileToAllTeam, ContractSettingsOverrides.ExtendedLances_HostileToAllLanceSizeOverride, "HostileToAll");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceMembers] [{contractOverride.hostileToAllTeam}] HostileToAll is 'false' so will not increase lance members");
            }

            if (Main.Settings.ExtendedLances.EnableForNeutralToAll)
            {
                PrepareIncreaseLanceMembers(contractOverride, contractOverride.neutralToAllTeam, ContractSettingsOverrides.ExtendedLances_NeutralToAllLanceSizeOverride, "NeutralToAll");
            }
            else
            {
                Main.LogDebug($"[AddExtraLanceMembers] [{contractOverride.neutralToAllTeam}] NeutralToAll is 'false' so will not increase lance members");
            }
        }
Example #29
0
        protected void HandleFallback(RunPayload payload, string lanceKey, string orientationTargetKey)
        {
            if (GetOriginalSpawnPosition() == Vector3.zero)
            {
                Main.LogDebug($"[{this.GetType().Name}] Cannot find valid spawn. Spawning with 'SpawnAnywhere' profile.");
                RunFallbackSpawn(payload, lanceKey, orientationTargetKey);
            }
            else
            {
                RestoreSpawnPositions(this.EncounterRules.ObjectLookup[lanceKey]);
                Main.LogDebug($"[{this.GetType().Name}] Cannot find valid spawn. Spawning at vanilla location for the encounter");
            }

            LookAtTarget lookAtTarget = new LookAtTarget(this.EncounterRules, lanceKey, orientationTargetKey, true);

            lookAtTarget.Run(payload);
        }
Example #30
0
        public Utilities.ItemRunResult RunItem(int EmpID, RunPayload RunPayload)
        {
            DataLayer.EPSEntities db = new DataLayer.EPSEntities();
            Employee emp             = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();

            try
            {
                Utilities util = new Utilities();

                Employee manager = db.Employees.Where(e => e.EmpID == emp.ReportsTo).FirstOrDefault();

                if (manager == null)
                {
                    throw new Exception(String.Format("There is no manager assigned to {0} {1}.", emp.FirstName, emp.LastName));
                }

                if (String.IsNullOrEmpty(manager.Email))
                {
                    throw new Exception(String.Format("The manager assigned to {0} {1} does not have an email set.", emp.FirstName, emp.LastName));
                }

                String emailServer = util.GetParam("SMTPServer", "smtp (email) server name");
                String from        = util.GetParam("EmailFrom", "email address to send from");
                String to          = manager.Email;
                String body        = util.GetParam("DisabledNotifyBody", "message to managers to notify them of a disabled employee");
                String subject     = util.GetParam("DisabledNotifySubject", "subject line for the email to send managers to notify them of a disabled employee");

                foreach (PropertyInfo prop in typeof(Employee).GetProperties())
                {
                    body    = body.Replace(String.Format("[{0}]", prop.Name), prop.GetValue(emp).ToString());
                    subject = subject.Replace(String.Format("[{0}]", prop.Name), prop.GetValue(emp).ToString());
                }

                util.SendEmail(emp.EmpID, from, to, null, null, subject, body);

                return(new Utilities.ItemRunResult {
                    ResultID = 2, ResultText = String.Format("The email was sent to {0} {1}.", manager.FirstName, manager.LastName), TimeDone = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                return(new Utilities.ItemRunResult {
                    ResultID = 4, ResultText = String.Format("Error: {0}", ex.Message), TimeDone = DateTime.Now
                });
            }
        }