public static AppDomain CreateDomain(string name, AppDomainSetup setup) { var realSetup = AccessTools.CreateInstance(AppDomainSetupType); Traverse.IterateProperties(setup, realSetup, (pSrc, pTgt) => pTgt.SetValue(pSrc.GetValue())); return(CreateDomainInternal(null, name, null, realSetup) as AppDomain); }
public void Test_AccessTools_CreateInstance() { Assert.IsTrue(AccessTools.CreateInstance <AccessToolsCreateInstance.NoConstructor>().constructorCalled); Assert.IsFalse(AccessTools.CreateInstance <AccessToolsCreateInstance.OnlyNonParameterlessConstructor>().constructorCalled); Assert.IsTrue(AccessTools.CreateInstance <AccessToolsCreateInstance.PublicParameterlessConstructor>().constructorCalled); Assert.IsTrue(AccessTools.CreateInstance <AccessToolsCreateInstance.InternalParameterlessConstructor>().constructorCalled); var instruction = AccessTools.CreateInstance <CodeInstruction>(); Assert.NotNull(instruction.labels); Assert.NotNull(instruction.blocks); }
public MapLayerFractalARGB(long seed, int octaves, float persistence, int scaleA, int scaleR, int scaleG, int scaleB, double ridgedMul = 1.0, double cullTest = 0.8) : base(seed) { this.ridgedMul = ridgedMul; this.cullTest = cullTest; noisegenA = FractalNoise.FromDefaultOctaves(octaves, 1f / scaleA, persistence, seed + 7312654); noisegenR = FractalNoise.FromDefaultOctaves(octaves, 1f / scaleR, persistence, seed + 5498987); noisegenG = FractalNoise.FromDefaultOctaves(octaves, 1f / scaleG, persistence, seed + 2987992); noisegenB = FractalNoise.FromDefaultOctaves(octaves, 1f / scaleB, persistence, seed + 4987462); mblurInst = AccessTools.CreateInstance(mblurT); }
private static bool Prefix(SkillRecord record) { Type EditorType = AccessTools.TypeByName("CharacterEditor.Editor"); FieldInfo APIField = AccessTools.Field(typeof(PRMod), "API"); object pr = AccessTools.CreateInstance(typeof(PRMod)); // I have absolutely no idea why we have to create an instance here, but // I was unable to figure out static ref access in AccessTools, and this works object API = APIField.GetValue(pr); var p = AccessTools.Field(EditorType, "pawn"); Pawn pawn = p.GetValue(API) as Pawn; record.passion = (Passion)Patch_CharacterEditorBase.IncreasePassion((int)record.passion, pawn, record.def); return(false); }
public static object CreateInstance(this Type type) => AccessTools.CreateInstance(type);
private void LoadContent() { Game1.concessionsSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Concessions"); Game1.birdsSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\birds"); Game1.daybg = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\daybg"); Game1.nightbg = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\nightbg"); Game1.menuTexture = ((ContentManager)Game1.content).Load <Texture2D>("Maps\\MenuTiles"); Game1.uncoloredMenuTexture = ((ContentManager)Game1.content).Load <Texture2D>("Maps\\MenuTilesUncolored"); Game1.lantern = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Lighting\\lantern"); Game1.windowLight = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Lighting\\windowLight"); Game1.sconceLight = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Lighting\\sconceLight"); Game1.cauldronLight = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Lighting\\greenLight"); Game1.indoorWindowLight = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Lighting\\indoorWindowLight"); Game1.shadowTexture = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\shadow"); Game1.mouseCursors = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Cursors"); Game1.mouseCursors2 = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Cursors2"); Game1.giftboxTexture = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\Giftbox"); Game1.controllerMaps = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\ControllerMaps"); Game1.animations = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\animations"); Reflection.GetField <Texture2D>(typeof(Game1), "mobileSpriteSheet", false)?.SetValue(((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\MobileAtlas_manually_made")); Game1.achievements = (Dictionary <int, string>)((ContentManager)Game1.content).Load <Dictionary <int, string> >("Data\\Achievements"); Game1.NPCGiftTastes = (IDictionary <string, string>)((ContentManager)Game1.content).Load <Dictionary <string, string> >("Data\\NPCGiftTastes"); Game1.onScreenMenus.Clear(); Reflection.GetMethod(Game1.game1, "TranslateFields").Invoke(); Game1.dayTimeMoneyBox = new DayTimeMoneyBox(); Reflection.GetField <Game1>(Game1.dayTimeMoneyBox, "game1", false)?.SetValue(Game1.game1); Game1.onScreenMenus.Add((IClickableMenu)Game1.dayTimeMoneyBox); IReflectedField <Toolbar> fieldToolBar = Helper.Reflection.GetField <Toolbar>(typeof(Game1), "toolbar", false); fieldToolBar?.SetValue(new Toolbar()); Type typeVirtualJoypad = AccessTools.TypeByName("StardewValley.Mobile.VirtualJoypad"); if (typeVirtualJoypad != null) { object virtualJoypad = AccessTools.CreateInstance(typeVirtualJoypad); Reflection.GetField <object>(typeof(Game1), "virtualJoypad", false)?.SetValue(virtualJoypad); } if (fieldToolBar != null) { Game1.onScreenMenus.Add(fieldToolBar.GetValue()); } Game1.buffsDisplay = new BuffsDisplay(); Game1.onScreenMenus.Add((IClickableMenu)Game1.buffsDisplay); Game1.dialogueFont = (SpriteFont)((ContentManager)Game1.content).Load <SpriteFont>("Fonts\\SpriteFont1"); Game1.smallFont = (SpriteFont)((ContentManager)Game1.content).Load <SpriteFont>("Fonts\\SmallFont"); Game1.tinyFont = (SpriteFont)((ContentManager)Game1.content).Load <SpriteFont>("Fonts\\tinyFont"); Game1.tinyFontBorder = (SpriteFont)((ContentManager)Game1.content).Load <SpriteFont>("Fonts\\tinyFontBorder"); Game1.objectSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("Maps\\springobjects"); Game1.cropSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\crops"); Game1.emoteSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\emotes"); Game1.debrisSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\debris"); Game1.bigCraftableSpriteSheet = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\Craftables"); Game1.rainTexture = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\rain"); Game1.buffsIcons = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\BuffsIcons"); Game1.objectInformation = (IDictionary <int, string>)((ContentManager)Game1.content).Load <Dictionary <int, string> >("Data\\ObjectInformation"); Game1.clothingInformation = (IDictionary <int, string>)((ContentManager)Game1.content).Load <Dictionary <int, string> >("Data\\ClothingInformation"); Game1.objectContextTags = (IDictionary <string, string>)((ContentManager)Game1.content).Load <Dictionary <string, string> >("Data\\ObjectContextTags"); Game1.bigCraftablesInformation = (IDictionary <int, string>)((ContentManager)Game1.content).Load <Dictionary <int, string> >("Data\\BigCraftablesInformation"); FarmerRenderer.hairStylesTexture = ((ContentManager)Game1.content).Load <Texture2D>("Characters\\Farmer\\hairstyles"); FarmerRenderer.shirtsTexture = ((ContentManager)Game1.content).Load <Texture2D>("Characters\\Farmer\\shirts"); FarmerRenderer.pantsTexture = ((ContentManager)Game1.content).Load <Texture2D>("Characters\\Farmer\\pants"); FarmerRenderer.hatsTexture = ((ContentManager)Game1.content).Load <Texture2D>("Characters\\Farmer\\hats"); FarmerRenderer.accessoriesTexture = ((ContentManager)Game1.content).Load <Texture2D>("Characters\\Farmer\\accessories"); Furniture.furnitureTexture = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\furniture"); SpriteText.spriteTexture = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\font_bold"); SpriteText.coloredTexture = ((ContentManager)Game1.content).Load <Texture2D>("LooseSprites\\font_colored"); Tool.weaponsTexture = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\weapons"); Projectile.projectileSheet = ((ContentManager)Game1.content).Load <Texture2D>("TileSheets\\Projectiles"); }
public static object CreateInstance(this Type type) { return(AccessTools.CreateInstance(type)); }