Beispiel #1
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;
            }
        }
Beispiel #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);
            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();
            });
        }