Exemplo n.º 1
0
        /// <summary>
        /// Reset this Branch to the given Commit using the given ResetBehavior.
        /// <para/>
        /// Reset behavior:
        /// <u>
        /// <il>Mixed - Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.</il>
        /// <il>Soft - Does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files "Changes to be committed", as git status would put it.</il>
        /// <il>Hard - Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since the commit are lost.</il>
        /// <il>Merge - (NOT IMPLEMENTED) Resets the index to match the tree recorded by the named commit, and updates the files that are different between the named commit and the current commit in the working tree.</il>
        /// </u>
        /// </summary>
        public void Reset(Commit commit, ResetBehavior resetBehavior)
        {
            if (commit == null)
            {
                throw new ArgumentNullException("commit");
            }
            switch (resetBehavior)
            {
            case ResetBehavior.Hard:
                ResetHard(commit);
                break;

            case ResetBehavior.Soft:
                ResetSoft(commit);
                break;

            case ResetBehavior.Mixed:
                ResetMixed(commit);
                break;

            case ResetBehavior.Merge:
                throw new NotImplementedException();

            default:
                throw new NotSupportedException(string.Format("{0} is not supported.", resetBehavior));
            }
        }
Exemplo n.º 2
0
 public void RestartSimulation(EcosystemDescription description, ResetBehavior resetBehavior)
 {
     if (_restartCoroutine != null)
     {
         StopCoroutine(_restartCoroutine);
     }
     _restartCoroutine = StartCoroutine(restartCoroutine(description, resetBehavior));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Reset this Branch to the named Commit using the given ResetBehavior. <see cref="Reset(GitSharp.Commit,GitSharp.ResetBehavior)"/> for explanation of the reset behavior.
        /// </summary>
        public void Reset(string commitHash, ResetBehavior resetBehavior)
        {
            var commit = new Commit(_repo, commitHash);

            if (!commit.IsCommit)
            {
                throw new ArgumentException(string.Format("The provided hash ({0}) does not point to a commit.", commitHash));
            }
            Reset(commit, resetBehavior);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reset this Branch to the current Commit using the given ResetBehavior. <see cref="Reset(GitSharp.Commit,GitSharp.ResetBehavior)"/> for explanation of the reset behavior.
        /// </summary>
        public void Reset(ResetBehavior resetBehavior)
        {
            if (this.CurrentCommit == null)
            {
                throw new InvalidOperationException(string.Format("Branch '{0}' has no commit.", Name));
            }
            var commit = this.CurrentCommit;

            Reset(commit, resetBehavior);
        }
Exemplo n.º 5
0
    /// <summary>
    /// Restarts the simulation using a specific preset to choose the
    /// initial conditions.
    /// </summary>
    public void RestartSimulation(EcosystemPreset preset,
                                  ResetBehavior resetBehavior = ResetBehavior.FadeInOut)
    {
        var presetDesc = _generator.GetPresetEcosystem(preset);

        RestartSimulation(presetDesc, resetBehavior);

        if (OnPresetLoaded != null)
        {
            OnPresetLoaded();
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Restarts the simulation to whatever state it was in when it was
 /// most recently restarted.
 /// </summary>
 public void RestartSimulation(ResetBehavior resetBehavior = ResetBehavior.SmoothTransition)
 {
     //If we had generated a random simulation, re-generate it so that new settings
     //can take effect.  We assume the name of the description is it's seed!
     if (_currentDescription.isRandomDescription)
     {
         RandomizeSimulation(_currentDescription.name, resetBehavior);
     }
     else
     {
         RestartSimulation(_currentDescription, resetBehavior);
     }
 }
Exemplo n.º 7
0
    private void restartSimulator(SimulationMethod method,
                                  EcosystemDescription ecosystemDescription,
                                  ResetBehavior resetBehavior)
    {
        switch (method)
        {
        case SimulationMethod.InteractionEngine:
            _ieSimulator.RestartSimulation(ecosystemDescription, resetBehavior);
            break;

        case SimulationMethod.Texture:
            _textureSimulator.RestartSimulation(ecosystemDescription, resetBehavior);
            break;

        default:
            throw new System.InvalidOperationException();
        }
    }
Exemplo n.º 8
0
    public void RestartSimulation(EcosystemDescription ecosystemDescription,
                                  ResetBehavior resetBehavior)
    {
        var oldMethod = _currentSimulationMethod;
        var newMethod = _simulationMethod;

        _currentSimulationMethod = newMethod;

        isPerformingTransition = true;
        if (OnEcosystemBeginTransition != null)
        {
            OnEcosystemBeginTransition();
        }

        if (oldMethod != newMethod)
        {
            restartSimulator(oldMethod, EcosystemDescription.empty, resetBehavior);
            restartSimulator(newMethod, ecosystemDescription, resetBehavior);
        }
        else
        {
            restartSimulator(_currentSimulationMethod, ecosystemDescription, resetBehavior);
        }
    }
Exemplo n.º 9
0
		/// <summary>
		/// Reset this Branch to the current Commit using the given ResetBehavior. <see cref="Reset(GitSharp.Commit,GitSharp.ResetBehavior)"/> for explanation of the reset behavior.
		/// </summary>
		public void Reset(ResetBehavior resetBehavior)
		{
			if (this.CurrentCommit == null)
				throw new InvalidOperationException(string.Format("Branch '{0}' has no commit.", Name));
			var commit = this.CurrentCommit;
			Reset(commit, resetBehavior);
		}
Exemplo n.º 10
0
 public void Reset(string commitHash, ResetBehavior resetBehavior)
 {
     Commit commit = ResolveCommit(commitHash);
     Reset(commit, resetBehavior);
 }
Exemplo n.º 11
0
 public void Reset(ResetBehavior resetBehavior)
 {
     Commit commit = GetSafeCurrentCommit();
     Reset(commit, resetBehavior);
 }
Exemplo n.º 12
0
        public void Reset(string commitHash, ResetBehavior resetBehavior)
        {
            Commit commit = ResolveCommit(commitHash);

            Reset(commit, resetBehavior);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Restarts the simulation using a random description.
 /// </summary>
 public void RandomizeSimulation(ResetBehavior resetBehavior)
 {
     RestartSimulation(_generator.GetRandomEcosystem(), resetBehavior);
 }
Exemplo n.º 14
0
    public void ApplySliderValues(ref EcosystemDescription currentDescription, out ResetBehavior requiredReset)
    {
        requiredReset = ResetBehavior.None;
        if (particleCount != currentDescription.toSpawn.Count)
        {
            requiredReset = ResetBehavior.SmoothTransition;
        }
        if (speciesCount != currentDescription.toSpawn.Query().CountUnique(t => t.species))
        {
            requiredReset = ResetBehavior.SmoothTransition;
        }

        if (currentDescription.isRandomDescription)
        {
            currentDescription = GetRandomEcosystem(currentDescription.name);
        }
        else
        {
            var preset = (EcosystemPreset)System.Enum.Parse(typeof(EcosystemPreset), currentDescription.name);
            currentDescription = GetPresetEcosystem(preset, updateSliders: false);

            float maxForce = float.Epsilon;
            float maxRange = float.Epsilon;
            int   maxSteps = 0;
            float maxDrag  = float.Epsilon;
            for (int i = 0; i < currentDescription.speciesData.Length; i++)
            {
                for (int j = 0; j < currentDescription.speciesData.Length; j++)
                {
                    maxForce = Mathf.Max(maxForce, currentDescription.socialData[i, j].socialForce);
                    maxRange = Mathf.Max(maxRange, currentDescription.socialData[i, j].socialRange);
                }
                maxSteps = Mathf.Max(maxSteps, currentDescription.speciesData[i].forceSteps);
                maxDrag  = Mathf.Max(maxDrag, currentDescription.speciesData[i].drag);
            }

            float forceFactor = maxSocialForce / maxForce;
            float rangeFactor = maxSocialRange / maxRange;
            float dragFactor  = dragCenter / maxDrag;

            for (int i = 0; i < currentDescription.speciesData.Length; i++)
            {
                for (int j = 0; j < currentDescription.speciesData.Length; j++)
                {
                    currentDescription.socialData[i, j].socialForce *= forceFactor;
                    currentDescription.socialData[i, j].socialRange *= rangeFactor;
                }

                float percent;
                if (maxSteps == 0)
                {
                    percent = 1;
                }
                else
                {
                    percent = Mathf.InverseLerp(0, maxSteps, currentDescription.speciesData[i].forceSteps);
                }

                int result = Mathf.FloorToInt(Mathf.Lerp(0, maxForceSteps - 1, percent));
                currentDescription.speciesData[i].forceSteps = result;
                currentDescription.speciesData[i].drag      *= dragFactor;
            }
        }
    }
Exemplo n.º 15
0
		/// <summary>
		/// Reset this Branch to the named Commit using the given ResetBehavior. <see cref="Reset(GitSharp.Commit,GitSharp.ResetBehavior)"/> for explanation of the reset behavior.
		/// </summary>
		public void Reset(string commitHash, ResetBehavior resetBehavior)
		{
			var commit = new Commit(_repo, commitHash);
			if (!commit.IsCommit)
				throw new ArgumentException(string.Format("The provided hash ({0}) does not point to a commit.", commitHash));
			Reset(commit, resetBehavior);
		}
Exemplo n.º 16
0
 /// <summary>
 /// Loads a random simulation based on the given string seed.
 /// </summary>
 public void LoadSimulationWithSeed(string seed, ResetBehavior resetBehavior)
 {
     RestartSimulation(_generator.GetRandomEcosystem(seed), resetBehavior);
 }
Exemplo n.º 17
0
		/// <summary>
		/// Reset this Branch to the given Commit using the given ResetBehavior.
		/// <para/>
		/// Reset behavior:
		/// <u>
		/// <il>Mixed - Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.</il>
		/// <il>Soft - Does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files "Changes to be committed", as git status would put it.</il>
		/// <il>Hard - Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since the commit are lost.</il>
		/// <il>Merge - (NOT IMPLEMENTED) Resets the index to match the tree recorded by the named commit, and updates the files that are different between the named commit and the current commit in the working tree.</il>
		/// </u>
		/// </summary>
		public void Reset(Commit commit, ResetBehavior resetBehavior)
		{
			if (commit == null)
				throw new ArgumentNullException("commit");
			switch (resetBehavior)
			{
				case ResetBehavior.Hard:
					ResetHard(commit);
					break;
				case ResetBehavior.Soft:
					ResetSoft(commit);
					break;
				case ResetBehavior.Mixed:
					ResetMixed(commit);
					break;
				case ResetBehavior.Merge:
					throw new NotImplementedException();
				default:
					throw new NotSupportedException(string.Format("{0} is not supported.", resetBehavior));
			}
		}
Exemplo n.º 18
0
 /// <summary>
 /// Restarts the simulation using a random description calculated using
 /// the seed value.  The same seed value should always result in the same
 /// simulation description.
 /// </summary>
 public void RandomizeSimulation(string seed,
                                 ResetBehavior resetBehavior)
 {
     RestartSimulation(_generator.GetRandomEcosystem(seed), resetBehavior);
 }
Exemplo n.º 19
0
    private IEnumerator restartCoroutine(EcosystemDescription description, ResetBehavior resetBehavior)
    {
        if (resetBehavior == ResetBehavior.SmoothTransition || resetBehavior == ResetBehavior.FadeInOut)
        {
            yield return(new WaitForSeconds(_manager.resetTime / 2));
        }

        //TODO: remove this and implement everything else
        resetBehavior = ResetBehavior.ResetPositions;

        switch (resetBehavior)
        {
        case ResetBehavior.None:
            //If no transition, all we need to do is update the colors
            foreach (var particle in _particles.Query().Take(MAX_PARTICLES))
            {
                _block.SetColor("_Color", description.speciesData[particle.species].color);
                particle.GetComponent <Renderer>().SetPropertyBlock(_block);
            }
            _manager.NotifyMidTransition(SimulationMethod.InteractionEngine);
            break;

        case ResetBehavior.FadeInOut:
        case ResetBehavior.SmoothTransition:
        case ResetBehavior.ResetPositions:
            foreach (var obj in _particles)
            {
                DestroyImmediate(obj.gameObject);
            }
            _particles.Clear();

            foreach (var obj in description.toSpawn.Query().Take(MAX_PARTICLES))
            {
                GameObject particle = Instantiate(_particlePrefab);
                particle.transform.SetParent(transform);
                particle.transform.localPosition = obj.position;
                particle.transform.localRotation = Quaternion.identity;
                particle.transform.localScale    = Vector3.one * _manager.particleRadius;

                particle.GetComponent <MeshFilter>().sharedMesh = _manager.particleMesh;

                particle.GetComponent <Renderer>().sharedMaterial = _displayMat;
                _block.SetColor("_Color", description.speciesData[obj.species].color);
                particle.GetComponent <Renderer>().SetPropertyBlock(_block);

                particle.GetComponent <Rigidbody>().velocity = obj.velocity;
                particle.GetComponent <IEParticle>().species = obj.species;

                particle.SetActive(true);
                _particles.Add(particle.GetComponent <IEParticle>());
            }

            TransformBy(_manager.displayAnchor.localToWorldMatrix);
            _prevDisplayPosition = _manager.displayAnchor.position;
            _prevDisplayRotation = _manager.displayAnchor.rotation;
            _prevDisplayScale    = _manager.displayAnchor.localScale;
            _prevParticleSize    = _manager.particleRadius;

            _manager.NotifyMidTransition(SimulationMethod.InteractionEngine);
            break;

        default:
            throw new System.NotImplementedException();
        }

        currentDescription = description;
        _manager.NotifyEndedTransition(SimulationMethod.InteractionEngine);
        _restartCoroutine = null;
    }
Exemplo n.º 20
0
        public void Reset(ResetBehavior resetBehavior)
        {
            Commit commit = GetSafeCurrentCommit();

            Reset(commit, resetBehavior);
        }