Пример #1
0
 public void RemoveActiveMission(ActiveMission actMiss)
 {
     _Grid.ResetCellsInPath(actMiss.Path);
     _Grid.ResetSourceCell(actMiss.Path[0].x);
     _Missions.Remove(actMiss.Mission);
     _ActiveMissions.Remove(actMiss);
 }
        public ActiveMissionViewController(ActiveMission actMission, Material material)
        {
            _Model      = GameModel.Instance;
            _ActMission = actMission;

            _TrackPathMaterial   = new Material(material);
            _ColourPathMaterial  = new Material(material);
            _OutlinePathMaterial = new Material(material);

            _ColourPathPoints = ShanghaiUtils.GetScreenCoordsFromCellKeys(_ActMission.Path, _Model.CellPositions);
            _ColourPathMaterial.SetColor("_TintColor", ShanghaiUtils.GetColour(_ActMission.Source.PaintColour));
            _ColourPath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _ColourPathMaterial, 10.0f, LineType.Continuous, Joins.Weld);
            _ColourPath.Draw();

            _OutlinePathMaterial.SetColor("_TintColor", Color.black);
            _OutlinePath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _OutlinePathMaterial, 15.0f, LineType.Continuous, Joins.Weld);
            _OutlinePath.Draw();

            Vector2[] linePoints = new Vector2[2];
            linePoints[0] = new Vector2(0, 0);
            linePoints[1] = new Vector2(Screen.width, Screen.height);
            _TrackPathMaterial.SetColor("_TintColor", Color.black);
            _TrackPath = new VectorLine("Active Path", _ColourPathPoints.ToArray(), _TrackPathMaterial, 5.0f, LineType.Continuous, Joins.Weld);
            _TrackPath.Draw();
        }
Пример #3
0
 public void RemoveActiveMission(ActiveMission actMiss)
 {
     _Grid.ResetCellsInPath(actMiss.Path);
     // remove source and target
     _ActiveMissions.Remove(actMiss);
     Messenger <ActiveMission> .Broadcast(EVENT_ACTIVE_MISSION_REMOVED, actMiss);
 }
Пример #4
0
        public static MissionHubServer AddMission(this MissionHubServer s, ActiveMission m, bool insertTop = false, bool preventRegistryChange = false, int desiredIndex = -1)
        {
            if (insertTop && desiredIndex <= -1)
            {
                desiredIndex = 0;
            }
            s.contractRegistryNumber += Utils.getRandomByte() + 1;
            s.listingMissions.Add(string.Concat(s.contractRegistryNumber), m);
            var item = new FileEntry(MissionSerializer.generateMissionFile(m, s.contractRegistryNumber, s.groupName), "Contract#" + s.contractRegistryNumber);

            if (insertTop || desiredIndex >= 0)
            {
                s.listingsFolder.files.Insert(desiredIndex, item);
            }
            else
            {
                s.listingsFolder.files.Add(item);
            }
            var inst = m as Instance;

            if (inst != null)
            {
                inst.MissionComputer = s.comp;
            }
            return(s);
        }
Пример #5
0
    private IEnumerator failMission(ActiveMission activeMission, float delay)
    {
        yield return(new WaitForSeconds(delay));

        gameState.registerMissionFailure(activeMission);
        activeMission.explode();
        explodedRocketMessage.alpha = 1;
    }
Пример #6
0
        private static int GetWordCountFromMission(ActiveMission m)
        {
            int num = 0;

            WordCounter.charAccum += m.email.body.Length;
            WordCounter.charAccum += m.email.subject.Length;
            WordCounter.charAccum += m.postingBody.Length;
            WordCounter.charAccum += m.postingTitle.Length;
            return(num + WordCounter.CountString(m.email.body) + WordCounter.CountString(m.email.subject) + WordCounter.CountString(m.postingBody) + WordCounter.CountString(m.postingTitle));
        }
Пример #7
0
    public void registerMissionCompletion(ActiveMission mission)
    {
        totalMissionSuccesses++;
        missions.Remove(mission);
        var payload = mission.getMissionData().payloadData;

        int currentCount;

        deliveredPayloads.TryGetValue(payload, out currentCount);
        deliveredPayloads[payload] = currentCount + 1;
    }
Пример #8
0
        public static MissionListingServer AddMission(this MissionListingServer s, ActiveMission m, bool injectTop = false)
        {
            s.addMisison(m, injectTop);
            var inst = m as Instance;

            if (inst != null)
            {
                inst.MissionComputer = s.comp;
            }
            return(s);
        }
Пример #9
0
 public void BeginMission(List <Hero> assignedHeroes, Mission currentMision)
 {
     currentMision.SetHeroes(assignedHeroes);
     foreach (var h in assignedHeroes)
     {
         h.AssignedMission = currentMision;
     }
     ActiveMission.Add(currentMision);
     Missions.Remove(currentMision);
     assignedHeroes.Clear();
 }
Пример #10
0
 private void OnActiveMissionRemoved(ActiveMission actMiss)
 {
     if (!_Views.ContainsKey(actMiss))
     {
         Debug.Log("Could not find active mission in _Views");
     }
     else
     {
         ActiveMissionViewController view = _Views[actMiss];
         view.CleanUp();
         _Views.Remove(actMiss);
     }
 }
Пример #11
0
 private void UpdateMissions()
 {
     for (int i = 0; i < ActiveMission.Count; i++)
     {
         ActiveMission[i].RemainingTime -= TimeManager.DeltaTime;
         if (ActiveMission[i].RemainingTime <= 0)
         {
             ActiveMission[i].Victory();
             CompletedMission.Add(ActiveMission[i]);
             ActiveMission.RemoveAt(i);
             i--;
         }
     }
 }
Пример #12
0
        public static string TestMissionEndFucntion(string missionName, string expectedEndFunction, object os_obj)
        {
            string str = "";

            if (!File.Exists(missionName))
            {
                str = str + "Invalid Mission Path! : " + missionName + "\r\n";
            }
            ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(missionName);

            if (activeMission.endFunctionName != expectedEndFunction)
            {
                str = str + "\r\nUnexpected end function in " + missionName + "\r\nExpected: " + expectedEndFunction + " -- found: " + activeMission.endFunctionName;
            }
            return(str);
        }
Пример #13
0
        internal static XElement GetMissionSaveElement(ActiveMission mission)
        {
            var result = new XElement("mission");

            if (mission == null)
            {
                result.SetAttributeValue("next", "NULL_MISSION");
                result.SetAttributeValue("goals", "none");
                result.SetAttributeValue("activeCheck", "none");
                return(result);
            }
            result.SetAttributeValue("next", mission.nextMission);
            result.SetAttributeValue("goals", mission.reloadGoalsSourceFile);
            result.SetAttributeValue("reqRank", mission.requiredRank);

            if (mission.wasAutoGenerated)
            {
                result.SetAttributeValue("genTarget", mission.genTarget);
                result.SetAttributeValue("genFile", mission.genFile);
                result.SetAttributeValue("genPath", mission.genPath);
                result.SetAttributeValue("genTargetName", mission.genTargetName);
                result.SetAttributeValue("genOther", mission.genOther);
            }

            result.SetAttributeValue("activeCheck", mission.activeCheck);

            var email = new XElement("email");

            email.SetAttributeValue("sender", mission.email.sender);
            email.SetAttributeValue("subject", mission.email.subject);
            email.SetValue(mission.email.body);
            result.Add(email);

            var endFunctionVal = new XElement("endFunc");

            endFunctionVal.SetAttributeValue("val", mission.endFunctionValue);
            endFunctionVal.SetAttributeValue("name", mission.endFunctionName);
            result.Add(endFunctionVal);

            var postingTag = new XElement("posting");

            postingTag.SetAttributeValue("title", mission.postingTitle);
            postingTag.SetValue(mission.postingBody);
            result.Add(postingTag);
            return(result);
        }
Пример #14
0
        private static string TestAllExtensionMissions(OS os, out int errorsAdded)
        {
            int    errors = 0;
            string ret    = "";

            Utils.ActOnAllFilesRevursivley(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/Missions", (Action <string>)(filename =>
            {
                if (!filename.EndsWith(".xml"))
                {
                    return;
                }
                if (OS.TestingPassOnly)
                {
                    try
                    {
                        ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(filename);
                        if (activeMission != null)
                        {
                            ExtensionTests.RuntimeLoadAdditionalErrors += ExtensionTests.TestExtensionMission((object)activeMission, filename, (object)os);
                        }
                    }
                    catch (Exception ex)
                    {
                        ++errors;
                        // ISSUE: variable of a compiler-generated type
                        ExtensionTests.\u003C\u003Ec__DisplayClass1 cDisplayClass1_1 = this;
                        // ISSUE: reference to a compiler-generated field
                        string str1 = cDisplayClass1_1.ret + "Error Loading Mission: " + filename;
                        // ISSUE: reference to a compiler-generated field
                        cDisplayClass1_1.ret = str1;
                        // ISSUE: variable of a compiler-generated type
                        ExtensionTests.\u003C\u003Ec__DisplayClass1 cDisplayClass1_2 = this;
                        // ISSUE: reference to a compiler-generated field
                        string str2 = cDisplayClass1_2.ret + "\r\n\r\n" + Utils.GenerateReportFromExceptionCompact(ex) + "\r\n\r\n";
                        // ISSUE: reference to a compiler-generated field
                        cDisplayClass1_2.ret = str2;
                    }
                }
            }));
            errorsAdded = errors;
            return(ret);
        }
Пример #15
0
    internal void onMissionComplete(ActiveMission activeMission)
    {
        var missionEndPosition = activeMission.getRocket().transform.position;

        activeMission.getRocket().onMissionComplete();
        var data = activeMission.getMissionData();

        Debug.Log("onMissionComplete: " + data);
        var completionBonus = data.payloadData.successBonus;

        gameState.registerMissionCompletion(activeMission);
        gameState.funds += completionBonus;

        if (data.payloadData.deployOnSuccess)
        {
            var satellite = Instantiate(satellitePrefab);
            satellite.sprite             = data.payloadData.icon;
            satellite.transform.position = missionEndPosition + new Vector3(Convert.ToSingle(2 * random.NextDouble() - 1), Convert.ToSingle(2 * random.NextDouble() - 1), 0);
        }
    }
Пример #16
0
        public static void SendStartingEmailForActiveExtensionNextFrame(object os_obj)
        {
            OS os = (OS)os_obj;

            if (!string.IsNullOrWhiteSpace(ExtensionLoader.ActiveExtensionInfo.StartingMissionPath))
            {
                os.delayer.Post(ActionDelayer.NextTick(), (Action)(() =>
                {
                    ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath);
                    os.currentMission = activeMission;
                    activeMission.sendEmail(os);
                    activeMission.ActivateSuppressedStartFunctionIfPresent();
                    os.saveGame();
                }));
            }
            if (os.Flags.HasFlag("ExtensionFirstBootComplete"))
            {
                return;
            }
            os.Flags.AddFlag("ExtensionFirstBootComplete");
        }
Пример #17
0
        public static ActiveMission LoadContentMission(string filename)
        {
            if (ComputerLoader.MissionPreLoadComplete != null)
            {
                ComputerLoader.MissionPreLoadComplete();
            }

            mission = new ActiveMission(new List <MisisonGoal>(), null, default)
            {
                willSendEmail         = true,
                reloadGoalsSourceFile = filename
            };
            branches = new List <ActiveMission>();
            mission.email.attachments = new List <string>();

            hasMissionTag = false;

            executor.SetText(LocalizedFileLoader.GetLocalizedFilepath(filename), true);

            foreach (var custom in CustomExecutors)
            {
                var customInstance = (MissionExecutor)Activator.CreateInstance(custom.ExecutorType);
                customInstance.Init(OS.currentInstance, ref mission);
                executor.RegisterTempExecutor(custom.Element, customInstance.Execute, custom.Options);
            }

            if (!executor.TryParse(out var ex))
            {
                throw new FormatException($"{filename}: {ex.Message}", ex);
            }

            var ret = mission;

            mission  = null;
            branches = null;

            return(hasMissionTag ? ret : null);
        }
Пример #18
0
    public void launchMission(MissionData mission)
    {
        Debug.Log("launchMission: " + mission);
        setUiModeMissionControl();

        FlightPlan flightPlan = registry.flightPlans.Where(plan => plan.destination == mission.destinationData).First();
        Rocket     rocket     = GameObject.Instantiate(mission.rocketData.rocketObject);

        rocket.setSprite(mission.rocketData.icon);

        var activeMission = new ActiveMission(this, rocket, mission, Time.time, flightPlan);

        gameState.registerActiveMission(activeMission);
        gameState.funds -= mission.getCost();
        gameState.registerProgress(mission.destinationData.progressionValue);
        activeMission.launch();

        if (missionWillFail(mission))
        {
            float explodeAfter = mission.getDurationSeconds() * 0.1f * Convert.ToSingle(random.NextDouble());
            StartCoroutine(failMission(activeMission, explodeAfter));
        }
    }
Пример #19
0
        /* ActiveMission.load */
        private static ActiveMission LoadMission(ElementInfo info)
        {
            string nextMission = info.Attributes.GetValue("next");

            if (nextMission == "NULL_MISSION")
            {
                return(null);
            }

            string goalsFile = info.Attributes.GetValue("goals");

            string genTarget = info.Attributes.GetValue("genTarget");

            if (!string.IsNullOrWhiteSpace(genTarget))
            {
                MissionGenerationParser.Comp   = genTarget;
                MissionGenerationParser.File   = info.Attributes.GetValue("genFile");
                MissionGenerationParser.Path   = info.Attributes.GetValue("genPath");
                MissionGenerationParser.Target = info.Attributes.GetValue("genTargetName");
                MissionGenerationParser.Other  = info.Attributes.GetValue("genOther");
            }

            if (!Settings.IsInExtensionMode && !goalsFile.StartsWith("Content", StringComparison.Ordinal))
            {
                goalsFile = "Content/" + goalsFile;
            }

            ActiveMission initMission;

            try
            {
                initMission = (ActiveMission)ComputerLoader.readMission(goalsFile);
            }
            catch (Exception ex)
            {
                /* TODO: Error reporting */
                initMission = new ActiveMission(
                    new List <MisisonGoal>(),
                    "NONE",
                    new MailServer.EMailData("Unknown", "Unknown", "Unknown", new List <string>())
                    );
            }

            string sender  = "ERRORBOT";
            string subject = "ERROR";
            string body    = "ERROR :: MAIL LOAD FAILED";

            var mailData = info.Children.FirstOrDefault(e => e.Name == "email");

            if (mailData != null)
            {
                sender  = Folder.deFilter(mailData.Attributes.GetValue("sender"));
                subject = Folder.deFilter(mailData.Attributes.GetValue("subject"));
                body    = Folder.deFilter(mailData.Value);
            }

            var loadedMission = new ActiveMission(
                initMission.goals,
                nextMission,
                new MailServer.EMailData(sender, body, subject, initMission.email.attachments)
                )
            {
                /* "activeCheck" check originally botched... twice. */
                activeCheck           = info.Attributes.GetBool("activeCheck") || initMission.activeCheck,
                reloadGoalsSourceFile = goalsFile,
                requiredRank          = info.Attributes.GetInt("reqRank", 0)
            };

            var endFuncData = info.Children.FirstOrDefault(e => e.Name == "endFunc");

            if (endFuncData == null)
            {
                /* TODO: Error reporting */
            }


            loadedMission.endFunctionName  = endFuncData.Attributes.GetValue("name");
            loadedMission.endFunctionValue = endFuncData.Attributes.GetInt("val");

            var postingData = info.Children.FirstOrDefault(e => e.Name == "posting");

            if (postingData == null)
            {
                /* TODO: Error reporting */
            }

            loadedMission.postingTitle = Folder.deFilter(postingData.Attributes.GetValue("title"));
            loadedMission.postingBody  = Folder.deFilter(postingData.Value);

            return(loadedMission);
        }
Пример #20
0
 public void AddActiveMission(ActiveMission actMiss)
 {
     ActiveMissions.Add(actMiss);
     Messenger <ActiveMission> .Broadcast(EVENT_ACTIVE_MISSION_ADDED, actMiss);
 }
Пример #21
0
 public void registerActiveMission(ActiveMission mission)
 {
     totalLaunchAttempts++;
     missions.Add(mission);
 }
Пример #22
0
 public virtual void Init(OS os, ref ActiveMission mission)
 {
     Os      = os;
     Mission = mission;
 }
Пример #23
0
        private void OnActiveMissionAdded(ActiveMission actMiss)
        {
            ActiveMissionViewController view = new ActiveMissionViewController(actMiss, LineMaterial);

            _Views.Add(actMiss, view);
        }
Пример #24
0
 public void registerMissionFailure(ActiveMission mission)
 {
     missions.Remove(mission);
 }
Пример #25
0
 internal static bool SkipNullMissions(ActiveMission m) => m != null;
Пример #26
0
        private IEnumerator RemoveActiveMission(float waitTime, ActiveMission actMiss)
        {
            yield return(new WaitForSeconds(waitTime));

            _Model.RemoveActiveMission(actMiss);
        }
Пример #27
0
        public static string TestExtensionMission(object mission, string filepath, object os)
        {
            string        str1          = "";
            ActiveMission activeMission = (ActiveMission)mission;
            string        str2          = File.ReadAllText(filepath);
            string        str3          = str1 + ExtensionTests.TestTagisClosed("missionEnd", str2) + ExtensionTests.TestTagisClosed("missionStart", str2) + ExtensionTests.TestTagisClosed("nextMission", str2) + ExtensionTests.TestTagisClosed("goals", str2) + ExtensionTests.TestTagisClosed("email", str2) + ExtensionTests.TestTagisClosed("sender", str2) + ExtensionTests.TestTagisClosed("subject", str2) + ExtensionTests.TestTagisClosed("body", str2) + ExtensionTests.TestTagisClosed("attachments", str2);

            if (!str2.Contains("</attachments>"))
            {
                str3 = str3 + "File does not contain attachments tag at the end of the email! It needs to be there!" + "\r\n";
            }
            int count = Regex.Matches(str2, "<goal ").Count;

            if (activeMission.goals.Count != count && activeMission.goals.Count < count)
            {
                string str4 = str3 + "File defines some goals that are not being correctly parsed in! (" + (object)activeMission.goals.Count + " loaded vs " + (object)count + " in file)" + "\r\nCheck your syntax and tags! Valid Goals:\r\n";
                for (int index = 0; index < activeMission.goals.Count; ++index)
                {
                    str4 = str4 + "\r\n" + activeMission.goals[index].ToString().Replace("Hacknet.Mission.", "");
                }
                str3 = str4 + "\r\n";
            }
            if (string.IsNullOrWhiteSpace(activeMission.startFunctionName) && str2.Contains("<missionStart"))
            {
                str3 = str3 + "File contains missionStart, but it's not being correctly parsed in. It might be out of order in the file." + "\r\n";
            }
            if (activeMission.startFunctionName != null)
            {
                try
                {
                    if (!activeMission.startFunctionName.Contains("addRank"))
                    {
                        MissionFunctions.runCommand(activeMission.startFunctionValue, activeMission.startFunctionName);
                    }
                }
                catch (Exception ex)
                {
                    str3 = str3 + "Error running start function " + activeMission.startFunctionName + "\r\n" + Utils.GenerateReportFromException(ex);
                }
            }
            if (string.IsNullOrWhiteSpace(activeMission.endFunctionName) && str2.Contains("<missionEnd"))
            {
                str3 = str3 + "File contains missionEnd, but it's not being correctly parsed in. It might be out of order in the file." + "\r\n";
            }
            if (activeMission.endFunctionName != null)
            {
                try
                {
                    if (!activeMission.endFunctionName.Contains("addRank"))
                    {
                        MissionFunctions.runCommand(activeMission.endFunctionValue, activeMission.endFunctionName);
                    }
                }
                catch (Exception ex)
                {
                    str3 = str3 + "Error running end function " + activeMission.endFunctionName + "\r\n" + Utils.GenerateReportFromException(ex);
                }
            }
            string str5 = TestSuite.TestMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath, os);

            if (!string.IsNullOrWhiteSpace(str5))
            {
                str3 += str5;
            }
            if (str3.Length > 1)
            {
                return("Mission Errors for " + filepath.Replace("\\", "/") + ":\r\n" + str3);
            }
            return("");
        }
Пример #28
0
        public static string TestMission(string missionName, object os_obj)
        {
            string str1 = "";
            OS     os   = (OS)os_obj;

            if (TestSuite.TestedMissionNames.Contains(missionName))
            {
                return(str1);
            }
            try
            {
                if (!File.Exists(missionName))
                {
                    str1 = str1 + "Invalid Mission Path! : " + missionName + "\r\n";
                }
                ActiveMission activeMission = (ActiveMission)ComputerLoader.readMission(missionName);
                TestSuite.ActiveObjectID = missionName;
                string str2 = "";
                for (int index = 0; index < activeMission.goals.Count; ++index)
                {
                    string str3 = activeMission.goals[index].TestCompletable();
                    if (str3 != null && str3.Length > 0)
                    {
                        str2 = str2 + missionName + " Goal[" + (object)index + "] " + activeMission.goals[index].ToString() + " :: " + str3 + "\r\n";
                    }
                }
                try
                {
                    if (!string.IsNullOrWhiteSpace(activeMission.startFunctionName))
                    {
                        if (!Utils.CheckStringIsRenderable(activeMission.startFunctionName))
                        {
                            str1 = str1 + "Mission " + missionName + " has unrenderable start function " + Utils.CleanStringToRenderable(activeMission.startFunctionName);
                        }
                        MissionFunctions.runCommand(activeMission.startFunctionValue, activeMission.startFunctionName);
                    }
                    if (!string.IsNullOrWhiteSpace(activeMission.endFunctionName))
                    {
                        if (!Utils.CheckStringIsRenderable(activeMission.endFunctionName))
                        {
                            str1 = str1 + "Mission " + missionName + " has unrenderable end function " + Utils.CleanStringToRenderable(activeMission.endFunctionName);
                        }
                        MissionFunctions.runCommand(activeMission.endFunctionValue, activeMission.endFunctionName);
                    }
                    string str3           = Directory.GetCurrentDirectory() + "/";
                    string fileLoadPrefix = Utils.GetFileLoadPrefix();
                    if (fileLoadPrefix == "Content/")
                    {
                        fileLoadPrefix += "Missions/";
                    }
                    else if (!fileLoadPrefix.StartsWith("Extensions"))
                    {
                        str3 = "";
                    }
                    string path = str3 + LocalizedFileLoader.GetLocalizedFilepath(fileLoadPrefix + activeMission.nextMission);
                    if (!(activeMission.nextMission == "NONE") && !File.Exists(path))
                    {
                        str1 = str1 + "\r\nNextMission Tag for mission \"" + missionName + "\" has nonexistent next mission path: " + activeMission.nextMission + "\r\n";
                    }
                }
                catch (Exception ex)
                {
                    str1 = str1 + "Error running start or end mission function of mission: " + missionName + "\r\nStart Func: " + activeMission.startFunctionName + "\r\nEnd Func: " + activeMission.endFunctionName;
                    str1 = str1 + "\r\n" + Utils.GenerateReportFromException(ex) + "\r\n";
                }
                if (str2.Length > 0)
                {
                    str1 = str1 + str2 + "--------------\r\n";
                }
                TestSuite.TestedMissionNames.Add(missionName);
                string str4 = "Content/Missions/";
                if (Settings.IsInExtensionMode)
                {
                    str4 = ExtensionLoader.ActiveExtensionInfo.FolderPath + "/";
                }
                List <ActiveMission> activeMissionList = new List <ActiveMission>();
                for (int index = 0; index < os.branchMissions.Count; ++index)
                {
                    activeMissionList.Add(os.branchMissions[index]);
                }
                if (activeMission.nextMission != null && activeMission.nextMission.ToLower() != "none")
                {
                    str1 += TestSuite.TestMission(str4 + activeMission.nextMission, (object)os);
                }
                for (int index = 0; index < activeMissionList.Count; ++index)
                {
                    string localizedFilepath = LocalizedFileLoader.GetLocalizedFilepath(activeMissionList[index].reloadGoalsSourceFile);
                    if (!TestSuite.TestedMissionNames.Contains(localizedFilepath))
                    {
                        Console.WriteLine("testing Branch Mission " + localizedFilepath);
                        str1 += TestSuite.TestMission(localizedFilepath, (object)os);
                    }
                }
            }
            catch (Exception ex)
            {
                str1 = str1 + "Error Loading " + missionName + "\r\n" + ex.ToString();
            }
            return(str1);
        }
Пример #29
0
        static MissionLoader()
        {
            EventManager.onPluginUnload += OnPluginUnload;

            executor.RegisterExecutor("mission", (exec, info) =>
            {
                hasMissionTag       = true;
                mission.activeCheck = info.Attributes.GetBool("activeCheck");
                mission.ShouldIgnoreSenderVerification = info.Attributes.GetBool("shouldIgnoreSenderVerification");
            });
            executor.RegisterExecutor("mission.goals.goal", (exec, info) => mission.goals.Add(LoadGoal(info)), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.missionStart", (exec, info) =>
            {
                var function = info.Content ?? throw new FormatException("missionStart with no mission function!");
                var val      = info.Attributes.GetInt("val", 1);
                if (info.Attributes.GetBool("suppress", Settings.IsInExtensionMode))
                {
                    mission.addStartFunction(val, function);
                }
                else
                {
                    MissionFunctions.runCommand(val, function);
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.missionEnd", (exec, info) =>
            {
                mission.addEndFunction(info.Attributes.GetInt("val", 1), info.Content ?? throw new FormatException("missionEnd with no mission function!"));
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.nextMission", (exec, info) =>
            {
                mission.willSendEmail = !info.Attributes.GetBool("IsSilent", false);
                mission.nextMission   = info.Content ?? "NONE";
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.branchMissions.branch", (exec, info) =>
            {
                var filePrefix      = Settings.IsInExtensionMode ? ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" : "Content/Missions/";
                var currentMission  = mission;
                var currentBranches = branches;
                mission             = null;
                branches            = null;
                exec.SaveState();
                currentBranches.Add(LoadContentMission(filePrefix + info.Content));
                exec.PopState();
                mission  = currentMission;
                branches = currentBranches;
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.branchMissions", (exec, info) => OS.currentInstance.branchMissions = branches, ParseOption.FireOnEnd);
            executor.RegisterExecutor("mission.posting", (exec, info) =>
            {
                mission.postingTitle = info.Attributes.GetString("title", "UNKNOWN").Filter();
                mission.postingBody  = info.Content ?? "UNKNOWN";
                mission.postingAcceptFlagRequirements = info.Attributes.GetString("reqs").Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries);
                mission.requiredRank = info.Attributes.GetInt("requiredRank");
                mission.difficulty   = info.Attributes.GetInt("difficulty");
                mission.client       = info.Attributes.GetString("client").Filter();
                mission.target       = info.Attributes.GetString("target").Filter();
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.sender", (exec, info) => mission.email.sender   = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.subject", (exec, info) => mission.email.subject = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.body", (exec, info) => mission.email.body       = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.attachments.link", (exec, info) =>
            {
                var comp = ComputerLookup.FindById(info.Attributes.GetString("comp"));
                if (comp != null)
                {
                    mission.email.attachments.Add($"link#%#{comp.name}#%#{comp.ip}");
                }
            });
            executor.RegisterExecutor("mission.email.attachments.account", (exec, info) =>
            {
                var comp = info.Attributes.GetComp("comp");
                mission.email.attachments.Add(
                    $"account#%#{comp.name}#%#{comp.ip}#%#{info.Attributes.GetString("user", "UNKNOWN").Filter()}#%#{info.Attributes.GetString("pass", "UNKNOWN").Filter()}"
                    );
            });
            executor.RegisterExecutor("mission.email.attachments.note", (exec, info) =>
            {
                mission.email.attachments.Add($"note#%#{info.Attributes.GetString("title", "Data").Filter()}#%#{info.Content.Filter()}");
            }, ParseOption.ParseInterior);
        }