コード例 #1
0
 void Aux(int ticks)
 {
     if (Tool.IsToolWorking() && PowerModule.HasEnoughPower)
     {
         BeamCtlModule.DrawBeam();
     }
 }
コード例 #2
0
        void Main(int ticks = 0)
        {
            try
            {
                if (ticks == 0)
                {
                    ticks = SessionCore.WorkSkipTicks;
                }
                System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                if (Tool.IsToolWorking())
                {
                    watch.Start();
                }
                try
                {
                    if (IsWelder && LocalPlayerIsOwner && HUDModule.MessageExpired)
                    {
                        MissingHUD.Hide();
                    }
                    PowerModule.SetPowerUsage();

                    if (Tool.IsToolWorking() && PowerModule.HasEnoughPower)
                    {
                        Work(ticks);
                        BeamCtlModule.DrawBeam();
                    }
                    else if (!PowerModule.HasEnoughPower)
                    {
                        DebugNote.Text = $"{Tool.CustomName}: not enough power";
                    }
                    else
                    {
                        DebugNote.Text = $"{Tool.CustomName}: idle";
                        //UnbuiltBlocks.Clear();
                    }
                    Tool.RefreshCustomInfo();
                    //if (SessionCore.Debug) DebugNote.Text = $"{Tool.CustomName} perf. impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 5).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 5).ToString() : "--")} ms (avg/max)";
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.Main().Work()", Scrap);
                }
                if (Tool.IsToolWorking())
                {
                    watch.Stop();
                    watch.Report(Tool.CustomName, "Main()");
                }
            }
            catch (Exception Scrap)
            {
                SessionCore.LogError($"{Tool.CustomName}.Main()", Scrap);
            }
        }