예제 #1
0
파일: NpcHooks.cs 프로젝트: pfchrono/Toaria
 public static bool OnStrikeNpc(NPC npc, ref int damage, ref float knockback, ref int hitdirection, ref bool crit, ref bool noEffect, ref double retdamage)
 {
     if (NpcHooks.StrikeNpc == null)
     {
         return false;
     }
     NpcStrikeEventArgs npcStrikeEventArgs = new NpcStrikeEventArgs
     {
         Npc = npc,
         Damage = damage,
         KnockBack = knockback,
         HitDirection = hitdirection,
         Critical = crit,
         NoEffect = noEffect,
         ReturnDamage = retdamage
     };
     NpcHooks.StrikeNpc(npcStrikeEventArgs);
     crit = npcStrikeEventArgs.Critical;
     damage = npcStrikeEventArgs.Damage;
     knockback = npcStrikeEventArgs.KnockBack;
     hitdirection = npcStrikeEventArgs.HitDirection;
     noEffect = npcStrikeEventArgs.NoEffect;
     retdamage = npcStrikeEventArgs.ReturnDamage;
     return npcStrikeEventArgs.Handled;
 }
예제 #2
0
파일: NpcHooks.cs 프로젝트: pfchrono/Toaria
 public static void OnSetDefaultsString(ref string npcname, NPC npc)
 {
     if (NpcHooks.SetDefaultsString == null)
     {
         return;
     }
     SetDefaultsEventArgs<NPC, string> setDefaultsEventArgs = new SetDefaultsEventArgs<NPC, string>
     {
         Object = npc,
         Info = npcname
     };
     NpcHooks.SetDefaultsString(setDefaultsEventArgs);
     npcname = setDefaultsEventArgs.Info;
 }
예제 #3
0
파일: NpcHooks.cs 프로젝트: pfchrono/Toaria
 public static void OnSetDefaultsInt(ref int npctype, NPC npc)
 {
     if (NpcHooks.SetDefaultsInt == null)
     {
         return;
     }
     SetDefaultsEventArgs<NPC, int> setDefaultsEventArgs = new SetDefaultsEventArgs<NPC, int>
     {
         Object = npc,
         Info = npctype
     };
     NpcHooks.SetDefaultsInt(setDefaultsEventArgs);
     npctype = setDefaultsEventArgs.Info;
 }
예제 #4
0
파일: Main.cs 프로젝트: pfchrono/Toaria
 public void DedServ()
 {
     Type t = Type.GetType("Mono.Runtime");
     Main.runningMono = (t != null);
     GameHooks.OnInitialize(true);
     Main.rand = new Random();
     Console.Title = "Toaria (Terraria Version " + Main.versionNumber2 + ")";
     Main.dedServ = true;
     Main.showSplash = false;
     this.Initialize();
     for (int i = 0; i < 147; i++)
     {
         NPC nPC = new NPC();
         nPC.SetDefaults(i, -1f);
         Main.npcName[i] = nPC.name;
     }
     while (Main.worldPathName == null || Main.worldPathName == "")
     {
         Main.LoadWorlds();
         bool flag = true;
         while (flag)
         {
             Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber2 + ")");
             Console.WriteLine("");
             for (int j = 0; j < Main.numLoadWorlds; j++)
             {
                 Console.WriteLine(string.Concat(new object[]
                 {
                     j + 1,
                     '\t',
                     '\t',
                     Main.loadWorld[j]
                 }));
             }
             Console.WriteLine(string.Concat(new object[]
             {
                 "n",
                 '\t',
                 '\t',
                 "New World"
             }));
             Console.WriteLine("d <number>" + '\t' + "Delete World");
             Console.WriteLine("");
             Console.Write("Choose World: ");
             string text2 = Console.ReadLine();
             try
             {
                 Console.Clear();
             }
             catch
             {
             }
             if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
             {
                 try
                 {
                     int num = Convert.ToInt32(text2.Substring(2)) - 1;
                     if (num < Main.numLoadWorlds)
                     {
                         Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber2 + ")");
                         Console.WriteLine("");
                         Console.WriteLine("Really delete " + Main.loadWorld[num] + "?");
                         Console.Write("(y/n): ");
                         string text3 = Console.ReadLine();
                         if (text3.ToLower() == "y")
                         {
                             Main.EraseWorld(num);
                         }
                     }
                 }
                 catch
                 {
                 }
                 try
                 {
                     Console.Clear();
                     continue;
                 }
                 catch
                 {
                     continue;
                 }
             }
             if (text2 == "n" || text2 == "N")
             {
                 bool flag2 = true;
                 while (flag2)
                 {
                     Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber2 + ")");
                     Console.WriteLine("");
                     Console.WriteLine("1" + '\t' + "Small");
                     Console.WriteLine("2" + '\t' + "Medium");
                     Console.WriteLine("3" + '\t' + "Large");
                     Console.WriteLine("");
                     Console.Write("Choose size: ");
                     string value = Console.ReadLine();
                     try
                     {
                         int num2 = Convert.ToInt32(value);
                         if (num2 == 1)
                         {
                             Main.maxTilesX = 4200;
                             Main.maxTilesY = 1200;
                             flag2 = false;
                         }
                         else
                         {
                             if (num2 == 2)
                             {
                                 Main.maxTilesX = 6300;
                                 Main.maxTilesY = 1800;
                                 flag2 = false;
                             }
                             else
                             {
                                 if (num2 == 3)
                                 {
                                     Main.maxTilesX = 8400;
                                     Main.maxTilesY = 2400;
                                     flag2 = false;
                                 }
                             }
                         }
                     }
                     catch
                     {
                     }
                     try
                     {
                         Console.Clear();
                     }
                     catch
                     {
                     }
                 }
                 flag2 = true;
                 while (flag2)
                 {
                     Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber2 + ")");
                     Console.WriteLine("");
                     Console.Write("Enter world name: ");
                     Main.newWorldName = Console.ReadLine();
                     if (Main.newWorldName != "" && Main.newWorldName != " " && Main.newWorldName != null)
                     {
                         flag2 = false;
                     }
                     try
                     {
                         Console.Clear();
                     }
                     catch
                     {
                     }
                 }
                 Main.worldName = Main.newWorldName;
                 Main.worldPathName = Main.nextLoadWorld();
                 Main.menuMode = 10;
                 WorldGen.CreateNewWorld();
                 flag2 = false;
                 while (Main.menuMode == 10)
                 {
                     if (Main.oldStatusText != Main.statusText)
                     {
                         Main.oldStatusText = Main.statusText;
                         Console.WriteLine(Main.statusText);
                     }
                 }
                 try
                 {
                     Console.Clear();
                     continue;
                 }
                 catch
                 {
                     continue;
                 }
             }
             try
             {
                 int num3 = Convert.ToInt32(text2);
                 num3--;
                 if (num3 >= 0 && num3 < Main.numLoadWorlds)
                 {
                     bool flag3 = true;
                     while (flag3)
                     {
                         Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber2 + ")");
                         Console.WriteLine("");
                         Console.Write("Server port (press enter for 7777): ");
                         string text5 = Console.ReadLine();
                         try
                         {
                             if (text5 == "")
                             {
                                 text5 = "7777";
                             }
                             int num5 = Convert.ToInt32(text5);
                             if (num5 <= 65535)
                             {
                                 Netplay.serverPort = num5;
                                 flag3 = false;
                             }
                         }
                         catch
                         {
                         }
                         try
                         {
                             Console.Clear();
                         }
                         catch
                         {
                         }
                     }
                     Main.worldPathName = Main.loadWorldPath[num3];
                     flag = false;
                     try
                     {
                         Console.Clear();
                     }
                     catch
                     {
                     }
                 }
             }
             catch
             {
             }
         }
     }
     try
     {
         Console.Clear();
     }
     catch
     {
     }
     WorldGen.serverLoadWorld();
     Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber + ")");
     Console.WriteLine("");
     while (!Netplay.ServerUp)
     {
         if (Main.oldStatusText != Main.statusText)
         {
             Main.oldStatusText = Main.statusText;
             Console.WriteLine(Main.statusText);
         }
     }
     try
     {
         Console.Clear();
     }
     catch
     {
     }
     Console.WriteLine("Toaria (Terraria Version " + Main.versionNumber + ")");
     Console.WriteLine("");
     Console.WriteLine("Listening on {0}:{1}",
         Netplay.serverListenIP != System.Net.IPAddress.Any ? Netplay.serverListenIP.ToString() : "*", Netplay.serverPort);
     Console.WriteLine("Type 'help' for a list of commands.");
     Console.WriteLine("");
     Console.Title = "Toaria: " + Main.worldName;
     Stopwatch stopwatch = new Stopwatch();
     if (!Main.autoShutdown)
     {
         Main.startDedInput();
     }
     GameHooks.OnInitialize(false);
     stopwatch.Start();
     double num6 = 16.666666666666668;
     double num7 = 0.0;
     int num8 = 0;
     Stopwatch stopwatch2 = new Stopwatch();
     stopwatch2.Start();
     while (!Netplay.disconnect)
     {
         double num9 = (double)stopwatch.ElapsedMilliseconds;
         if (num9 + num7 >= num6)
         {
             num8++;
             num7 += num9 - num6;
             stopwatch.Reset();
             stopwatch.Start();
             if (Main.oldStatusText != Main.statusText)
             {
                 Main.oldStatusText = Main.statusText;
                 Console.WriteLine(Main.statusText);
             }
             if (num7 > 1000.0)
             {
                 num7 = 1000.0;
             }
             if (Netplay.anyClients)
             {
                 GameHooks.OnUpdate(true);
                 this.Update();
                 GameHooks.OnUpdate(false);
             }
             double num10 = (double)stopwatch.ElapsedMilliseconds + num7;
             if (num10 < num6)
             {
                 int num11 = (int)(num6 - num10) - 1;
                 if (num11 > 1)
                 {
                     Thread.Sleep(num11);
                     if (!Netplay.anyClients)
                     {
                         num7 = 0.0;
                         Thread.Sleep(10);
                     }
                 }
             }
         }
         Thread.Sleep(0);
     }
 }