Наследование: Script
Пример #1
0
        public void ExecuteTest3()
        {
            var exp = new Mod(new Number(0), new Number(5));
            var result = exp.Execute();

            Assert.Equal(0.0, result);
        }
Пример #2
0
		public static void CreateModFile( string ckDir, Mod mod )
		{
			FileInfo mpath = new FileInfo( ckDir + @"/mod/" + mod.ModFile );
			StreamWriter mw = new StreamWriter( mpath.Open( FileMode.Create, FileAccess.Write ), Encoding.GetEncoding( 1252 ) );

			mw.WriteLine( "name = \"" + mod.Name + "\"" );

			mw.WriteLine( "path = \"" + mod.Path + "\"" );

			mw.WriteLine();

			foreach( string e in mod.Extends )
				mw.WriteLine( "extend = \"" + e + "\"" );

			foreach( string e in mod.Replaces )
				mw.WriteLine( "replace_path = \"" + e + "\"" );

			if( mod.Dependencies.Count >= 0 )
			{
				mw.Write( "dependencies = {" );
				foreach( string s in mod.Dependencies )
					mw.Write( "\"" + s + "\" " );
				mw.WriteLine( "}" );
			}

			mw.Dispose();
		}
Пример #3
0
        public void ExecuteTest1()
        {
            var exp = new Mod(new Number(25), new Number(7));
            var result = exp.Execute();

            Assert.Equal(4.0, result);
        }
        /// <summary>Returns true if the mod is classified as a "preinstalled mod".</summary>
        public static bool IsPreinstalledMod(Mod mod)
        {
            var folderName = mod.Folder;

            return PreinstalledModsList.Contains(folderName) ||
                   OtherClassifiedAsPreinstalled.Contains(folderName);
        }
Пример #5
0
            private static void LoadModJSON(string[] modDirectories)
            {
                foreach (string modName in modDirectories)
                {
                    if (new DirectoryInfo(modName).Name == "Localization")
                    {
                        continue;
                    }
                    Mod m = new Mod(new DirectoryInfo(modName).Name);
                    string jsonFilename = modName + "/modinfo.json";
                    string rawJSON = JSONSystem.JSON.GetRawJSONFromFile(jsonFilename);
                    JSONNode output = JSONSystem.JSON.Parse(rawJSON);

                    JSONArray scripts = output["scripts"].AsArray;
                    foreach (JSONNode node in scripts)
                    {
                        m.AddScript(node);
                    }

                    JSONArray sprites = output["sprites"].AsArray;
                    foreach (JSONNode node in sprites)
                    {
                        m.AddSprite(node);
                    }
                    LoadGameModJSON(output, m);
                    AddMod(m);
                }
            }
        public DesignTimeModLibraryViewModel() {
            var game = new Arma1Game(Guid.NewGuid(), new GameSettingsController());
            var collectionGroup = new ModLibraryGroupViewModel(this, "Collections",
                icon: SixIconFont.withSIX_icon_Folder);
            var collections =
                new CustomCollectionLibraryItemViewModel(this,
                    new CustomCollection(Guid.NewGuid(), game) {Name = "Test ModSet"},
                    collectionGroup);
            var subscribedCollections =
                new SubscribedCollectionLibraryItemViewModel(this,
                    new SubscribedCollection(Guid.NewGuid(), Guid.NewGuid(), game) {Name = "Test ModSet3"},
                    collectionGroup);
            var mod = new Mod(Guid.Empty) {
                Name = "@TESTMOD",
                FullName = "Da Full name fewafefiejaofijeafoijeafo ieafioj eaoi",
                Author = "The Author",
                Version = "1.2.0"
            };
            collections.Items.Add(new CustomCollection(Guid.NewGuid(), game) {
                Name = "Some ModSet wuith faopek faof aepokf poaefpokpof  eaf",
                Author = "Some author",
                Version = "1.0.2"
            });
            collections.Items.Add(mod);
            collections.SelectedItem = mod;

            // TODO
            //CreateItemsView(
            //    new ReactiveList<ContentLibraryItem>(new[]
            //    {subscribedCollections, sharedCollections, localCollections}), new LibraryGroup[0]);
            SelectedItem = collections;
        }
Пример #7
0
 public static int NewDust(Vector2 Position, int Width, int Height, Mod mod, string name, float SpeedX = 0f, float SpeedY = 0f, int Alpha = 0, Color newColor = default(Color), float Scale = 1f)
 {
     int dust = Dust.NewDust(Position, Width, Height, 0, SpeedX, SpeedY, Alpha, newColor, Scale);
     Main.dust[dust].modDust = mod.dusts[name];
     mod.dusts[name].OnSpawn(Main.dust[dust]);
     return dust;
 }
Пример #8
0
        public void ExecuteTest4()
        {
            var exp = new Mod(new Number(5), new Number(0));
            var result = exp.Execute();

            Assert.Equal(double.NaN, result);
        }
Пример #9
0
 public void SetResult(Mod mod, string itemName, int stack = 1)
 {
     if(mod == null)
     {
         mod = this.mod;
     }
     this.SetResult(mod.ItemType(itemName), stack);
 }
Пример #10
0
 public void AddCraftGroup(Mod mod, string name, int stack = 1)
 {
     if (mod == null)
     {
         mod = this.mod;
     }
     this.AddCraftGroup(mod.GetCraftGroup(name), stack);
 }
Пример #11
0
 public void AddIngredient(Mod mod, string itemName, int stack = 1)
 {
     if(mod == null)
     {
     mod = this.mod;
     }
     this.AddIngredient(mod.ItemType(itemName), stack);
 }
 public IEnumerable<ActivityItem> LoadMod(Mod mod)
 {
     foreach (var item in loadMod(mod.FullFolderPath))
     {
         item.Mod = mod;
         yield return item;
     }
 }
Пример #13
0
		internal string defaultKey; // from mod.Load
		//string configurationString; // Prevent 2 mods from having same hotkey

		public ModHotkey(string name, Mod mod, string defaultKey)
		{
			this.name = name;
			this.mod = mod;
			//this.currentKey = currentKey;
			this.defaultKey = defaultKey;
			this.displayName = mod.Name + ": " + name;
			//configurationString = mod.Name + "_" + "HotKey" + "_" + name.Replace(' ', '_');
		}
Пример #14
0
 public BlockInfo(DataTable dataTable, String name, ModList modList, Mod curMod)
 {
     data = dataTable;
     this.modList = modList;
     this.curMod = curMod;
     this.name = name;
     InitializeComponent();
     loadData();
 }
 public DesignTimeLicenseDialogViewModel() {
     var msLicense = new ModSetLicenses("Test Mod") {IsModSetLicensesExpanded = true};
     ModSetLicenses = new List<ModSetLicenses> {msLicense};
     var mod = new Mod(Guid.NewGuid()) {Name = "Test Mod", ModVersion = "1.0.0"};
     var ml = new ModLicense(null, String.Format("{0} {1}", mod.Name, mod.ModVersion)) {
         IsModLicenseExpanded = true
     };
     msLicense.ModLicenses.Add(ml);
 }
Пример #16
0
		internal static ModPlayer GetModPlayer(Player player, Mod mod, string name)
		{
			IDictionary<string, int> modIndexes = indexes[mod.Name];
			if (!modIndexes.ContainsKey(name))
			{
				return null;
			}
			return player.modPlayers[modIndexes[name]];
		}
Пример #17
0
    public ModButtonViewModel(Mod.Header.Button button)
    {
        this.button = button;
        AssignedKey = Configuration.GetString("Mods." + button.Mod.Game.GameConfiguration.ID + "." + button.Mod.ID + ".Buttons." + button.ID);
        if (AssignedKey == "")
        {
            Key = button.StandardKey;

        }
    }
        /// <summary>Creates a new view model wrapper for a mod.</summary>
        public ModViewModel(Mod mod, ModManager modManager, PresetManager presetManager)
            : base()
        {
            this.modManager = modManager;
            this.presetManager = presetManager;

            Mod = mod;

            DeleteModCommand = new Command(DeleteMod);
            AddModToPresetCommand = new Command<Preset>(AddToPreset);
            NewPresetForModCommand = new Command(AddToNewPreset);
        }
 public bool ModIsInAPreset(Mod mod)
 {
     if (presetModsBuffer == null)
     {
         LoadModsBuffer();
     }
     if (presetModsBuffer.Contains(mod.Folder))
     {
         return true;
     }
     return false;
 }
Пример #20
0
 public static void CheckItems(Mod mod, Player player, ref int damage, ref float knockBack)
 {
     // Loop throught the accessories of the player.
     for (int i = 3; i < 8 + player.extraAccessorySlots; i++)
     {
         // -50% knockback.
         if (player.armor[i].type == mod.ItemType("TornadoAnklet") || player.armor[i].type == mod.ItemType("HeavyRing"))
             knockBack /= 2;
         else if (player.armor[i].type == mod.ItemType("ReinforcedRing"))
             knockBack -= (knockBack / 5); // 20% less knockback
     }
 }
        /// <summary>Enables a mod and returns the new location of the mod</summary>
        public void EnableMod(Mod mod)
        {
            var source = mod.FullFolderPath;
            var destination = Path.Combine(settings.Get().CCInstallDirectory, mod.Folder);

            Directory.Move(source, destination);

            InvalidateCache();

            mod.IsEnabled = true;
            mod.FullFolderPath = destination;
            mod.IconPath = ModScanner.FindModImagePath(destination);
        }
        /// <summary>Disables a mod and returns the new location of the mod</summary>
        public void DisableMod(Mod mod)
        {
            var source = mod.FullFolderPath;
            var destination = Path.Combine(DisabledModPath, mod.Folder);

            Directory.Move(source, destination);

            InvalidateCache();

            mod.IsEnabled = false;
            mod.FullFolderPath = destination;
            mod.IconPath = ModScanner.FindModImagePath(destination);
        }
 public void AddModToPreset(Mod mod, Preset preset)
 {
     if (!ModIsInAPreset(mod))
     {
         preset.Add(mod);
         if (mod.IsEnabled != preset.IsEnabled)
         {
             modManager.ToggleEnabled(mod);
         }
         SavePreset(preset);
         LoadModsBuffer();
     }
 }
Пример #24
0
 public static void AddBossRecipes(Mod mod)
 {
     ModRecipe recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.SuspiciousLookingEye, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.WormFood, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.BloodySpine, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.Abeemination, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.GuideVoodooDoll);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.MechanicalEye, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.MechanicalWorm, 20);
     recipe.AddRecipe();
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(null, "BossItem", 10);
     recipe.AddTile(null, "ExampleWorkbench");
     recipe.SetResult(ItemID.MechanicalSkull, 20);
     recipe.AddRecipe();
     // Here we see another way to retrieve type ids from classnames. Useful for those who program in an IDE who wish to avoid spelling mistakes.
     recipe = new ModRecipe(mod);
     recipe.AddIngredient(mod.ItemType<Items.BossItem>(), 10);
     recipe.AddTile(mod.TileType<Tiles.ExampleWorkbench>());
     recipe.SetResult(ItemID.LihzahrdPowerCell, 20);
     recipe.AddRecipe();
 }
Пример #25
0
		public void AddIngredient(Mod mod, string itemName, int stack = 1)
		{
			if (mod == null)
			{
				mod = this.mod;
			}
			int type = mod.ItemType(itemName);
			if (type == 0)
			{
				string message = "The item " + itemName + " does not exist in the mod " + mod.Name + "." + Environment.NewLine;
				message += "If you are trying to use a vanilla item, try removing the first argument.";
				throw new RecipeException(message);
			}
			this.AddIngredient(type, stack);
		}
Пример #26
0
        public static bool has_mod(this Expression expr, Mod mod)
        {
            var is_exact = ((int)mod & 65536) == 65536;
            mod = (Mod)((int)mod & ~65536);

            var modded = expr as Modded;
            if (modded != null)
            {
                if (is_exact) return modded.Mod == mod;
                else return mod == 0 || (modded.Mod & ~mod) == 0;
            }
            else
            {
                if (is_exact) return mod == 0;
                else return true;
            }
        }
Пример #27
0
        public void checkChanged(Mod mod)
        {
            if (!string.IsNullOrEmpty(mod.Code))
            {
                string fileName = mod.Code.Split(' ')[1].Split('\\').Last();

                if (mm.inUse(fileName, mod.IsChecked))
                {
                    if (!confirm(Strings.text["FileInUse"], "Caution"))
                    {
                        //Might be a dirty fix, but because the value is changed and triggers the OnChangedValue again I would have no indicator it is because user canceled confirmBox
                        _skipNextChange = true;
                        mod.IsChecked = false;
                        return;
                    }
                }

                mm.UpdateFile(mod, fileName);
            }
        }
Пример #28
0
        public static void TestRecipeEditor(Mod mod)
        {
            RecipeFinder finder = new RecipeFinder();
            finder.AddIngredient(ItemID.Chain);
            foreach (Recipe recipe in finder.SearchRecipes())
            {
                RecipeEditor editor = new RecipeEditor(recipe);
                editor.DeleteIngredient(ItemID.Chain);
            }

            finder = new RecipeFinder();
            finder.AddRecipeGroup("IronBar");
            finder.AddTile(TileID.Anvils);
            finder.SetResult(ItemID.Chain, 10);
            Recipe recipe2 = finder.FindExactRecipe();
            if (recipe2 != null)
            {
                RecipeEditor editor = new RecipeEditor(recipe2);
                editor.DeleteRecipe();
            }
        }
Пример #29
0
        public Brush(Mod game, Rectangle rect)
            : base(rect, "Brush")
        {
            Game = game;

            Rectangle pageRect = this.Rectangle; // tab pages are the size of the tab control
            pageRect.X = pageRect.Y = 0;
            pageRect.Height = 148;

            Children.Add(new XG_Button(new Rectangle(350, 5, 60, 20), "Clear", this.Clear_Clicked));

            Children.Add(new XG_Button(new Rectangle(260, 5, 80, 20), "Set shape", this.Set_Clicked));

            XGTabControl tab = new XGTabControl(pageRect);
            Children.Add(tab); // add the tab control to our child control list

            freeStyle = new FreeStyle(game, pageRect);
            tab.Children.Add(freeStyle);

            copyPaste = new CopyPaste(game, pageRect);
            tab.Children.Add(copyPaste);
        }
        public override void NPCLoot(NPC npc)
        {
            Player      player    = Main.player[npc.lastInteraction];
            FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>();

            if (modPlayer.PlatinumEnchant && !npc.boss && firstLoot)
            {
                int chance = 5;
                int bonus  = 2;

                if (modPlayer.WillForce || modPlayer.WizardEnchant)
                {
                    bonus = 5;
                }

                if (Main.rand.Next(chance) == 0)
                {
                    firstLoot = false;
                    for (int i = 1; i < bonus; i++)
                    {
                        npc.NPCLoot();
                    }

                    int num1 = 36;
                    for (int index1 = 0; index1 < num1; ++index1)
                    {
                        Vector2 vector2_1 = (Vector2.Normalize(npc.velocity) * new Vector2((float)npc.width / 2f, (float)npc.height) * 0.75f).RotatedBy((double)(index1 - (num1 / 2 - 1)) * 6.28318548202515 / (double)num1, new Vector2()) + npc.Center;
                        Vector2 vector2_2 = vector2_1 - npc.Center;
                        int     index2    = Dust.NewDust(vector2_1 + vector2_2, 0, 0, DustID.PlatinumCoin, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f);
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].noLight   = true;
                        Main.dust[index2].velocity  = vector2_2;
                    }
                }
            }

            firstLoot = false;

            //patreon gang
            if (SoulConfig.Instance.PatreonOrb && npc.type == NPCID.Golem && Main.rand.Next(10) == 0)
            {
                Item.NewItem(npc.Hitbox, ModContent.ItemType <Patreon.Daawnz.ComputationOrb>());
            }

            if (SoulConfig.Instance.PatreonDoor && npc.type == NPCID.Squid && Main.rand.Next(50) == 0)
            {
                Item.NewItem(npc.Hitbox, ModContent.ItemType <Patreon.Sam.SquidwardDoor>());
            }

            if (SoulConfig.Instance.PatreonKingSlime && npc.type == NPCID.KingSlime && FargoSoulsWorld.MasochistMode && Main.rand.Next(100) == 0)
            {
                Item.NewItem(npc.Hitbox, ModContent.ItemType <Patreon.Catsounds.MedallionoftheFallenKing>());
            }

            if (SoulConfig.Instance.PatreonPlant && npc.type == NPCID.Dryad && Main.bloodMoon && player.ZoneJungle)
            {
                Item.NewItem(npc.Hitbox, ModContent.ItemType <Patreon.LaBonez.PiranhaPlantVoodooDoll>());
            }

            //boss drops
            if (Main.rand.Next(FargoSoulsWorld.MasochistMode ? 3 : 10) == 0)
            {
                switch (npc.type)
                {
                case NPCID.KingSlime:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <SlimeKingsSlasher>());
                    break;

                case NPCID.EyeofCthulhu:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <LeashOfCthulhu>());
                    break;

                case NPCID.EaterofWorldsHead:
                case NPCID.EaterofWorldsBody:
                case NPCID.EaterofWorldsTail:
                    bool dropItems = true;
                    for (int i = 0; i < 200; i++)
                    {
                        if (Main.npc[i].active && i != npc.whoAmI && (Main.npc[i].type == NPCID.EaterofWorldsHead || Main.npc[i].type == NPCID.EaterofWorldsBody || Main.npc[i].type == NPCID.EaterofWorldsTail))
                        {
                            dropItems = false;
                            break;
                        }
                    }
                    if (dropItems)
                    {
                        Item.NewItem(npc.Hitbox, ModContent.ItemType <EaterStaff>());
                    }
                    break;

                case NPCID.BrainofCthulhu:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <BrainStaff>());
                    break;

                case NPCID.QueenBee:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <TheSmallSting>());
                    break;

                case NPCID.SkeletronHead:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <BoneZone>());
                    break;

                case NPCID.WallofFlesh:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <FleshHand>());
                    break;

                case NPCID.TheDestroyer:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <DestroyerGun>());
                    break;

                case NPCID.SkeletronPrime:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <RefractorBlaster>());
                    break;

                case NPCID.Retinazer:
                    if (!EModeGlobalNPC.BossIsAlive(ref EModeGlobalNPC.spazBoss, NPCID.Spazmatism))
                    {
                        Item.NewItem(npc.Hitbox, ModContent.ItemType <TwinRangs>());
                    }
                    break;

                case NPCID.Spazmatism:
                    if (!EModeGlobalNPC.BossIsAlive(ref EModeGlobalNPC.retiBoss, NPCID.Retinazer))
                    {
                        Item.NewItem(npc.Hitbox, ModContent.ItemType <TwinRangs>());
                    }
                    break;

                case NPCID.Plantera:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <Dicer>());
                    break;

                case NPCID.Golem:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <RockSlide>());
                    break;

                case NPCID.DukeFishron:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <FishStick>());
                    break;

                case NPCID.DD2Betsy:
                    Item.NewItem(npc.Hitbox, ModContent.ItemType <DragonBreath>());
                    break;
                }
            }

            if (npc.type == NPCID.BigMimicJungle)
            {
                switch (Main.rand.Next(3))
                {
                case 0: Item.NewItem(npc.Hitbox, ModContent.ItemType <Vineslinger>()); break;

                case 1: Item.NewItem(npc.Hitbox, ModContent.ItemType <Mahoguny>()); break;

                case 2: Item.NewItem(npc.Hitbox, ModContent.ItemType <OvergrownKey>()); break;
                }
            }

            if (Fargowiltas.Instance.CalamityLoaded && Revengeance && FargoSoulsWorld.MasochistMode && Main.bloodMoon && Main.moonPhase == 0 && Main.raining && Main.rand.Next(10) == 0)
            {
                Mod calamity = ModLoader.GetMod("CalamityMod");

                if (npc.type == calamity.NPCType("DevourerofGodsHeadS"))
                {
                    Item.NewItem(npc.Hitbox, calamity.ItemType("CosmicPlushie"));
                }
            }
        }
Пример #31
0
        public void ValidateAndFillDetails()
        {
            if (IsNullOrEmpty(Title))
            {
                Title = $"{FounderName}'s game";
            }
            if (IsNullOrEmpty(EngineVersion) || (Mode != AutohostMode.None))
            {
                EngineVersion = server.Engine;
            }
            server.Downloader.GetResource(DownloadType.ENGINE, server.Engine);

            switch (Mode)
            {
            case AutohostMode.Game1v1:
                MaxPlayers = 2;
                break;

            case AutohostMode.Planetwars:
                if (MaxPlayers < 2)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.GameChickens:
                if (MaxPlayers < 2)
                {
                    MaxPlayers = 10;
                }
                break;

            case AutohostMode.GameFFA:
                if (MaxPlayers < 3)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.Teams:
                if (MaxPlayers < 4)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.None:
                if (MaxPlayers == 0)
                {
                    MaxPlayers = 16;
                }
                break;
            }
            if (MaxPlayers > DynamicConfig.Instance.MaximumBattlePlayers && !IsAutohost)
            {
                MaxPlayers = DynamicConfig.Instance.MaximumBattlePlayers;
            }

            HostedMod = MapPicker.FindResources(ResourceType.Mod, ModName ?? server.Game ?? GlobalConst.DefaultZkTag).FirstOrDefault();
            HostedMap = MapName != null
                ? MapPicker.FindResources(ResourceType.Map, MapName).FirstOrDefault()
                : MapPicker.GetRecommendedMap(GetContext());

            ModName = HostedMod?.InternalName ?? ModName ?? server.Game ?? GlobalConst.DefaultZkTag;
            MapName = HostedMap?.InternalName ?? MapName ?? "Small_Divide-Remake-v04";

            if (HostedMod != null)
            {
                try
                {
                    HostedModInfo = MetaDataCache.ServerGetMod(HostedMod.InternalName);
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Error loading mod metadata for {0} : {1}", HostedMod.InternalName, ex);
                }
            }
        }
 public override ECFieldElement Invert()
 {
     uint[] z = Nat.Create(17);
     Mod.Invert(SecP521R1Field.P, x, z);
     return(new SecP521R1FieldElement(z));
 }
Пример #33
0
 private static string GetModDataFilename(Mod mod)
 {
     // Use filename because title may contains invalid path chars.
     return(string.Format("mod_{0}.txt", mod.FileName));
 }
Пример #34
0
        /// <summary>
        /// This method parses custom attributes offered by the ModAPI to offer
        /// certain abilities like launching a mod ingame or inmenu.
        /// </summary>
        /// <remarks>
        /// This method adds new elements to the XDocument provided to it.
        /// This is because you cant scan efficently for all methods with a certain
        /// attribute. While in-game the ModAPI can use this information to determine
        /// which methods to call when.
        /// </remarks>
        /// <param name="mod">The mod currently parsed.</param>
        /// <param name="configuration">The configuration file where the attributes are saved for quicker lookup while in-game.</param>
        /// <param name="method">The method to parse</param>
        /// <param name="configurationAttributes">A dictionary filled with the attributes to look for.</param>
        public static void ParseCustomAttributes(Mod mod, XDocument configuration, MethodDefinition method, Dictionary <string, TypeDefinition> configurationAttributes)
        {
            for (var k = 0; k < method.CustomAttributes.Count; k++)
            {
                var attribute = method.CustomAttributes[k];
                var attrKey   = attribute.AttributeType.FullName;
                if (configurationAttributes.ContainsKey(attrKey))
                {
                    var attributeType = configurationAttributes[attrKey];
                    var valid         = true;
                    foreach (var interfc in attributeType.Interfaces)
                    {
                        if (interfc.InterfaceType.Name == "IStaticAttribute" && !method.IsStatic)
                        {
                            Debug.Log("Modloader: " + mod.Game.GameConfiguration.Id,
                                      "Method \"" + method.FullName + "\" is using attribute \"" + method.CustomAttributes[k].AttributeType.FullName +
                                      "\" which is only suitable for static methods but isn't marked as static.", Debug.Type.Warning);
                            valid = false;
                        }
                        if (interfc.InterfaceType.Name == "INoParametersAttribute" && method.Parameters.Count > 0)
                        {
                            Debug.Log("Modloader: " + mod.Game.GameConfiguration.Id,
                                      "Method \"" + method.FullName + "\" is using attribute \"" + method.CustomAttributes[k].AttributeType.FullName +
                                      "\" which is only suitable for methods without parameters but has parameters.", Debug.Type.Warning);
                            valid = false;
                        }
                    }
                    if (!valid)
                    {
                        continue;
                    }
                    var names = new List <string>();
                    if (attribute.ConstructorArguments.Count > 0)
                    {
                        foreach (var m in attributeType.Methods)
                        {
                            if (m.IsConstructor)
                            {
                                foreach (var p in m.Parameters)
                                {
                                    names.Add(p.Name);
                                }
                                break;
                            }
                        }
                    }
                    var newElement = new XElement(attributeType.Name);
                    for (var i = 0; i < attribute.ConstructorArguments.Count; i++)
                    {
                        var arg = attribute.ConstructorArguments[i];
                        newElement.SetAttributeValue(names[i], arg.Value);
                    }
                    newElement.Value = method.FullName;
                    newElement.SetAttributeValue("ModID", mod.Id);
                    configuration.Root.Add(newElement);

                    method.CustomAttributes.RemoveAt(k);
                    k--;
                }
            }
        }
        internal static void Prefix(Mod __instance, ref EventArgsInput e)
        {
            ArcadePongMod.pong = __instance;

            e = new EventArgsInput(SButton.A, e.Cursor, new HashSet <SButton>());
        }
Пример #36
0
 public void Start(Mod mod)
 {
     string[] s = mod.Code.Split(' ');
     int counter = 0;
     while (counter <= s.Length)
     {
         switch (s[counter])
         {
             case "SELECT":
                 selectFile(s[counter + 1]);
                 break;
             case "REPLACEWITH":
                 replaceFile(s[counter + 1], mod.Name);
                 break;
         }
         counter += 2;
     }
 }
 public Texture2D GetAnimalShopIconTexture()
 {
     return(CanBePurchased() ? Mod.LoadTexture(AnimalShop.Icon) : null);
 }
Пример #38
0
        public override void PostUpdate()
        {
            cachedPageCount = pages;
            int rand = Main.rand.Next(0, 5000);

            Main.rand.Next(rand);
            if (rand == 0 && Main.raining)
            {
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/ThunderClap"));
            }
            if (displayTimes > SpookyTerrariaUtils.maxDisplayTimes)
            {
                displayTimes = SpookyTerrariaUtils.maxDisplayTimes;
            }
            if (pageDisplayTimer == 0)
            {
                displayTimes = 0;
            }
            // Main.NewText(displayTimes);
            pageDisplayTimer--;
            if (pageDisplayTimer < 0)
            {
                pageDisplayTimer = 0;
            }
            if (msgTimer < 301)
            {
                msgTimer++;
            }
            //byte[] i = new byte[] { 1, 2, 3 };
            //Microsoft.Xna.Framework.Audio.SoundEffect Poop = new Microsoft.Xna.Framework.Audio.SoundEffect(i, 1, Microsoft.Xna.Framework.Audio.AudioChannels.Stereo);
            //poop
            Mod ST = ModLoader.GetMod("SpookyTerraria");

            if (msgTimer == 120)
            {
                Main.NewText($"Spooky Terraria is on  v{ST.Version}.", Color.DarkGray);
            }
            if (msgTimer == 300)
            {
                Main.NewText($"Also, if you manage to find any bugs, please go to the Main Menu and click the Discord Logo and report the issue to my server.", Color.DarkGray);
            }
            IncrementHeartRate(); // Increment Appropriately
            DecrementHeartRate(); // Decrement Appropriately

            hootTimer++;
            breezeTimer++;
            Main.invasionProgress = 0;
            Main.CanStartInvasion(0, false);
            if (hootTimer == 400 && PlayerIsInForest(player) && !player.ZoneSkyHeight)
            {
                if (!ModContent.GetInstance <SpookyConfigClient>().toggleHoots)
                {
                    if (!ModContent.GetInstance <SpookyTerraria>().beatGame)
                    {
                        if (Main.rand.NextFloat() < 0.35f)
                        {
                            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/HootOne"));
                        }
                        else if (Main.rand.NextFloat() < 0.35f)
                        {
                            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/HootTwo"));
                        }
                        hootTimer = 0;
                    }
                }
            }
            // I really need wolves howling in the snow
            if (!ModContent.GetInstance <SpookyConfigClient>().toggleWind)
            {
                if (breezeTimer >= 2650)
                {
                    if (Main.rand.NextFloat() < 0.35f)
                    {
                        Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/Breezes"));
                    }
                    breezeTimer = 0;
                }
            }
            // Main.NewText(stalkerConditionMet);
            // Main.NewText($"{hbDecTimer} <= Decrement, {hbIncTimer} <= Increment");
        }
Пример #39
0
        public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
        {
            if (target.active && spotter) // If this projectile was shot by the spotter
            {
                if (Main.projectile.Any(x => x.active && x.owner == projectile.owner && x.type == Mod.Find <ModProjectile>(nameof(ProjCrosshair)).Type))
                {
                    return; // Doesn't spawn a crosshair if there's already one in the world
                }

                Vector2 position = target.SpriteCenter() + Main.rand.NextVector2(400, 600);
                var     proj     = Projectile.NewProjectileDirect(null,
                                                                  position, Vector2.Zero, Mod.Find <ModProjectile>(nameof(ProjCrosshair)).Type,
                                                                  damage * 5, knockback * 2, projectile.owner);
                var crosshair = proj.ModProjectile as ProjCrosshair;
                crosshair.Target = target.whoAmI;
                proj.netUpdate   = true;
            }
        }
Пример #40
0
 public ModButton GetModButton(Mod mod)
 {
     return(ModSectionsContainer.ChildrenOfType <ModButton>().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())));
 }
 internal static bool Prefix(Mod __instance)
 {
     ArcadePongMod.pong = __instance;
     return(false);
 }