Beispiel #1
0
        [TestMethod()] public void FilterActionTest()
        {
            ActionDef[] defs = new ActionDef[] {
                CreateDef("action", "Default", "all", "Def1"),
                CreateDef("eval", "Code1"),
                CreateDef("action", "Default", "more", "Def2"),
                CreateDef("skip", "splash", "phase", "SplashMod"),
                CreateDef("eval", "Code2"),
            };

            var splash = ModActions.FilterActions(defs, "splashmod", out int defCount);

            Assert.AreEqual(1, splash?.Count, "1 splash actions");
            splash[0].TryGetValue("skip", out object val);
            Assert.AreEqual("splash", val, "splash field");
            splash[0].TryGetValue("all", out val);
            Assert.AreEqual("Def1", val, "splash def 1");
            splash[0].TryGetValue("more", out val);
            Assert.AreEqual("Def2", val, "splash def 2");
            Assert.AreEqual(2, defCount, "splash defCount");

            var main = ModActions.FilterActions(defs, "mainmod", out defCount);

            Assert.AreEqual(2, main?.Count, "2 main actions");
            Assert.AreEqual(2, defCount, "main defCount");
        }
Beispiel #2
0
        public override void Load()
        {
            Harmony.PatchAll();

            Dummy.Group                   = ER_GROUP;
            Vents.Group                   = ER_GROUP;
            TeamAffinity.Group            = ER_GROUP;
            GameMode.Group                = ER_GROUP;
            RespawnTime.Group             = ER_GROUP;
            MaxPoints.Group               = ER_GROUP;
            GameModeInterval.Group        = ER_GROUP;
            ControlPointUseInterval.Group = ER_GROUP;
            FlagCapturerVents.Group       = ER_GROUP;

            IndependendColorsFix.Enable();
            TasksOverlay.Enable();

            LanguageManager.Load(Assembly.GetExecutingAssembly(), "Military.Lang.");
            Role.Init();

            TeamsController.Init();
            TeamAffinityController.Init();
            ModActions.Init();

            RegisterNetworkMessages();
            RegisterComponents();
            RegisterListeners();
            RegisterCustomMaps();

            CommandsController.Register(new TeamAffinityCommand());
        }
Beispiel #3
0
        public static void ResetAll()
        {
            foreach (var SomeRole in ROLES)
            {
                SomeRole.Reset();
            }

            ModActions.ResetAll();
        }
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="actions"></param>
 public void OpenMod(string fileName, ModActions actions)
 {
     foreach (ModAction ma in actions)
     {
         if (ma.Type == "OPEN")
         {
             openModFiles[fileName].Nodes.Add(ma.Body);
             openModFiles[fileName].Expand();
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// Initialises a new instance of the Mod class. Must be inherited (abstract).
 /// </summary>
 public Mod()
 {
     textTemplateReadOnly = true;
     Header                      = new ModHeader();
     Header.Authors              = new ModAuthors();
     Header.History              = new ModHistory();
     Header.IncludedFiles        = new StringCollection();
     Header.FilesToEdit          = new StringCollection();
     Actions                     = new ModActions();
     Header.EasyModCompatibility = new ModVersion();
     Header.Version              = new ModVersion();
 }
        private void comboBoxModArchivePreset_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (isUpdatingSidePanel)
            {
                return;
            }
            foreach (int index in editedIndices)
            {
                ManagedMod editedMod = Mods[index];
                switch (this.comboBoxModArchivePreset.SelectedIndex)
                {
                case 0:     // Please select
                case 1:     // Auto-detect
                    editedMod.Format      = ManagedMod.ArchiveFormat.Auto;
                    editedMod.Compression = ManagedMod.ArchiveCompression.Auto;
                    break;

                case 2:     // General
                    editedMod.Format      = ManagedMod.ArchiveFormat.General;
                    editedMod.Compression = ManagedMod.ArchiveCompression.Compressed;
                    break;

                case 3:     // Textures
                    editedMod.Format      = ManagedMod.ArchiveFormat.Textures;
                    editedMod.Compression = ManagedMod.ArchiveCompression.Compressed;
                    break;

                case 4:     // Audio
                    editedMod.Format      = ManagedMod.ArchiveFormat.General;
                    editedMod.Compression = ManagedMod.ArchiveCompression.Uncompressed;
                    break;
                }
                if (editedMod.Frozen &&
                    (editedMod.Format != editedMod.CurrentFormat ||
                     editedMod.Compression != editedMod.CurrentCompression))
                {
                    ModActions.Unfreeze(editedMod);
                }
            }
            if (!editingBulk)
            {
                UpdateSidePanel();
            }
            UpdateModList();
            UpdateStatusStrip();
            UpdateWarningLabel();
            UpdateSidePanelControls();
            Mods.Save();
        }
Beispiel #7
0
        public static void Update()
        {
            var IsImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;

            foreach (var Action in Actions)
            {
                if (!(IsImpostor && Action.Type == ActionType.PRIMARY) &&
                    !Action.Last && Input.GetKeyDown(Action.Key))
                {
                    ModActions.DoAction(Action.Type);
                }

                Action.Last = Input.GetKeyUp(Action.Key);
            }
        }
 private void textBoxModFolderName_TextChanged(object sender, EventArgs e)
 {
     if (this.textBoxModFolderName.Focused)
     {
         if (ModActions.RenameFolder(editedMod, this.textBoxModFolderName.Text))
         {
             Mods.Save();
             this.textBoxModFolderName.ForeColor = Color.Black;
         }
         else
         {
             //this.textBoxModFolderName.Text = this.editedMod.ManagedFolderName;
             this.textBoxModFolderName.ForeColor = Color.Red;
         }
     }
 }
 // Auto-detect installation options
 private void linkLabelModAutoDetectInstallOptions_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (!editingBulk)
     {
         ModActions.DetectOptimalModInstallationOptions(editedMod);
     }
     else
     {
         foreach (int index in editedIndices)
         {
             ModActions.DetectOptimalModInstallationOptions(Mods[index]);
         }
     }
     UpdateSidePanel();
     UpdateModList();
 }
Beispiel #10
0
        private static void RegisterListeners()
        {
            EventsController.RESET_ALL.Register(() => {
                CustomTasksController.ResetAll();
                Team.FixIfNoEnabled();
                Role.FixIfNoEnabled();

                TeamsController.ResetAll();
                ModActions.ResetAll();
                HealthController.ResetAll();
                EndGameCentral.ResetAll();
                Logic.Mode.GameMode.ResetAll();
            });
            EventsController.GAME_STARTED.Register(() => {
                DoorsController.DestroyDoors();
            });
            EventsController.MAP_INIT.Register(() => {
                Logic.Mode.GameMode.Current.InitMap();
            });
        }
        /*
         * Properties changed:
         */


        private void comboBoxModInstallAs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (isUpdatingSidePanel)
            {
                return;
            }
            foreach (int index in editedIndices)
            {
                ManagedMod editedMod = Mods[index];
                switch (this.comboBoxModInstallAs.SelectedIndex)
                {
                case 0:     // Bundled *.ba2 archive
                    editedMod.Method = ManagedMod.DeploymentMethod.BundledBA2;
                    break;

                case 1:     // Separate *.ba2 archive
                    editedMod.Method = ManagedMod.DeploymentMethod.SeparateBA2;
                    break;

                case 2:     // Loose files
                    editedMod.Method = ManagedMod.DeploymentMethod.LooseFiles;
                    break;
                }
                if (editedMod.Frozen && (editedMod.Method != ManagedMod.DeploymentMethod.SeparateBA2 &&
                                         editedMod.PreviousMethod == ManagedMod.DeploymentMethod.SeparateBA2))
                {
                    ModActions.Unfreeze(editedMod);
                }
            }
            if (!editingBulk)
            {
                UpdateSidePanel();
            }
            UpdateModList();
            UpdateStatusStrip();
            UpdateWarningLabel();
            UpdateSidePanelControls();
            Mods.Save();
        }
Beispiel #12
0
 public static bool Prefix()
 {
     return(ModActions.DoAction(ActionType.PRIMARY));
 }
Beispiel #13
0
        public static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
            {
                foreach (var Control in PlayerControl.AllPlayerControls)
                {
                    Control.nameText.Color = Color.white;
                }

                if (!Military.TeamAffinity.GetValue())
                {
                    return;
                }

                foreach (var(Team, Players) in TeamAffinityController.GetAffinities())
                {
                    foreach (var Player in Players.Select(PlayerTools.GetPlayerById))
                    {
                        Player.nameText.Color = Team.Color;
                    }
                }

                return;
            }

            if (!__instance.Chat.isActiveAndEnabled)
            {
                __instance.Chat.SetVisible(true);
            }

            var Scroll = Input.GetAxis("Mouse ScrollWheel");

            if (Scroll < 0)
            {
                GunController.PreviousGun();
            }
            else if (Scroll > 0)
            {
                GunController.NextGun();
            }

            var LocalPlayer = PlayerControl.LocalPlayer;
            var Dead        = LocalPlayer.Data.IsDead;

            KeyboardController.Update();

            var UseButtonActiveEnabled = __instance.UseButton != null &&
                                         __instance.UseButton.isActiveAndEnabled;

            PlayerTools.CalculateClosest(PlayerControl.LocalPlayer);

            foreach (var Role in Role.ROLES)
            {
                Role.PreUpdate(__instance, UseButtonActiveEnabled, Dead);
            }

            foreach (var Role in Role.ROLES)
            {
                Role.PostUpdate(__instance, UseButtonActiveEnabled, Dead);
            }

            __instance.ReportButton.gameObject.SetActive(false);
            GameMode.Current?.Update(Time.deltaTime);

            ModActions.Update();

            foreach (var Control in PlayerControl.AllPlayerControls)
            {
                var Extra = Control.Extra();
                if (Extra.Team == null)
                {
                    continue;
                }

                var Protection = !Extra.IsReady();
                var Color      = Protection ? PROTECTION : NO_PROTECTION;

                Control.nameText.Color = Protection
                                        ? Extra.Team.ProtectionColor
                                        : Extra.Team.Color;

                Extra.SetHealthBarActive(!Protection);
                Control.myRend.color      = Color;
                Control.HatRenderer.color = Color;

                Control.CurrentPet.rend.color = Color;
                if (Control.CurrentPet.shadowRend != null)
                {
                    Control.CurrentPet.shadowRend.color = Color;
                }

                Control.MyPhysics.Skin.layer.color = Color;

                Extra.Update();
            }
        }
Beispiel #14
0
 public static bool Prefix()
 {
     return(ModActions.DoAction(ActionType.SHOOT));
 }