public override void ForEach(IBaseObjectCallback <IColShape> baseObjectCallback)
 {
     foreach (var baseObject in GetAllObjects())
     {
         using var baseObjectRef = new ColShapeRef(baseObject);
         if (!baseObjectRef.Exists)
         {
             continue;
         }
         baseObjectRef.DebugCountUp();
         baseObjectCallback.OnBaseObject(baseObject);
         baseObjectRef.DebugCountDown();
     }
 }
Esempio n. 2
0
        public override void OnColShapeEvent(IColShape colShape, IEntity entity, bool state)
        {
            base.OnColShapeEvent(colShape, entity, state);
            if (!ColShapeAsyncDelegateHandlers.HasEvents())
            {
                return;
            }
            var colShapeReference = new ColShapeRef(colShape);

            switch (entity)
            {
            case IPlayer playerEntity:
                var playerEntityReference = new PlayerRef(playerEntity);
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    playerEntityReference.Dispose();
                    colShapeReference.Dispose();
                });
                break;

            case IVehicle vehicleEntity:
                var vehicleEntityReference = new VehicleRef(vehicleEntity);
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    vehicleEntityReference.Dispose();
                    colShapeReference.Dispose();
                });
                break;

            default:
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    colShapeReference.Dispose();
                });
                break;
            }
        }
Esempio n. 3
0
        public override void OnColShapeEvent(IColShape colShape, IEntity entity, bool state)
        {
            base.OnColShapeEvent(colShape, entity, state);
            if (!ColShapeAsyncDelegateHandlers.HasEvents())
            {
                return;
            }
            var colShapeReference = new ColShapeRef(colShape);
            var baseObjectRef     = new BaseObjectRef(entity);

            Task.Run(async() =>
            {
                colShapeReference.DebugCountUp();
                baseObjectRef.DebugCountUp();
                await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                              @delegate(colShape, entity, state));
                baseObjectRef.DebugCountDown();
                colShapeReference.DebugCountDown();
                baseObjectRef.Dispose();
                colShapeReference.Dispose();
            });
        }