public override void PreUpdate() { if (DEntrogicDebugClient.Instance.AuthorMode && Main.netMode == NetmodeID.SinglePlayer) { // 这里是buildings文件生成的代码 if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.U) && !Main.oldKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.U)) { if (start == null) { start = MousePos; Main.NewText("Start: " + MousePos + " T " + MousePos.ToTileCoordinates()); } else { Main.NewText("End: " + MousePos + " T " + MousePos.ToTileCoordinates()); Buildings.Export(start.Value, MousePos); start = null; } } if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.B) && !Main.oldKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.B)) { using (FileStream fs = File.OpenRead(Buildings.BuildingSavePath + "1.buildings")) Buildings.Build(fs, MousePos); } } }
public override void HandlePacket(BinaryReader reader, int whoAmI) { EntrogicModMessageType msgType = (EntrogicModMessageType)reader.ReadByte(); switch (msgType) { case EntrogicModMessageType.ReceiveMagicStormRequest: // 由服务器通告全体客户端 { EntrogicWorld.magicStorm = reader.ReadBoolean(); break; } case EntrogicModMessageType.ReceiveMagicStormMPC: // 客户端发出接受请求,服务器发送参数 if (Main.dedServ) // 在服务器下 { ModPacket packet = GetPacket(); packet.Write((byte)EntrogicModMessageType.ReceiveMagicStormMPC); packet.Write(EntrogicWorld.magicStorm); // 发回给发送者 packet.Send(whoAmI, -1); break; } else // 客户端下接收 { EntrogicWorld.magicStorm = reader.ReadBoolean(); if (EntrogicWorld.magicStorm == true /*规范!*/) // 肯定是要开始了才提示啊,不然提示什么东西哦 { Main.NewText("魔力开始涌动...", 150, 150, 250); // 补一个提示 } break; } case EntrogicModMessageType.FindUWTeleporter: { if (Main.dedServ) // 在服务器下 { int i = reader.ReadInt32(); int j = reader.ReadInt32(); int playernum = reader.ReadInt32(); UnderworldPortal.HandleTransportion(i, j, playernum, true); break; } else // 在客户端下,其实就是给玩家回复提示信息 { string warn = reader.ReadString(); Main.NewText(warn); } break; } case EntrogicModMessageType.NPCSpawnOnPlayerAction: { int plr = (int)reader.ReadByte(); int type = (int)reader.ReadInt16(); if (!NPC.AnyNPCs(type)) { NPC.SpawnOnPlayer(plr, type); } break; } case EntrogicModMessageType.NPCSpawn: { if (Main.netMode == NetmodeID.MultiplayerClient) { break; } int plr = (int)reader.ReadByte(); int type = (int)reader.ReadInt16(); bool showSpawnText = reader.ReadBoolean(); float posx = reader.ReadSingle(); float posy = reader.ReadSingle(); Main.PlaySound(SoundID.Roar, Main.player[plr].Center, 0); int npc = NPC.NewNPC((int)posx, (int)posy, type, 1); if (npc == 200) { break; } Main.npc[npc].target = plr; Main.npc[npc].timeLeft *= 20; if (npc < 200) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc); } if (showSpawnText == true) { NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", Main.npc[npc].GetTypeNetName()), new Color(175, 75, 255)); } break; } case EntrogicModMessageType.SyncExplode: { if (Main.netMode == NetmodeID.MultiplayerClient) { Explode(reader.ReadPackedVector2(), reader.ReadPackedVector2(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadBoolean()); } else { MessageHelper.SendExplode(reader.ReadPackedVector2(), reader.ReadPackedVector2(), reader.ReadInt32(), -1, whoAmI, reader.ReadInt32(), reader.ReadInt32(), reader.ReadBoolean()); } break; } case EntrogicModMessageType.SyncCardGamingInfos: { int playernumber = reader.ReadByte(); EntrogicPlayer entrogicPlayer = Main.player[playernumber].GetModPlayer <EntrogicPlayer>(); // 如何传输List?首先传输一个List.Count,然后遍历传输List数值,接收者根据List.Count逐个接收,最后List.Add发给第三方 //entrogicPlayer.IsBookActive = reader.ReadBoolean(); //// Unlike SyncPlayer, here we have to relay/forward these changes to all other connected clients //if (Main.netMode == NetmodeID.Server) //{ // var packet = GetPacket(); // packet.Write((byte)EntrogicModMessageType.SyncBookBubbleInfo); // packet.Write((byte)playernumber); // packet.Write(entrogicPlayer.IsBookActive); // packet.Send(-1, playernumber); //} break; } case EntrogicModMessageType.SyncBookBubbleInfo: { int playernumber = reader.ReadByte(); EntrogicPlayer entrogicPlayer = Main.player[playernumber].GetModPlayer <EntrogicPlayer>(); entrogicPlayer.PageNum = reader.ReadByte(); entrogicPlayer.IsBookActive = reader.ReadBoolean(); // Unlike SyncPlayer, here we have to relay/forward these changes to all other connected clients if (Main.netMode == NetmodeID.Server) { MessageHelper.SendBookInfo(playernumber, entrogicPlayer.PageNum, entrogicPlayer.IsBookActive, -1, playernumber); } break; } case EntrogicModMessageType.SendCompletedCardMerchantMissionRequest: { byte playernumber = reader.ReadByte(); CardMerchantQuest cardMerchantQuest = Main.player[playernumber].GetModPlayer <CardMerchantQuest>(); cardMerchantQuest.Complete = reader.ReadString(); // Unlike SyncPlayer, here we have to relay/forward these changes to all other connected clients if (Main.netMode == NetmodeID.Server) { MessageHelper.SendCardMission(playernumber, cardMerchantQuest.Complete, -1, playernumber); } break; } case EntrogicModMessageType.BuildBuilding: { string name = reader.ReadString(); Vector2 pos = reader.ReadPackedVector2(); bool useAir = reader.ReadBoolean(); Buildings.Build(name, pos, useAir); break; } default: Logger.WarnFormat("Entrogic: Unknown Message type: {0}", msgType); break; } }
public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int MicroBiomesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); if (MicroBiomesIndex != -1) { tasks.Insert(MicroBiomesIndex + 1, new PassLegacy("Generating Card Shrine", delegate(GenerationProgress progress) { progress.Message = Language.GetTextValue("Mods.Entrogic.GenCardShrine"); try { for (int l = 0; l < (int)((double)(MaxTilesX * MaxTilesY) * 0.00003); l++) { Point psw = new Point(WorldGen.genRand.Next(50, MaxTilesX - 50), WorldGen.genRand.Next((int)((float)MaxTilesY * 0.35f), (int)((float)MaxTilesY * 0.85f))); bool goodPlace = true; for (int i = psw.X; i <= psw.X + 5; i++) { int j = psw.Y + 9; if (!Main.tile[i, j].active() || !Main.tileSolid[Main.tile[i, j].type]) { goodPlace = false; break; } } if (goodPlace && WorldGen.InWorld(psw.X, psw.Y) && WorldGen.InWorld(psw.X + 8, psw.Y + 16) && Main.tile[psw.X, psw.Y].active() && Main.tile[psw.X, psw.Y].type == TileID.Stone && Main.tile[psw.X + 5, psw.Y].active() && Main.tile[psw.X + 5, psw.Y].type == TileID.Stone) { Rectangle r = Buildings.Build($"Buildings/CardShrine{WorldGen.genRand.Next(2)}.ebuilding", psw.ToWorldCoordinates()); ModHelper.FindAndReplaceWall(r, (ushort)WallType <黑陨岩墙>()); Chest c = ModHelper.FindAndCreateChest(r, TileType <Tiles.ExplodeGraniteChest>()); int index = 0; c.AddItem(ModHelper.GetRandomCard(Main.LocalPlayer, WorldGen.genRand, CardRareID.GrandUnified, -1, false).type, 1, ref index); Item item = ModHelper.GetRandomCard(Main.LocalPlayer, WorldGen.genRand); c.AddItem(item.type, Math.Max(WorldGen.genRand.Next(item.maxStack) + 1 - 2, 1), ref index); c.AddNormalChestItem(psw.Y, index); } } } catch (Exception e) { throw new Exception("生成世界时发生错误!请将错误发送在QQ群798484146并将 Terraria/ModLoader/Logs/client.txt 发给群主!\n" + e.Message); } })); int maxX = Main.maxTilesX / 2; int maxY = Main.maxTilesY / 2 + 160; tasks.Insert(MicroBiomesIndex + 1, new PassLegacy("Generating Life Liquid", delegate(GenerationProgress progress) { try { progress.Message = Language.GetTextValue("Mods.Entrogic.GenLifeLiquid"); int r = 55; ModWorldHelper.RoundTile(maxX, maxY, r, r, 70, 75, true, TileType <BlackMeteorite>(), 1, 0.2); progress.Set(0.20f); ModWorldHelper.RoundTile(maxX, maxY, r, r, 0, 24.5, true, TileType <BlackMeteorite>()); progress.Set(0.40f); ModWorldHelper.RoundTile(maxX, maxY, r - 7, r - 7, 0, 18, true, 0, 2, 0.5, 1, 140); progress.Set(0.60f); int length = 15; for (int j = maxY - 46; j >= maxY - 80; j--) { for (int i = maxX - WorldGen.genRand.Next(-1, 2) - length; i <= maxX + WorldGen.genRand.Next(-1, 2) + length; i++) { if (Main.tile[i, j].type == TileType <BlackMeteorite>()) { Main.tile[i, j].active(false); } } } progress.Set(0.80f); ModWorldHelper.RoundWall(maxX, maxY, r, r, 0, 25, true, WallType <Walls.黑陨岩墙>(), 0, 1); progress.Set(1.00f); progress.Message = Language.GetTextValue("Mods.Entrogic.SmoothLifeLiquid"); ModWorldHelper.SmoothTile(maxX - 80, maxY - 80, maxX + 80, maxY + 80, progress, true); } catch (Exception e) { throw new Exception("生成世界时发生错误!请将错误发送在QQ群798484146并将 Terraria/ModLoader/Logs/client.txt 发给群主!\n" + e.Message); } })); } }
public override void Load() { PassHotkey = RegisterHotKey("过牌快捷键", "E"); WashHotkey = RegisterHotKey("洗牌快捷键", "Q"); HookCursorHotKey = RegisterHotKey("设置钩爪指针快捷键", "C"); On.Terraria.Player.QuickGrapple += Player_QuickGrapple; On.Terraria.Player.ItemCheck += UnderworldTransportCheck; On.Terraria.Main.DrawInterface_40_InteractItemIcon += CustomHandIcon; //On.Terraria.Main.DrawTiles += Main_DrawTiles; foolTexts = Main.rand.Next(3); Unloading = false; IsCalamityLoaded = ModLoader.GetMod("CalamityMod") != null; Mod yabhb = ModLoader.GetMod("FKBossHealthBar"); if (yabhb != null) { #region Wlta yabhb yabhb.Call("RegisterCustomHealthBar", ModContent.NPCType <Embryo>(), null, //ForceSmall null, //displayName GetTexture("UI/yabhb/瓦卢提奥血条Fill"), //fillTexture GetTexture("UI/yabhb/瓦卢提奥血条头"), GetTexture("UI/yabhb/瓦卢提奥血条条"), GetTexture("UI/yabhb/瓦卢提奥血条尾"), null, //midBarOffsetX 0, //midBarOffsetY null, //fillDecoOffsetX 32, //bossHeadCentreOffsetX 30, //bossHeadCentreOffsetY null, //fillTextureSM null, //leftBarSM null, //midBarSM null, //rightBarSM null, //fillDecoOffsetXSM null, //bossHeadCentreOffsetXSM null, //bossHeadCentreOffsetYSM true); //LoopMidBar yabhb.Call("RegisterCustomHealthBar", ModContent.NPCType <Volutio>(), null, //ForceSmall null, //displayName GetTexture("UI/yabhb/瓦卢提奥血条Fill"), //fillTexture GetTexture("UI/yabhb/瓦卢提奥血条头"), GetTexture("UI/yabhb/瓦卢提奥血条条"), GetTexture("UI/yabhb/瓦卢提奥血条尾"), null, //midBarOffsetX 0, //midBarOffsetY null, //fillDecoOffsetX 32, //bossHeadCentreOffsetX 32, //bossHeadCentreOffsetY null, //fillTextureSM null, //leftBarSM null, //midBarSM null, //rightBarSM null, //fillDecoOffsetXSM null, //bossHeadCentreOffsetXSM null, //bossHeadCentreOffsetYSM true); //LoopMidBar #endregion } MimicryCustomCurrencyId = CustomCurrencyManager.RegisterCurrency(new EntrogicMimicryCurrency(ModContent.ItemType <拟态魔能>(), 999L)); if (!Main.dedServ) { ResourceLoader.LoadAllTextures(); ResourceLoader.LoadAllCardMissions(); AddEquipTexture(new PollutionElementalMask1(), null, EquipType.Head, "PollutionElementalMask1", "Entrogic/Items/PollutElement/PollutionElementalMask1_Head"); AddEquipTexture(new PollutionElementalMask2(), null, EquipType.Head, "PollutionElementalMask2", "Entrogic/Items/PollutElement/PollutionElementalMask2_Head"); AddEquipTexture(new PollutionElementalMask3(), null, EquipType.Head, "PollutionElementalMask3", "Entrogic/Items/PollutElement/PollutionElementalMask3_Head"); AddEquipTexture(new PollutionElementalMask4(), null, EquipType.Head, "PollutionElementalMask4", "Entrogic/Items/PollutElement/PollutionElementalMask4_Head"); AddEquipTexture(new PolluWings1(), null, EquipType.Wings, "PolluWings1", "Entrogic/Items/PollutElement/PolluWings1_Wings"); AddEquipTexture(new PolluWings2(), null, EquipType.Wings, "PolluWings2", "Entrogic/Items/PollutElement/PolluWings2_Wings"); AddEquipTexture(new PolluWings3(), null, EquipType.Wings, "PolluWings3", "Entrogic/Items/PollutElement/PolluWings3_Wings"); AddEquipTexture(new PolluWings4(), null, EquipType.Wings, "PolluWings4", "Entrogic/Items/PollutElement/PolluWings4_Wings"); AddEquipTexture(new PolluWings5(), null, EquipType.Wings, "PolluWings5", "Entrogic/Items/PollutElement/PolluWings5_Wings"); AddEquipTexture(new PolluWings6(), null, EquipType.Wings, "PolluWings6", "Entrogic/Items/PollutElement/PolluWings6_Wings"); AddEquipTexture(new PolluWings7(), null, EquipType.Wings, "PolluWings7", "Entrogic/Items/PollutElement/PolluWings7_Wings"); AddEquipTexture(new PolluWings8(), null, EquipType.Wings, "PolluWings8", "Entrogic/Items/PollutElement/PolluWings8_Wings"); ResourceLoader.LoadAllShaders(); BookUI = new BookUI(); BookUI.Activate(); BookUIE = new UserInterface(); BookUIE.SetState(BookUI); //BookPageUI = new BookPageUI(); //BookPageUI.Activate(); //BookPageUIE = new UserInterface(); //BookPageUIE.SetState(BookPageUI); CardUI = new CardUI(); CardUI.Activate(); CardUIE = new UserInterface(); CardUIE.SetState(CardUI); CardInventoryUI = new CardInventoryUI(); CardInventoryUI.Activate(); CardInventoryUIE = new UserInterface(); CardInventoryUIE.SetState(CardInventoryUI); CardGameUI = new CardGameUI(); CardGameUI.Activate(); CardGameUIE = new UserInterface(); CardGameUIE.SetState(CardGameUI); /*SinsBar.visible = true; * Sinsbar = new SinsBar(); * Sinsbar.Activate(); * SinsBarInterface = new UserInterface(); * SinsBarInterface.SetState(Sinsbar);*/ } Buildings.Cache("Buildings/CardShrine0.ebuilding", "Buildings/CardShrine1.ebuilding", "Buildings/UnderworldPortal.ebuilding"); new PiggyBankAmmo(); new ModHandler(); #region Armor Translates Translation.RegisterTranslation("mspeed", GameCulture.Chinese, "移动速度", " movement speed"); Translation.RegisterTranslation("and", GameCulture.Chinese, "与", " and"); Translation.RegisterTranslation("csc", GameCulture.Chinese, "暴击率", " critical strike chance"); Translation.RegisterTranslation("knockback", GameCulture.Chinese, "击退", " knockback"); Translation.RegisterTranslation("damage", GameCulture.Chinese, "伤害", " damage"); Translation.RegisterTranslation("cntca", GameCulture.Chinese, "的几率不消耗弹药", " chance not to consume ammo"); Translation.RegisterTranslation("immb", GameCulture.Chinese, "最大魔力值增加", "Increases maximum mana by "); Translation.RegisterTranslation("rmub", GameCulture.Chinese, "魔力消耗减少", "Reduces mana usage by "); #endregion #region Boss Checklist Translates ModTranslation bctext = CreateTranslation("BossSpawnInfo.GelSymb"); bctext.AddTranslation(GameCulture.Chinese, "在地下原汤湖使用 [i:" + ModContent.ItemType <GelCultureFlask>() + "] 召唤一只史莱姆, 并将其掷于地下原汤湖中召唤"); bctext.SetDefault("Use [i:" + ModContent.ItemType <GelCultureFlask>() + "] in the underground pool to summon a slime, and thorw it into the pool to summon."); AddTranslation(bctext); bctext = CreateTranslation("BossSpawnInfo.Athanasy"); bctext.AddTranslation(GameCulture.Chinese, "使用 [i:" + ModContent.ItemType <TitansOrder>() + "] 召唤(由地牢怪物掉落或在上锁的金箱中找到)"); bctext.SetDefault("Use [i:" + ModContent.ItemType <TitansOrder>() + "] to spawn, you can find it from locked chests or drop from dungeon monsters"); AddTranslation(bctext); bctext = CreateTranslation("BossSpawnInfo.PollutionElement"); bctext.AddTranslation(GameCulture.Chinese, "在海边使用 [i:" + ModContent.ItemType <ContaminatedLiquor>() + "] 召唤"); bctext.SetDefault("Use [i:" + ModContent.ItemType <ContaminatedLiquor>() + "] in ocean to spawn"); AddTranslation(bctext); #endregion #region Another Translates ModTranslation transform = CreateTranslation("RightClickToTransform"); transform.AddTranslation(GameCulture.Chinese, "右键点击物品以切换状态"); transform.SetDefault("Right click to switch status"); AddTranslation(transform); ModTranslation modTranslation = CreateTranslation("ArcaneDamage"); modTranslation.AddTranslation(GameCulture.Chinese, "奥术"); modTranslation.SetDefault("arcane "); AddTranslation(modTranslation); modTranslation = CreateTranslation("Pollution_SkyDarkened"); modTranslation.AddTranslation(GameCulture.Chinese, "天空变得更加黑暗"); modTranslation.SetDefault("The sky is becomes darkened"); AddTranslation(modTranslation); modTranslation = CreateTranslation("Pollution_Pollutional"); modTranslation.AddTranslation(GameCulture.Chinese, "污染生物正在聚集..."); modTranslation.SetDefault("Pollutional creatures are gathering..."); AddTranslation(modTranslation); modTranslation = CreateTranslation("Pollution_Summon"); modTranslation.AddTranslation(GameCulture.Chinese, "永远不要尝试去挑战自然..."); modTranslation.SetDefault("Never try to challenge the nature..."); AddTranslation(modTranslation); modTranslation = CreateTranslation("Pollution_Summon2"); modTranslation.AddTranslation(GameCulture.Chinese, "呵..."); modTranslation.SetDefault("Heh..."); AddTranslation(modTranslation); ModTranslation text = CreateTranslation("NPCTalk"); text.SetDefault("<{0}> {1}"); AddTranslation(text); text = CreateTranslation("Common.RandomCardImage"); text.SetDefault($"[i:{ModContent.ItemType<RandomCard>()}] [c/ffeb6e:卡牌系统自定义项]"); AddTranslation(text); ModTranslation modGen = CreateTranslation("GenLifeLiquid"); modGen.AddTranslation(GameCulture.Chinese, "正在生成生命湖"); modGen.SetDefault("Life."); AddTranslation(modGen); modGen = CreateTranslation("SmoothLifeLiquid"); modGen.AddTranslation(GameCulture.Chinese, "正在平整生命湖"); modGen.SetDefault("Life."); AddTranslation(modGen); modGen = CreateTranslation("GenCardShrine"); modGen.AddTranslation(GameCulture.Chinese, "正在生成卡牌神龛"); modGen.SetDefault("Card."); AddTranslation(modGen); #endregion }