// Instruction ************************************************************** /// <summary>Creates a shallow copy of an Instruction</summary> /// <param name="instr">The instruction to be cloned</param> /// <returns>Returns the new Instruction if ILManager.GenInstruction was successful, otherwise null</returns> public static Instruction Clone(this Instruction instr) { if (instr == null) { throw new ArgumentNullException(nameof(instr)); } return(ILManager.GenInstruction(instr.OpCode, instr.Operand)); }
void Start() { textMesh = GetComponent <TextMesh>(); if (ILManager.IsRtl) { ILManager.SetText3D(textMesh, textMesh.text); } }
void Start() { uiText = GetComponent <Text>(); if (ILManager.IsRtl) { ILManager.SetTextUI(uiText, uiText.text); } }
public override void Load() { CalamityVersionException.ThrowErrorOnIncorrectVersion(ModLoader.GetMod("CalamityMod"), ExpectedCalamityVersion); ILManager.Load(); SummonRotationAdjustmentsGlobalProj.Initialize(); AbyssalMinesExplosionGlobalProj.Initialize(); ArmorSetDatabase.Initialize(); TooltipModificationsItem.Initialize(); }
private void MakeItemAvailable() { if (instructionEditor.DragItem == null) { InstructionInfo nII = new InstructionInfo(); nII.OldInstructionNum = -1; nII.NewInstructionNum = -1; nII.NewInstruction = ILManager.GenInstruction(OpCodes.Nop, null); instructionEditor.DragItem = nII; } }
IEnumerator HotfixStart() { ILManager iL = this.gameObject.AddComponent <ILManager>(); iL.Init(); yield return(StartCoroutine(iL.GetServerDllVersion())); iL.CheckIsUpdate(); yield return(StartCoroutine(iL.DownloadTasks())); yield return(StartCoroutine(iL.LoadHotfixDll())); }
public override void Unload() { // Unload any data that goes unhandled by tML or contains static data. AssetManager.Unload(); ChangelogData.Unload(); ILManager.Unload(); SaveDataManager.Unload(); LocalizationInitializer.Unload(); ModLogger = null; Instance = null; }
public override void Load() { Instance = this; ModLogger = Instance.Logger; // Initialize all the things! AssetManager.Load(); LocalizationInitializer.Initialize(); ILManager.Load(); SaveDataManager.Load(); SaveDataManager.Save(); ChangelogData.PopulateChangelogList(this); }
private void ChangeListener() { // remove old listener and create a new one when were done manipulating the text // otherwise we will get stackOverflow (recursive change) inputField.onValueChanged.RemoveAllListeners(); bool didSet = ILManager.SetInputText(inputField, lastInput); Listen(inputField); //if the manager didnt manipulate the text, we dont want to save the last text if (didSet) { lastInput = inputField.text; } }
/// <summary>Loads the patch data from an XmlNode</summary> /// <param name="input">The XmlNode containing the Instruction nodes</param> /// <returns>Returns true if it succeeded, false otherwise</returns> public override bool Load(XmlNode input) { NameCompressor nc = NameCompressor.Instance; Validator val = new Validator(() => PatchStatus = PatchStatus.Broken); if (!val.ValidateTrue(input.ChildNodes.Count > 0, $"Node {input.Name} has no Childnodes")) { return(val.Ok); } XmlNode PatchList = input.GetChildNode(SST.PatchList, 0); if (!val.ValidateSet(PatchList, "No PatchList Child found")) { return(val.Ok); } string metpathunres = PatchList.GetAttribute(SST.MethodPath); if (!val.ValidateStringSet(metpathunres, "MethodPath Attribute not found or empty")) { return(val.Ok); } methodDefinition = DataStruct.ReferenceTable.Resolve(metpathunres.ToBaseInt()) as MethodDefinition; if (!val.ValidateSet(methodDefinition, $"MethodID \"{metpathunres}\" couldn't be resolved")) { return(val.Ok); } // TODO: move methodDef related checks to Execute OriginalInstructionCount = int.Parse(PatchList.GetAttribute(SST.InstructionCount)); // if new method body has changed -> patching the new assembly will not work if (!val.ValidateTrue(methodDefinition.Body.Instructions.Count == OriginalInstructionCount, $"The PatchAction \" { Name }\" cannot be applied to a changend method")) { return(val.Ok); } // TODO: init with given params, instead of static AnyArray <InstructionInfo> iibuffer = new AnyArray <InstructionInfo>(OriginalInstructionCount); bool checkopcdes = true; bool resolveparams = false; // resolves types/methods/... bool checkprimitives = true; // checks if primitive types are identical var xmlInstructionLoader = new XMLInstruction <InstructionInfo>( DataStruct.ReferenceTable, methodDefinition); #region Load all InstructionInfo foreach (XmlNode xelem in PatchList.ChildNodes) { if (!val.ValidateTrue(xelem.Name == nc[SST.Instruction], $"PatchList elemtent \"{xelem.Name}\" is not recognized")) { continue; } InstructionInfo nII = new InstructionInfo(); XmlAttribute xdelatt = xelem.Attributes[nc[SST.Delete]]; OpCode opcode = ILManager.OpCodeLookup[xelem.GetAttribute(SST.OpCode)]; if (xdelatt != null) // Old_Instruction { nII.Delete = xdelatt.Value == nc[SST.True]; //Load old Instruction into InstructionInfo nII.OldInstructionNum = int.Parse(xelem.GetAttribute(SST.InstructionNum)); if (nII.OldInstructionNum < OriginalInstructionCount) { nII.OldInstruction = methodDefinition.Body.Instructions[nII.OldInstructionNum]; val.ValidateTrue(checkopcdes && opcode == nII.OldInstruction.OpCode, () => { nII.OpCodeMismatch = true; return($"Opcode of Instruction {nII.OldInstructionNum} has changed"); }); // TODO: set mismatch | from-to log } else { continue; } if (checkprimitives) { if (opcode.OperandType == nII.OldInstruction.OpCode.OperandType) { string oldPrimOperand; if (nII.OldInstruction.Operand == null) { nII.PrimitiveMismatch = xelem.GetAttribute(SST.PrimitiveValue, out oldPrimOperand); } else { nII.PrimitiveMismatch = xelem.GetAttribute(SST.PrimitiveValue) != nII.OldInstruction.Operand.ToString(); } } else { nII.PrimitiveMismatch = true; } } if (resolveparams) { Log.Write(Log.Level.Info, "Resolve not implemented yet."); //TODO: PatchStatus = PatchStatus.Broken; of not found ref implement, when DeepTypeCompare works } if (xelem.ChildNodes.Count == 1) // check if patchnode exists { XmlNode xpatchelem = xelem.ChildNodes[0]; string instnum = xpatchelem.GetAttribute(SST.InstructionNum); if (string.IsNullOrEmpty(instnum)) // check InstructionNum Patch { nII.NewInstructionNum = nII.OldInstructionNum; } else { nII.NewInstructionNum = int.Parse(instnum); } OpCode patchopc; string patchopcode = xpatchelem.GetAttribute(SST.OpCode); if (string.IsNullOrEmpty(patchopcode)) // check Opcode patch { patchopc = opcode; } else { patchopc = ILManager.OpCodeLookup[patchopcode]; } nII.NewInstruction = xmlInstructionLoader.Node2Instruction(xpatchelem, patchopc, nII.NewInstructionNum); if (nII.NewInstruction == null) { nII.NewInstruction = ILManager.GenInstruction(patchopc, nII.OldInstruction.Operand); } } else // no patchnode -> clone old one { nII.NewInstructionNum = nII.OldInstructionNum; nII.NewInstruction = nII.OldInstruction.Clone(); } } else // New_Instruction { nII.OldInstructionNum = -1; nII.NewInstructionNum = int.Parse(xelem.GetAttribute(SST.InstructionNum)); nII.NewInstruction = xmlInstructionLoader.Node2Instruction(xelem, opcode, nII.NewInstructionNum); val.ValidateSet(nII.NewInstruction, () => { nII.NewInstruction = Instruction.Create(OpCodes.Nop); nII.NewInstruction.OpCode = opcode; nII.NewInstruction.Operand = "!!!!! Dummy !!!!!"; return($"Expected Operand for '{opcode.Name}', but no matching Attribute was found in {xelem.InnerXml}"); }); } iibuffer[nII.NewInstructionNum] = nII; } #endregion instructPatchList = new List <InstructionInfo>(iibuffer.ToArray()); // Check for not loaded Instructions if (!val.ValidateTrue(instructPatchList.All(x => x != null), () => "PatchList has holes: " + string.Join(", ", instructPatchList.Select((b, i) => b == null ? i : -1).Where(i => i != -1).ToArray()))) { return(false); } #region Set all jump operands from PostInitData foreach (PostInitData pid in xmlInstructionLoader.GetPostInitalisationList()) { if (pid.isArray) { bool success = true; instructPatchList[pid.InstructionNum].NewInstruction.Operand = Array.ConvertAll(pid.targetArray, a => { InstructionInfo pidinstr = instructPatchList.FirstOrDefault(x => x.NewInstructionNum == a); if (!val.ValidateSet(pidinstr, () => { success = false; return($"PID_At: {a}"); })) { return(null); } else { return(pidinstr.NewInstruction); } }); if (!val.ValidateTrue(success, $"PostInitData failed: {pid}")) { continue; } } else { InstructionInfo pidinstr = instructPatchList.First(x => x.NewInstructionNum == pid.targetNum); if (!val.ValidateSet(pidinstr, $"PostInitData failed: {pid}")) { continue; } instructPatchList[pid.InstructionNum].NewInstruction.Operand = pidinstr.NewInstruction; } } #endregion if (PatchStatus == PatchStatus.Unset) { PatchStatus = PatchStatus.WoringPerfectly; } return(val.Ok); }
public override void Unload() { ILManager.Unload(); RecipeManager.Unload(); }
public override void Load() { ILManager.Load(); RecipeManager.Load(); }
public override void Unload() { ILManager.Unload(); CataclysmConfig.Instance = null; Instance = null; }