public override void Load() { Instance = this; parts = new Dictionary <string, PartType>(); effects = new Dictionary <string, EffectType>(); modPartRecipes = new List <object[]>(); modToolRecipes = new List <object[]>(); doneCrossModContent = false; herosMod = ModLoader.GetMod("HEROsMod"); cheatSheet = ModLoader.GetMod("CheatSheet"); if (!Main.dedServ) { DismantleUserInterface = new UserInterface(); CheatDismantleUserInterface = new UserInterface(); } GHelper.AddPart(PartData.UnknownPart); GHelper.AddPart(PartData.CopperPickaxeHead); }
public override object Call(params object[] args) { try { string message = args[0] as string; if (message == "CheckEffect") //Returns -1 if effect isn't present or item used isn't a ConstructTool. Returns level of effect of effect is present. { if ((args[1] as Item).modItem is ConstructTool cTool) { if (cTool.effects.ContainsKey(args[2] as string)) { return(cTool.effects[args[2] as string]); } else { return(-1); } } else { return(-1); } } else if (message == "GetItemType") //Returns itemType if item passed in is a ConstructTool. Returns an error otherwise. { if ((args[1] as Item).netID == 0) { return("GetItemType called too early!"); } else if ((args[1] as Item).modItem is ConstructTool cTool) { return(cTool.itemType); } else { return("GetItemType called on an item that is not a ConstructTool!"); } } if (doneCrossModContent) //Done so the following Calls can't be done after mod load. like mid-game. { throw new Exception($"Call Error: TerrariaConstruct expects the message you sent, \"{message}\", before AddRecipes(). A good place to put this Call() is in PostSetupContent()."); } if (message == "AddPart") //Adds a new PartType to parts. { string materialName = args[2] as string; string type = args[5] as string; GHelper.AddPart(args[1] as string, materialName, Convert.ToSingle(args[3]), Convert.ToSingle(args[4]), args[5] as string, args[6] as string, type, Convert.ToSingle(args[7]), Convert.ToInt32(args[8]), args[9] as Dictionary <string, int>); Logger.Info($"Call Info: Part {materialName} {type} added"); return($"Part {materialName} {type} added"); } else if (message == "AddPartRecipe") //Adds the ags to modPartRecipes to add later in AddRecipes. { modPartRecipes.Add(args); return("Part Recipe added to list"); } else if (message == "AddToolRecipe") //Adds the args to modToolRecipes to add later in AddRecipes. { modToolRecipes.Add(args); return("Tool Recipe added to list"); } else if (message == "AddEffect") //Adds a new EffectType to effects. { string name = args[2] as string; GHelper.AddEffect(args[1] as string, name, Convert.ToInt32(args[3]), Convert.ToBoolean(args[4]), args[5] as string); Logger.Info($"Call Info: Effects {name} added"); return($"Effects {name} added"); } else //You dun f****d up. { Logger.Error("Call Error: Unknown Message: " + message); return("Call Error: Unknown Message: " + message); } } catch (Exception e) { Logger.Error("Call Error: " + e.StackTrace + e.Message); return("Failure, see logs"); } }