private void OnNextArtClicked() { int i = artable.stages.FindIndex(s => s.id == artable.CurrentStage); Artable.Stage desiredStage = (i + 1 == artable.stages.Count) ? artable.stages[0] : artable.stages[i + 1]; artable.SetStage(desiredStage.id, false); }
/// <summary> /// Triggered when the user requests a resculpt of the decor item. /// </summary> private void OnResculpt() { Artable.Status currentStatus; if (artable != null && (currentStatus = artable.CurrentStatus) != Artable.Status. Ready) { var eligible = ListPool <Artable.Stage, Resculptable> .Allocate(); int currentIndex = 0; string stageID = artable.CurrentStage; try { // Populate with valid stages foreach (var stage in artable.stages) { if (stage.statusItem == currentStatus) { // Search for the current one if possible if (stage.id == stageID) { currentIndex = eligible.Count; } eligible.Add(stage); } } int n = eligible.Count; if (n > 1) { // Next entry artable.SetStage(eligible[(currentIndex + 1) % n].id, true); } } finally { eligible.Recycle(); } } }
/*private void OnCopySettings(object data) * { * throw new NotImplementedException("This one is not thrown..."); * PickableLook component = ((UnityEngine.GameObject)data).GetComponent<PickableLook>(); * if (!((UnityEngine.Object)component != (UnityEngine.Object)null)) * return; * this.artable.SetStage(component.artable.CurrentStage, false); * Debug.Log("SelectableArt: copied"); * }*/ private void OnNextArtClicked() { Artable.Status status = artable.stages.Find(s => s.id == artable.CurrentStage).statusItem; List <Artable.Stage> potential_stages = new List <Artable.Stage>(); foreach (Artable.Stage s in artable.stages) { if (s.statusItem == status) { potential_stages.Add(s); } } int i = potential_stages.FindIndex(s => s.id == artable.CurrentStage); Artable.Stage desiredStage = (i + 1 == potential_stages.Count) ? potential_stages[0] : potential_stages[i + 1]; artable.SetStage(desiredStage.id, false); }
/// <summary> /// Triggered when the user requests a resculpt of the decor item. /// </summary> private void OnResculpt() { Artable.Status currentStatus; if (artable != null && (currentStatus = artable.CurrentStatus) != Artable.Status. Ready) { var eligible = ListPool <Artable.Stage, Resculptable> .Allocate(); int currentIndex = 0; string stageID = artable.CurrentStage; try { // Populate with valid stages foreach (var stage in artable.stages) { if (stage.statusItem == currentStatus) { // Search for the current one if possible if (stage.id == stageID) { currentIndex = eligible.Count; } eligible.Add(stage); } } int n = eligible.Count; if (n > 1) { var attrs = this.GetAttributes().Get(Db.Get().BuildingAttributes.Decor); // Remove the decor bonus (SetStage adds it back) attrs.Modifiers.RemoveAll((modifier) => modifier.Description == "Art Quality"); // Next entry artable.SetStage(eligible[(currentIndex + 1) % n].id, true); } } finally { eligible.Recycle(); } } }