Ejemplo n.º 1
0
 public void MinAsync(string columnName, SqlCondition condition, BasicAction <TableKey> onMin)
 {
     SqlManager.PoolAsyncOperation(() => {
         var min = _database.Min <TableKey>(columnName, condition);
         onMin?.Invoke(min);
     });
 }
Ejemplo n.º 2
0
 public void ExistAsync(SqlCondition condition, BasicAction <bool> onExist, bool distinct)
 {
     SqlManager.PoolAsyncOperation(() => {
         var count = _database.Count <TableKey>(condition, distinct);
         onExist?.Invoke(count > 0);
     });
 }
Ejemplo n.º 3
0
 public void SumAsync(string columnName, SqlCondition condition, BasicAction <decimal> onSum)
 {
     SqlManager.PoolAsyncOperation(() => {
         var sum = _database.Sum <TableKey>(columnName, condition);
         onSum?.Invoke(sum);
     });
 }
Ejemplo n.º 4
0
 public void SelectAllAsync(SqlCondition condition, BasicAction <TableKey[]> onSelected, bool distinct, params string[] columnsToSelect)
 {
     SqlManager.PoolAsyncOperation(() => {
         var tables = _database.SelectAll <TableKey>(condition, distinct, columnsToSelect);
         onSelected?.Invoke(tables);
     });
 }
Ejemplo n.º 5
0
 public void CountAsync(string columnName, SqlCondition condition, BasicAction <long> onCounted, bool distinct)
 {
     SqlManager.PoolAsyncOperation(() => {
         var count = _database.Count <TableKey>(columnName, condition, distinct);
         onCounted?.Invoke(count);
     });
 }
        BasicAction GetSecondaryAction(InteractableRaw thisInteractable, InteractorRaw interactor)
        {
            BasicAction action = null;

            switch (secondary)
            {
            case SecondGrab.None:
                action = new NothingAction(thisInteractable, interactor);
                break;

            case SecondGrab.Switch:
                action = new SwitchAction(thisInteractable, interactor);
                break;

            case SecondGrab.Scale:
                break;

            case SecondGrab.LookAt:
                var updateType = followType == FollowType.Transform ? UpdateEvents.BeforeRender : UpdateEvents.FixedUpdate;
                action = new LookAtAction(thisInteractable, interactor, ((FollowAction)grab.grabbedObjects[0].action).offset, true, updateType);
                break;
            }

            return(action);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// action's effect on worldState.
 /// </summary>
 /// <returns>returns the estimated effect of action on worldState</returns>
 public WorldState CalculateEffectOnWorld(BasicAction action, WorldState worldState)
 {
     // get memory of other times, compare with current world state
     //	WorldState estimatedEffect = action.memory.EstimateEffectOn(worldState);
     WorldState estimatedEffect = worldState;
     return estimatedEffect;
 }
            public void NotifyGrab(InteractorRaw interactor)
            {
                if (!interactor)
                {
                    return;
                }

                if (grabbedObjects.Count == 0)
                {
                }
                BasicAction grabTypeAction = null;

                //Utils.CleanInteractions.CleanInteracableTouching(interactor, ref parent.touch.touchedObjects);
                if (grabbedObjects.Count < 1)
                {
                    grabTypeAction = parent.PrimaryActionEvent(parent, interactor);
                }
                else                //bool canGrab
                if (grabbedObjects.Count == 1)
                {
                    grabTypeAction = parent.SecondaryActionEvent(parent, interactor);
                }

                if (grabTypeAction != null)
                {
                    grabbedObjects.Add(new GrabData(interactor, parent, grabTypeAction));

                    parent.Grabbed?.Invoke(interactor);

                    GrabProccess();
                }
            }
Ejemplo n.º 9
0
 public void AverageAsync(string columnName, SqlCondition condition, BasicAction <long> onAverage)
 {
     SqlManager.PoolAsyncOperation(() => {
         var average = _database.Average <TableKey>(columnName, condition);
         onAverage?.Invoke(average);
     });
 }
Ejemplo n.º 10
0
 public void MaxAsync(string columnName, SqlCondition condition, BasicAction <TableKey> onMax)
 {
     SqlManager.PoolAsyncOperation(() => {
         var max = _database.Max <TableKey>(columnName, condition);
         onMax?.Invoke(max);
     });
 }
Ejemplo n.º 11
0
        public static double GetElapsedMilliseconds(BasicAction handler)
        {
            var clock = new Clock();

            handler();

            return(clock.GetElapsedMilliseconds());
        }
 public GrabData(InteractorRaw _hand, InteractableRaw _interactable, BasicAction _action)
 {
     interactor         = _hand;
     interactable       = _interactable;
     action             = _action;
     kinematicOnRelease = interactable.mainRigidbody.isKinematic;
     gravityOnRelease   = interactable.mainRigidbody.useGravity;
 }
Ejemplo n.º 13
0
 public TrialRunner(string name, BasicAction action, TimeSpan maxTime, InvocationCompleteAction runCompleteAction, InvocationCompleteAction batchCompleteAction)
 {
     Name = name;
     Action = action;
     MaxTime = maxTime;
     RunCompleteAction = runCompleteAction;
     BatchCompleteAction = batchCompleteAction;
 }
Ejemplo n.º 14
0
            internal NextFrameExecution(BasicAction action)
            {
                if (action != null)
                {
                    _action = action;

                    RuntimeManager.RtUpdate += Execute;
                }
            }
Ejemplo n.º 15
0
        /// <summary>
        /// Create a new instance of <see cref="SqlCondition"/> and attach to the current instance of <see cref="QueryAccessor{TableKey}"/>
        /// </summary>
        /// <param name="onCondition"></param>
        /// <returns></returns>
        public QueryAccessor <TableKey> UseCondition(BasicAction <SqlCondition> onCondition)
        {
            if (_cd == null)
            {
                _cd = new SqlCondition();
            }

            onCondition(_cd);
            return(this);
        }
Ejemplo n.º 16
0
 public void DeleteAsync(SqlCondition condition, BasicAction onDeleted)
 {
     SqlManager.PoolAsyncOperation(() => {
         var deleted = _database.Delete <TableKey>(condition);
         if (deleted)
         {
             onDeleted?.Invoke();
         }
     });
 }
Ejemplo n.º 17
0
 public void UpdateAllAsync(TableKey reference, BasicAction onUpdated, params string[] columnsToUpdate)
 {
     SqlManager.PoolAsyncOperation(() => {
         var updated = _database.UpdateAll(reference, columnsToUpdate);
         if (updated)
         {
             onUpdated?.Invoke();
         }
     });
 }
Ejemplo n.º 18
0
            internal ExecuteScriptIn(float time, BasicAction <ExecuteScriptIn> action, bool permanent)
            {
                _action   = action;
                _time     = time;
                Permanent = permanent;

                RuntimeManager.RtUpdate += Update;

                IsRunning = true;
            }
Ejemplo n.º 19
0
 internal static void OnReader(this MySqlCommand command, BasicAction <MySqlDataReader> readerCallback)
 {
     using (var reader = command.ExecuteReader())
     {
         while (reader.Read())
         {
             readerCallback(reader);
         }
     }
 }
Ejemplo n.º 20
0
 public void DeleteAllAsync(BasicAction onDeleted)
 {
     SqlManager.PoolAsyncOperation(() => {
         var deleted = _database.DeleteAll <TableKey>();
         if (deleted)
         {
             onDeleted?.Invoke();
         }
     });
 }
Ejemplo n.º 21
0
 public IActionViewModel NewActionViewModel(BasicAction actionType)
 {
     try
     {
         return((IActionViewModel)Activator.CreateInstance(Type.GetType("EMM.Core.ViewModels." + Enum.GetName(typeof(BasicAction), actionType) + "ViewModel"), this.GetDependency <SimpleAutoMapper>(), this));
     }
     catch
     {
         throw new NotImplementedException("Cannot create an instance of this viewmodel. Maybe it's not yet implemented");
     }
 }
Ejemplo n.º 22
0
 public static void SetTypeSerialization(Type type, BasicAction <BasicWriter, object> serialization)
 {
     if (!_typageDefinitions.ContainsKey(type))
     {
         _typageDefinitions.Add(type, serialization);
     }
     else
     {
         _typageDefinitions[type] = serialization;
     }
 }
Ejemplo n.º 23
0
        private static string UseBuilder(string baseStr, SqlCondition condition, BasicAction <StringBuilder> onBuilder)
        {
            var sb = new StringBuilder(baseStr);

            onBuilder?.Invoke(sb);

            if (condition != null)
            {
                sb.Append($" { condition.GetQuery() }");
            }

            return(sb.ToString());
        }
Ejemplo n.º 24
0
 internal void ExecuteCommand(string query, BasicAction <MySqlCommand> onCommand, bool force = false)
 {
     if (IsInitialized || force)
     {
         using (var conn = CreateConnection())
         {
             using (var cmd = new MySqlCommand(query, conn))
             {
                 onCommand(cmd);
             }
         }
     }
 }
        public static void Execute(ICommand command, BasicAction onFailure = null)
        {
            try
            {
                command.Execute();
            }
            catch (Exception exception)
            {
                DebugHelper.PrintCommandExceptionMessage(exception, command);

                if (onFailure != null)
                    onFailure();
            }
        }
Ejemplo n.º 26
0
 internal void ExecuteCommand(BasicAction <MySqlCommand> onCommand, bool force = false)
 {
     if (IsInitialized || force)
     {
         using (var conn = CreateConnection())
         {
             using (var cmd = new MySqlCommand())
             {
                 cmd.Connection = conn;
                 onCommand(cmd);
             }
         }
     }
 }
Ejemplo n.º 27
0
        public IActionScriptGenerator GetActionScriptGenerator(Emulator emulator, BasicAction basicAction)
        {
            if (!dict.ContainsKey(emulator))
            {
                throw new NotImplementedException(emulator.ToString() + " is not implemented");
            }

            var actionDict = dict[emulator];

            if (!actionDict.ContainsKey(basicAction))
            {
                throw new NotImplementedException(basicAction.ToString() + " is not implemented");
            }

            return(actionDict[basicAction]);
        }
Ejemplo n.º 28
0
        public IActionViewModel NewActionViewModel(BasicAction actionType)
        {
            try
            {
                var type = Type.GetType("EMM.Core.ViewModels." + Enum.GetName(typeof(BasicAction), actionType) + "ViewModel");
                if (type == typeof(ActionGroupViewModel) || type == typeof(CustomActionViewModel))
                {
                    return((IActionViewModel)Activator.CreateInstance(type, this.GetDependency <SimpleAutoMapper>(), this, this.GetDependency <ViewModelClipboard>()));
                }

                return((IActionViewModel)Activator.CreateInstance(type, this.GetDependency <SimpleAutoMapper>(), this));
            }
            catch
            {
                throw new NotImplementedException("Cannot create an instance of this viewmodel. Maybe it's not yet implemented");
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Tries to pass and verify passage of an agility obstacle
        /// </summary>
        /// <param name="passObstacle">method for passing the obstacle</param>
        /// <param name="verifyPassedObstacle">method for verifying passage of the obstacle</param>
        /// <returns></returns>
        protected bool TryPassObstacle(BasicAction passObstacle, BasicAction verifyPassedObstacle)
        {
            verifyPassedObstacle = verifyPassedObstacle ?? HasPassedObstacle;
            int remainingTries = MaxPassObstacleTries;

            while (remainingTries-- > 0)
            {
                if (passObstacle() && verifyPassedObstacle())
                {
                    return(true);
                }
                if (StopFlag)
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Attempts to clear each of a list of obstacles.
        /// Stops trying after an obstacle is failed.
        /// </summary>
        /// <param name="obstacles">list of pass and verify methods for a series of obstacles</param>
        /// <returns>True if successful for all obstacles. False if we fail on any obstacle.</returns>
        protected bool TryPassObstacles(List <Tuple <BasicAction, BasicAction> > obstacles)
        {
            foreach (Tuple <BasicAction, BasicAction> obstacle in obstacles)
            {
                if (StopFlag)
                {
                    return(false);
                }

                BasicAction tryPass      = obstacle.Item1;
                BasicAction verifyPassed = obstacle.Item2;
                if (!TryPassObstacle(tryPass, verifyPassed))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 31
0
    // this function returns the utility for this action, as specified by the different goals and the worldState argument
    public float CalculateUtilityFunction(BasicAction action, WorldState worldState, int steps = 1)
    {
        // calculate this many steps into the future
        while (steps > 0) {

            WorldState effect = CalculateEffectOnWorld(action, worldState);
            float sum = 0;
            foreach (var g in agentController.goals) {
                sum += g.Utility(effect);

            }
            // now we have the sum of utilities from each goal. this is the total utility score of this action on this world.

            // multiply by discount factor depending on the number of steps. the more steps, the less utility the action should have.

            steps--;
        }
        return 0;
    }
Ejemplo n.º 32
0
    public void ActivateEndGameCredits(BasicAction callback)
    {
        List <CanvasRenderer> canvasList = new List <CanvasRenderer>();

        ListCanvasRendererRecursive(this.gameObject, canvasList);

        foreach (CanvasRenderer cr in canvasList)
        {
            float alpha = cr.GetAlpha();
            cr.SetAlpha(1);
        }

        aboutGroup.SetActive(true);
        Button bt = aboutGroup.transform.Find("ReturnButton").GetComponent <Button>();

        bt.enabled = true;

        bt.onClick.RemoveAllListeners();
        bt.onClick.AddListener(delegate(){ callback(); });
    }
Ejemplo n.º 33
0
 public void Add(string name, BasicAction action)
 {
     trialRunners.Enqueue(new TrialRunner(name, action, maxTime, a => { }, a => { }));
 }
 public SeparateThreadTimer(BasicAction onTick, int interval)
 {
     _onTick = onTick;
     _interval = interval;
 }
Ejemplo n.º 35
0
 public void RunAction(BasicAction action, BasicAction.DelegateMessage delegateMessage)
 {
     ActionManager.GetInstance().RunAction(this, action, delegateMessage);
 }
Ejemplo n.º 36
0
 public void Run(string name, BasicAction action)
 {
     new TrialRunner(name, action, maxTime, result => { }, result => { }).Run();
 }
Ejemplo n.º 37
0
 public void Run(string name, BasicAction action, InvocationCompleteAction runCompleteAction, InvocationCompleteAction batchCompleteAction)
 {
     new TrialRunner(name, action, maxTime, runCompleteAction, batchCompleteAction).Run();
 }
Ejemplo n.º 38
0
 public void SumAsync(string columnName, BasicAction <decimal> onSum)
 {
     SumAsync(columnName, _cd, onSum);
 }
Ejemplo n.º 39
0
 public void Add(string name, BasicAction action, InvocationCompleteAction runCompleteAction, InvocationCompleteAction batchCompleteAction)
 {
     trialRunners.Enqueue(new TrialRunner(name, action, maxTime, runCompleteAction, batchCompleteAction));
 }
Ejemplo n.º 40
0
 public InvocationResult Run(string name, BasicAction action, TimeSpan maxTime, InvocationCompleteAction runCompleteAction, InvocationCompleteAction batchCompleteAction)
 {
     return new TrialRunner(name, action, maxTime, runCompleteAction, batchCompleteAction).Run();
 }
Ejemplo n.º 41
0
        private static double InvokeAsBatch(BasicAction action)
        {
            var stopwatch = new Stopwatch();
            long invocationCount = 0;

            stopwatch.Start();

            while (stopwatch.Elapsed < MinimumBatchTime)
            {
                action.Invoke();
                ++invocationCount;
            }

            stopwatch.Stop();

            return stopwatch.Elapsed.TotalMilliseconds / invocationCount;
        }