public static void SharedVisualizeTestResults(
            ITempList <TestResult> physicsTestResults,
            CollisionGroup collisionGroup)
        {
            if (IsClient)
            {
                using var testResults = Api.Shared.GetTempList <Vector2D>();
                AddTestResults(physicsTestResults.AsList(), testResults.AsList());
                ClientComponentPhysicsSpaceVisualizer.VisualizeTestResults(testResults.AsList(),
                                                                           collisionGroup,
                                                                           isClient: true);
            }
            else // if server
            {
                Api.Assert(Api.IsEditor, "This is Editor-only server code");
                var allPlayers = Server.Characters.EnumerateAllPlayerCharacters(onlyOnline: true,
                                                                                exceptSpectators: false);

                var testResults = new List <Vector2D>();
                AddTestResults(physicsTestResults.AsList(), testResults);

                var collisionGroupId = CollisionGroups.GetCollisionGroupId(collisionGroup);
                instance.CallClient(
                    allPlayers,
                    // ReSharper disable once AccessToDisposedClosure
                    _ => _.ClientRemote_ProcessServerTestResults(testResults, collisionGroupId));
            }
        }
Ejemplo n.º 2
0
        private static uint SharedCalculateTotalEnergyCharge(
            ITempList <IItem> tempItemsList,
            uint stopIfEnergyExceeds = uint.MaxValue)
        {
            ulong result = 0;

            foreach (var item in tempItemsList.AsList())
            {
                var privateState = SharedGetPrivateState(item);
                var charge       = privateState.DurabilityCurrent;
                result += charge;

                if (result >= stopIfEnergyExceeds)
                {
                    break;
                }
            }

            return((uint)Math.Min(uint.MaxValue, result));
        }