Ejemplo n.º 1
0
        public static Store <T> CreateStore(Reducer <T> reducer, T initialState, Enhancer <T> enhancer = null)
        {
            if (enhancer != null)
            {
                return(enhancer(CreateStore)(reducer, initialState, null));
            }

            return(new Store <T>(reducer, initialState));
        }
Ejemplo n.º 2
0
	public override Item Clone ()
	{
		Enhancer item = new Enhancer();
		base.CloneBase(item);
		
		//copy all vars before return
		return item;
	}
Ejemplo n.º 3
0
 internal void TerminalRefresh(bool update = true)
 {
     Enhancer.RefreshCustomInfo();
     if (update && InControlPanel && InThisTerminal)
     {
         MyCube.UpdateTerminal();
     }
 }
Ejemplo n.º 4
0
        static int Solve(string raw, int interations)
        {
            var input    = Transform(raw);
            var enhancer = new Enhancer(input);

            for (int i = 0; i < interations; i++)
            {
                enhancer.Step();

                //Console.WriteLine(enhancer);
                //Console.WriteLine();
            }

            return(enhancer.NumPixelsOn());
        }
Ejemplo n.º 5
0
 private void BeforeInit()
 {
     if (Enhancer.CubeGrid.Physics == null)
     {
         return;
     }
     Session.Instance.Enhancers.Add(this);
     PowerInit();
     Entity.TryGetSubpart("Rotor", out _subpartRotor);
     _isServer    = Session.Instance.IsServer;
     _isDedicated = Session.Instance.DedicatedServer;
     Enhancer.RefreshCustomInfo();
     NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
     _bTime       = _isDedicated ? 10 : 1;
     _bInit       = true;
 }
Ejemplo n.º 6
0
        private void Timing()
        {
            if (_count++ == 59)
            {
                _count = 0;
                _lCount++;
                if (_lCount == 10)
                {
                    _lCount = 0;
                }
            }

            if (!_isDedicated && _count == 29 && MyAPIGateway.Gui.GetCurrentScreen == MyTerminalPageEnum.ControlPanel && Session.Instance.LastTerminalId == Enhancer.EntityId)
            {
                Enhancer.RefreshCustomInfo();
            }
        }
Ejemplo n.º 7
0
 public override void UpdateOnceBeforeFrame()
 {
     base.UpdateOnceBeforeFrame();
     try
     {
         if (Enhancer.CubeGrid.Physics == null)
         {
             return;
         }
         Session.Instance.Enhancers.Add(this);
         PowerInit();
         Entity.TryGetSubpart("Rotor", out _subpartRotor);
         _isServer    = Session.Instance.IsServer;
         _isDedicated = Session.Instance.DedicatedServer;
         Enhancer.RefreshCustomInfo();
     }
     catch (Exception ex) { Log.Line($"Exception in UpdateOnceBeforeFrame: {ex}"); }
 }
Ejemplo n.º 8
0
 private void NeedUpdate(bool onState, bool turnOn)
 {
     if (!onState && turnOn)
     {
         EnhState.State.Online = true;
         EnhState.SaveState();
         EnhState.NetworkUpdate();
         if (!_isDedicated)
         {
             Enhancer.RefreshCustomInfo();
         }
     }
     else if (onState & !turnOn)
     {
         EnhState.State.Online = false;
         EnhState.SaveState();
         EnhState.NetworkUpdate();
         if (!_isDedicated)
         {
             Enhancer.RefreshCustomInfo();
         }
     }
 }
Ejemplo n.º 9
0
	void DrawEnhancerList(ItemDataBase control)
	{
		ItemIndex = EditorGUILayout.IntSlider("Item Index", ItemIndex, 0, control.EnhancerList.Count - 1);
		
		EditorGUILayout.BeginHorizontal();
		
		if(GUILayout.Button("Add Item"))
		{
			var newEnhancer = new Enhancer();
			newEnhancer.Type = ItemType.Enhancer;
			control.EnhancerList.Add(newEnhancer);
			ItemIndex = control.EnhancerList.Count - 1;
		}
		
		if(GUILayout.Button("Remove Item"))
		{
			control.EnhancerList.RemoveAt(ItemIndex);
			ItemIndex = control.EnhancerList.Count - 1;
		}
		
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.Space();
		
		CommonItemProps(control.EnhancerList[ItemIndex]);
	}
Ejemplo n.º 10
0
        public virtual async Task <ProcessResult> ProcessAsync(Frame frame, Windows.Foundation.Rect area, double rotation)
        {
            var timedExecution = new Internal.TimedExecution();
            var normalizeTime  = new TimeSpan(0);
            var enhanceTime    = new TimeSpan(0);
            var decodeTime     = new TimeSpan(0);

            NormalizeResult normalizeResult = null;

            if (Normalizer != null)
            {
                normalizeResult = await timedExecution.ExecuteAsync <NormalizeResult>(
                    Normalizer.NormalizeAsync(frame, area, rotation).AsAsyncOperation());

                normalizeTime = timedExecution.ExecutionTime;
                frame         = normalizeResult.Frame;
            }

            if (Enhancer != null)
            {
                var enhanceResult = await timedExecution.ExecuteAsync <EnhanceResult>(
                    Enhancer.EnhanceAsync(frame).AsAsyncOperation());

                enhanceTime = timedExecution.ExecutionTime;
                frame       = enhanceResult.Frame;
            }

            var decodeResult = await timedExecution.ExecuteAsync <DecodeResult>(
                Decoder.DecodeAsync(frame).AsAsyncOperation());

            decodeTime = timedExecution.ExecutionTime;

#if DEBUG
            System.Diagnostics.Debug.WriteLine(String.Format(
                                                   "Normalizing took {0} ms, enhancing took {1} ms, decoding took {2}, which totals to {3} ms",
                                                   (int)normalizeTime.TotalMilliseconds, (int)enhanceTime.TotalMilliseconds, (int)decodeTime.TotalMilliseconds,
                                                   (int)(normalizeTime + enhanceTime + decodeTime).TotalMilliseconds));
#endif // DEBUG

            if (DebugFrameAvailable != null)
            {
                DebugFrameAvailable(this, new DebugFrameEventArgs()
                {
                    DebugFrame = frame
                });
            }

            if (decodeResult != null)
            {
                var interestPoints = decodeResult.InterestPoints;

                if (interestPoints != null)
                {
                    if (normalizeResult != null && normalizeResult.Translate != null)
                    {
                        var translatedInterestPoints = new List <Windows.Foundation.Point>();

                        foreach (var point in interestPoints)
                        {
                            translatedInterestPoints.Add(normalizeResult.Translate(point));
                        }

                        interestPoints = translatedInterestPoints;
                    }
                }

                return(new ProcessResult()
                {
                    Data = decodeResult.Data,
                    Format = decodeResult.Format,
                    Text = decodeResult.Text,
                    InterestPoints = interestPoints
                });
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
	protected Enhancer(Enhancer other) : base(other)
	{

	}