//////////////// public override void ModifyTooltips(List <TooltipLine> tooltips) { var topTip = new TooltipLine(this.mod, "intrinsics", "This contract imparts intrinsics from the following items:"); tooltips.Add(topTip); int i = 0; foreach (string itemUid in this.IntrinsicItemUids) { int itemId = ItemID.TypeFromUniqueKey(itemUid); if (itemId == 0) { continue; } var item = new Item(); item.SetDefaults(itemId, true); var tip = new TooltipLine(this.mod, "intrinsic_" + i, " " + item.HoverName); Color tryColor; if (ItemRarityAttributeHelpers.RarityColor.TryGetValue(item.rare, out tryColor)) { tip.overrideColor = tryColor; } tooltips.Add(tip); i++; } }
//////////////// public override void Action(CommandCaller caller, string input, string[] args) { var mymod = (IntrinsicsMod)this.mod; if (!mymod.Config.DebugModeCheat) { caller.Reply("Cheat mode not active. See configs.", Color.Red); return; } if (Main.netMode == 1) { LogHelpers.Warn("Not supposed to run on client."); return; } if (Main.netMode == 2 && caller.CommandType != CommandType.Console) { bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player); if (!hasPriv) { caller.Reply("Access denied.", Color.Red); return; } } if (args.Length < 1) { caller.Reply("Insufficient arguments.", Color.Red); return; } string itemName = string.Join(" ", args); int itemId; if (!ItemAttributeHelpers.DisplayNamesToIds.ContainsKey(itemName)) { itemId = ItemID.TypeFromUniqueKey(itemName); if (itemId == 0) { caller.Reply("Invalid item name: " + itemName, Color.Red); return; } } else { itemId = ItemAttributeHelpers.DisplayNamesToIds[itemName]; } var myplayer = TmlHelpers.SafelyGetModPlayer <IntrinsicsPlayer>(Main.LocalPlayer); myplayer.RemoveIntrinsic(ItemID.GetUniqueKey(itemId)); //TODO GetProperUniqueId caller.Reply("Intrinsic removed.", Color.Lime); }
///// public void SyncIntrinsicItemsToMe(IEnumerable <string> itemUids, IDictionary <int, bool> itemStates) { this.IntrinsicItemUids = new HashSet <string>(itemUids); foreach (string itemUid in itemUids) { int itemType = ItemID.TypeFromUniqueKey(itemUid); bool itemState; itemStates.TryGetValue(itemType, out itemState); var item = new Item(); item.SetDefaults(itemType); this.LoadIntrinsicItemInternal(item, itemState); } }
public override TagCompound Save() { int count = this.IntrinsicItemUids.Count; var tag = new TagCompound { { "item_count", count } }; int i = 0; foreach (string itemUid in this.IntrinsicItemUids) { tag["item_" + i] = itemUid; tag["item_" + i + "_on"] = this.IntrinsicToggle[ItemID.TypeFromUniqueKey(itemUid)]; i++; } return(tag); }
public void Load(TagCompound tag) { type = (Type)tag.Get <int>("Type"); uniqueKey = tag.GetString("UniqueKey"); switch (type) { case Type.Item: id = ItemID.TypeFromUniqueKey(uniqueKey); break; case Type.NPC: id = NPCID.TypeFromUniqueKey(uniqueKey); break; case Type.Projectile: id = ProjectileID.TypeFromUniqueKey(uniqueKey); break; } animation = new DrawAnimationVertical(tag.Get <int>("TicksPerFrame"), tag.Get <int>("FrameCount")); }
public void RemoveIntrinsic(string itemUid) { this.IntrinsicItemUids.Remove(itemUid); int itemId = ItemID.TypeFromUniqueKey(itemUid); if (itemId != 0) { if (this.IntrinsicBuffItem.ContainsKey(itemId)) { this.IntrinsicBuffItem.Remove(itemId); } if (this.IntrinsicArmItem.ContainsKey(itemId)) { this.IntrinsicArmItem.Remove(itemId); } if (this.IntrinsicAccItem.ContainsKey(itemId)) { this.IntrinsicAccItem.Remove(itemId); } } }
//////////////////// public void ApplyIntrinsic(string itemUid, bool isEnabled) { this.IntrinsicItemUids.Add(itemUid); int itemId = ItemID.TypeFromUniqueKey(itemUid); if (itemId != 0) { Item item = this.LoadIntrinsicItem(itemId); Color rareColor; if (ItemRarityAttributeHelpers.RarityColor.TryGetValue(item.rare, out rareColor)) { string colorHex = rareColor.Hex3(); Main.NewText("The deal is made. Imparting [c/" + colorHex + ":" + item.HoverName + "]..."); } else { Main.NewText("The deal is made. Imparting " + item.HoverName + "..."); } } this.IntrinsicToggle[itemId] = isEnabled; if (Main.netMode == 1) { if (this.player.whoAmI == Main.myPlayer) { IntrinsicsSyncProtocol.SyncFromMe(); } else { IntrinsicsSyncProtocol.SyncFromOther(this.player.whoAmI); } } }
//////////////// public override void Action(CommandCaller caller, string input, string[] args) { var mymod = (IntrinsicsMod)this.mod; if (!mymod.Config.DebugModeCheat) { caller.Reply("Cheat mode not active. See configs.", Color.Red); return; } if (Main.netMode == 1) { LogHelpers.Warn("Not supposed to run on client."); return; } if (Main.netMode == 2 && caller.CommandType != CommandType.Console) { bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player); if (!hasPriv) { caller.Reply("Access denied.", Color.Red); return; } } if (args.Length < 1) { caller.Reply("Insufficient arguments.", Color.Red); return; } if (args[0].Length == 0 || args[0][0] != '\"') { caller.Reply("Invalid first item name: " + args[0], Color.Red); return; } IList <Item> items = new List <Item>(); int argNextIdx = 0; string itemKey; while (CommandsHelpers.GetQuotedStringFromArgsAt(args, argNextIdx, out argNextIdx, out itemKey)) { int itemId; if (!ItemAttributeHelpers.DisplayNamesToIds.ContainsKey(itemKey)) { itemId = ItemID.TypeFromUniqueKey(itemKey); if (itemId == 0) { caller.Reply("Invalid item name: " + itemKey, Color.Red); return; } } else { itemId = ItemAttributeHelpers.DisplayNamesToIds[itemKey]; } var item = new Item(); item.SetDefaults(itemId); items.Add(item); } IEnumerable <string> itemNames = items.Select(i => ItemID.GetUniqueKey(i.type)); //TODO GetProperUniqueId if (ImpartmentContractItem.Create(Main.LocalPlayer, Main.LocalPlayer.Center, new HashSet <string>(itemNames)) != -1) { caller.Reply("Created Impartment Contract.", Color.Lime); } else { caller.Reply("Could not create Impartment Contract.", Color.Red); } }