Example #1
0
    void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("captureZone") && infectionState == InfectionState.Clean)
        {
            CaptureZone zoneRef = other.GetComponent <CaptureZone>();

            if (zoneRef.infectionState == CaptureZone.InfectionState.P1Red)
            {
                infectionTimerCatP1Red -= Time.deltaTime;
                if (infectionTimerCatP1Red <= 0)
                {
                    catP1RedConscripts.AddConscript(humanNavigation);
                    BecomeInfectedWith((int)zoneRef.infectionState);
                }
            }
            if (zoneRef.infectionState == CaptureZone.InfectionState.P2Blu)
            {
                infectionTimerCatP2Blu -= Time.deltaTime;
                if (infectionTimerCatP2Blu <= 0)
                {
                    catP2BluConscripts.AddConscript(humanNavigation);
                    BecomeInfectedWith((int)zoneRef.infectionState);
                }
            }
            if (zoneRef.infectionState == CaptureZone.InfectionState.P3Grn)
            {
                infectionTimerCatP3Grn -= Time.deltaTime;
                if (infectionTimerCatP3Grn <= 0)
                {
                    catP3GrnConscripts.AddConscript(humanNavigation);
                    BecomeInfectedWith((int)zoneRef.infectionState);
                }
            }
        }
    }
        private static Image ReadBitmap(GeckoWebBrowser webBrowser, CaptureZone captureZone, IActiveDocument activeDocument)
        {
            webBrowser.Stop();

            var rectangle = captureZone.GetZone(activeDocument);

            if (rectangle.Width == 0 || rectangle.Height == 0)
            {
                throw new CaptureEngineException($"Selected zone is 0 area {rectangle}", CaptureEngineState.InvalidCaptureZone);
            }

            try
            {
                return(webBrowser.GetBitmap(
                           (uint)rectangle.X,
                           (uint)rectangle.Y,
                           (uint)rectangle.Width,
                           (uint)rectangle.Height));
            }
            catch (InvalidOperationException)
            {
                throw new CaptureEngineException("Out of memory. Result bitmap size is too large",
                                                 CaptureEngineState.InternalError);
            }
        }
Example #3
0
    protected virtual void OnSceneGUI()
    {
        CaptureZone tri = (CaptureZone)target;

        EditorGUI.BeginChangeCheck();

        Vector3[] pos = tri.Points;
        Handles.matrix = tri.transform.localToWorldMatrix;

        for (int i = 0; i < tri.Points.Length; i++)
        {
            pos[i]   = Handles.PositionHandle(pos[i], Quaternion.identity);
            pos[i].y = 0;
        }

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(tri, "Change Points");
            tri.Points = pos;
            if (tri.enabled)
            {
                tri.OnEnable();
            }
        }
    }
Example #4
0
 public EngineDomainWrapper(Size browserSize, Trigger trigger, CaptureZone captureZone)
     : base(browserSize, trigger, captureZone)
 {
     CurrentDomainName = $"enginedomainmanager{Guid.NewGuid()}";
     _currentDomain    = AppDomain.CreateDomain(CurrentDomainName, null, new AppDomainSetup {
         ApplicationBase = Environment.CurrentDirectory
     });
 }
Example #5
0
 //used to add an element to a capture zone when clicked
 public void enqueueElement(string elementName)
 {
     if (lastZone == CaptureZone.Zone1)
     {
         zone2Capturer.captureElement(GlobalVars.ELEMENT_SPRITES[elementName]);
         lastZone = CaptureZone.Zone2;
     }
     else if (lastZone == CaptureZone.Zone2)
     {
         zone1Capturer.captureElement(GlobalVars.ELEMENT_SPRITES[elementName]);
         lastZone = CaptureZone.Zone1;
     }
 }
Example #6
0
        public CaptureZone RegisterCaptureZone(int x, int y, int width, int height, int downscaleLevel = 0)
        {
            lock (_screenCapture)
            {
                CaptureZone captureZone = _screenCapture.RegisterCaptureZone(x, y, width, height, downscaleLevel);
                _zoneCount++;

                if (_updateTask == null)
                {
                    _cancellationTokenSource = new CancellationTokenSource();
                    _cancellationToken       = _cancellationTokenSource.Token;
                    _updateTask = Task.Run(UpdateLoop, _cancellationToken);
                }

                return(captureZone);
            }
        }
        public void RecreateCaptureZone()
        {
            if (PropertiesOpen || _creatingCaptureZone)
            {
                return;
            }

            try
            {
                _creatingCaptureZone = true;
                RemoveCaptureZone();
                AmbilightCaptureProperties props = Properties.Capture;
                bool defaulting = props.GraphicsCardDeviceId == 0 || props.GraphicsCardVendorId == 0 || props.DisplayName.CurrentValue == null;

                GraphicsCard?graphicsCard = _screenCaptureService.GetGraphicsCards()
                                            .Where(gg => defaulting || (gg.VendorId == props.GraphicsCardVendorId) && (gg.DeviceId == props.GraphicsCardDeviceId))
                                            .Cast <GraphicsCard?>()
                                            .FirstOrDefault();
                if (graphicsCard == null)
                {
                    return;
                }

                _display = _screenCaptureService.GetDisplays(graphicsCard.Value)
                           .Where(d => defaulting || d.DeviceName.Equals(props.DisplayName.CurrentValue, StringComparison.OrdinalIgnoreCase))
                           .Cast <Display?>()
                           .FirstOrDefault();
                if (_display == null)
                {
                    return;
                }

                // If we're defaulting or always capturing full screen, apply the display to the properties
                if (defaulting || props.CaptureFullScreen.CurrentValue)
                    props.ApplyDisplay(_display.Value, true); }

                // Stick to a valid region within the display
                int width  = Math.Min(_display.Value.Width, props.Width);
                int height = Math.Min(_display.Value.Height, props.Height);
                int x      = Math.Min(_display.Value.Width - width, props.X);
                int y      = Math.Min(_display.Value.Height - height, props.Y);
                _captureZone                     = _screenCaptureService.GetScreenCapture(_display.Value).RegisterCaptureZone(x, y, width, height, props.DownscaleLevel);
                _captureZone.AutoUpdate          = false; //TODO DarthAffe 09.04.2021: config?
                _captureZone.BlackBars.Threshold = props.BlackBarDetectionThreshold;
            }
Example #8
0
        public bool UnregisterCaptureZone(CaptureZone captureZone)
        {
            lock (_screenCapture)
            {
                bool result = _screenCapture.UnregisterCaptureZone(captureZone);
                if (result)
                {
                    _zoneCount--;
                }

                if ((_zoneCount == 0) && (_updateTask != null))
                {
                    _cancellationTokenSource.Cancel();
                    _updateTask = null;
                }

                return(result);
            }
        }
Example #9
0
        protected CaptureEngine(Size browserSize, Trigger trigger, CaptureZone captureZone)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException(nameof(trigger));
            }

            if (captureZone == null)
            {
                throw new ArgumentNullException(nameof(captureZone));
            }

            if (browserSize.IsEmpty || browserSize.Width <= 0 || browserSize.Height <= 0)
            {
                throw new ArgumentException($"{nameof(browserSize)} surface must be > 0", nameof(browserSize));
            }

            BrowserSize = browserSize;
            Trigger     = trigger;
            CaptureZone = captureZone;
        }
Example #10
0
 public GeckoCaptureEngine(Size browserSize, Trigger trigger, CaptureZone captureZone)
     : base(browserSize, trigger, captureZone)
 {
     new ThreadLocal <LocalInitializer>(() => new LocalInitializer()).Value.Init();
 }
Example #11
0
 public WorkerEngine(Size browserSize, Trigger trigger, CaptureZone captureZone, IWorkerPool <IWorker> workerPool) : base(browserSize, trigger, captureZone)
 {
     _workerPool = workerPool;
 }
Example #12
0
 public WorkerEngine(Size browserSize, Trigger trigger, CaptureZone captureZone) :
     this(browserSize, trigger, captureZone, FreezerGlobal.Workers)
 {
     _cascadeDisposeWorkerPool = false;
 }
Example #13
0
 public void SetCaptureZone(CaptureZone value)
 {
     _captureZoneData = value.ToByteArray();
 }
	//used to add an element to a capture zone when clicked
	public void enqueueElement (string elementName) {
		if (lastZone == CaptureZone.Zone1) {
			zone2Capturer.captureElement(GlobalVars.ELEMENT_SPRITES[elementName]);
			lastZone = CaptureZone.Zone2;
		} else if (lastZone == CaptureZone.Zone2) {
			zone1Capturer.captureElement(GlobalVars.ELEMENT_SPRITES[elementName]);
			lastZone = CaptureZone.Zone1;
		}
	}