コード例 #1
0
ファイル: SaveObjManager.cs プロジェクト: DrDoak/LittleDeity
    bool m_checkRegister(GameObject go)
    {
        PersistentItem c  = go.GetComponent <PersistentItem> ();
        string         id = GenerateID(go, c.data.prefabPath);

        //Debug.Log ("Checking if character: " + c + " registered id is: " + c.data.regID);
        //Debug.Log ("incoming ID: " + c.data.regID);
        if (c.data.regID != "Not Assigned")
        {
            id = c.data.regID;
        }
        if (registeredPermItems.Contains(id))
        {
            if (c.recreated)
            {
                //Debug.Log ("Recreated entity: " + c.data.regID);
                c.recreated = false;
                return(false);
            }
            else
            {
                //Debug.Log ("already registered, removing");
                return(true);
            }
        }
        //Debug.Log ("new entity. " + id + " Adding to registry");
        registeredPermItems.Add(id);
        c.data.regID = id;
        //Debug.Log ("saved ID is: " + c.data.regID);
        //Debug.Log ("Length of registry is: " + registeredPermItems.Count);
        return(false);
    }
コード例 #2
0
ファイル: FormAddAssociation.cs プロジェクト: psulek/doemd
 public ResultData(bool simpleMode, string associationName, PersistentItem persistentItem1,
                   PersistentItem persistentItem2)
 {
     SimpleMode      = simpleMode;
     AssociationName = associationName;
     PersistentItem1 = persistentItem1;
     PersistentItem2 = persistentItem2;
 }
コード例 #3
0
        /// <summary>
        /// The processor.
        /// </summary>
        /// <param name="item">Bulk of <see cref="TInput"/> to process</param>
        /// <param name="progress">Progress of the current bulk</param>
        /// <param name="cancellationToken"><see cref="CancellationToken"/></param>
        /// <returns><see cref="Task"/></returns>
        protected override async Task Process(Func <TInput> item, IProgress <double> progress,
                                              CancellationToken cancellationToken)
        {
            var policy = Policy
                         .Handle <Exception>(ex => !(ex is TaskCanceledException || ex is OperationCanceledException))
                         .WaitAndRetryAsync(_clusterOptions.RetryAttempt,
                                            retryAttempt =>
                                            TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
                                            (exception, sleepDuration, retry, context) =>
            {
                if (retry >= _clusterOptions.RetryAttempt)
                {
                    _logger.LogError(
                        $"Could not process item after {retry} retry times: {exception.Message}");
                }
            });

            var policyResult = await policy.ExecuteAndCaptureAsync(async ct =>
            {
                try
                {
                    if (CpuUsage > _clusterOptions.LimitCpuUsage)
                    {
                        var suspensionTime = (CpuUsage - _clusterOptions.LimitCpuUsage) / CpuUsage * 100;
                        await Task.Delay((int)suspensionTime, ct);
                    }

                    var entity = item();
                    var persistentCacheToken = new CancellationTokenSource();
                    var persistentItem       = new PersistentItem <TInput>(entity, persistentCacheToken);
                    if (_clusterOptions.PersistenceEnabled)
                    {
                        _synchronizedDispatcherSubject.OnNext(persistentItem);
                    }

                    await _remoteContract.ProcessRemotely(entity, NodeMetrics);
                    persistentItem.CancellationTokenSource.Cancel();
                }
                catch (Exception ex) when(ex is TaskCanceledException || ex is OperationCanceledException)
                {
                    _logger.LogTrace("The item process has been cancelled.");
                }
                finally
                {
                    Interlocked.Increment(ref _executorProcessedItems);
                }
            }, cancellationToken).ConfigureAwait(false);

            if (policyResult.Outcome == OutcomeType.Failure)
            {
                _logger.LogCritical(
                    policyResult.FinalException != null
                        ? $"Could not process item: {policyResult.FinalException.Message}."
                        : "An error has occured while processing the item.");
            }
        }
コード例 #4
0
ファイル: SaveObjManager.cs プロジェクト: DrDoak/GDS2
    public static PersistentItem RecreatePersistentItem(string path, Vector3 position, Quaternion rotation)
    {
        //Debug.Log ("re-instantiating object: " + path);
        GameObject prefab = Resources.Load <GameObject>(path);
        //Debug.Log (prefab);
        GameObject     go    = GameObject.Instantiate(prefab, position, rotation) as GameObject;
        PersistentItem actor = go.GetComponent <PersistentItem>() ?? go.AddComponent <PersistentItem>();

        actor.recreated = true;
        return(actor);
    }
コード例 #5
0
ファイル: SaveObjManager.cs プロジェクト: sdasd30/TSSG
    public static PersistentItem RecreatePersistentItem(CharData data, string path, Vector3 position, Quaternion rotation)
    {
        PersistentItem actor = null;

        if (data.targetID != null)
        {
            Vector3 nv    = data.pos;
            bool    found = false;
            foreach (SceneTrigger rm in sceneTriggers)
            {
                //Debug.Log ("COMPARE: " + rm.TriggerID + " : " + data.targetID);
                if (rm.name == data.targetID)
                {
                    if (data.targetDir == Direction.LEFT)
                    {
                        nv = rm.transform.position - new Vector3(rm.GetComponent <BoxCollider> ().size.x + 1f, 0f);
                    }
                    else if (data.targetDir == Direction.RIGHT)
                    {
                        nv = rm.transform.position + new Vector3(rm.GetComponent <BoxCollider> ().size.x + 1f, 0f);
                    }
                    else if (data.targetDir == Direction.UP)
                    {
                        nv = rm.transform.position + new Vector3(0f, rm.GetComponent <BoxCollider> ().size.z + 1f, 0f);
                    }
                    else if (data.targetDir == Direction.DOWN)
                    {
                        nv = rm.transform.position - new Vector3(0f, rm.GetComponent <BoxCollider> ().size.z + 1f, 0f);
                    }
                    nv   -= new Vector3(0f, rm.transform.localScale.y / 2f, 0f);
                    found = true;
                    break;
                }
            }
            if (found)
            {
                actor = RecreatePersistentItem(path, nv, rotation);
            }
            else
            {
                actor = RecreatePersistentItem(path, nv, rotation);
            }
        }
        else
        {
            actor = RecreatePersistentItem(path, data.pos, rotation);
        }
        actor.data = data;
        return(actor);
    }
コード例 #6
0
ファイル: SaveObjManager.cs プロジェクト: DrDoak/LittleDeity
    void m_moveItem(GameObject go, string newRoom, Vector3 newPos)
    {
        PersistentItem item = go.GetComponent <PersistentItem> ();

        item.StoreData();
        refreshPersItems();
        DelCharData(item.data);
        CharacterSaveContainer cc = LoadChars(savePath + newRoom);

//		item.pos = newPos;
        JsonUtility.ToJson(new CharacterSaveContainer());
        cc.actors.Add(item.data);
        Save(savePath + newRoom, cc);
        ResaveRoom();
    }
コード例 #7
0
ファイル: SaveObjManager.cs プロジェクト: sdasd30/TSSG
    public static PersistentItem RecreatePersistentItem(string path, Vector3 position, Quaternion rotation)
    {
        GameObject prefab = Resources.Load <GameObject>(path);

        if (prefab == null)
        {
            Debug.Log("ERROR: Could not re-instantiate object: " + path + " prefab not found");
            return(null);
        }
        //Debug.Log (prefab);
        GameObject     go    = GameObject.Instantiate(prefab, position, rotation) as GameObject;
        PersistentItem actor = go.GetComponent <PersistentItem>() ?? go.AddComponent <PersistentItem>();

        actor.recreated = true;
        return(actor);
    }
コード例 #8
0
ファイル: SaveObjManager.cs プロジェクト: DrDoak/LittleDeity
    void m_moveItem(GameObject go, string newRoom, string newID, RoomDirection newDir)
    {
        //Debug.Log ("Moving " + go.name + " to " + newRoom + " at position: " + newID + " direction: " + newDir);
        PersistentItem item = go.GetComponent <PersistentItem> ();

        //Remove the current data.
        item.StoreData();
        refreshPersItems();
        DelCharData(item.data);

        //load the list of things in the new room and add the current character to it
        CharacterSaveContainer cc = LoadChars(savePath + newRoom);

        item.data.targetID  = newID;
        item.data.targetDir = newDir;
        cc.actors.Add(item.data);
        //Debug.Log ("What is this anyways?: " + item.data.targetID + " : " + item.data.targetDir);
        Save(savePath + newRoom, cc);
        ResaveRoom();
        LoadChars(savePath + curRoom);
    }