/// <summary> /// Open item after research. /// Could be changed by children /// Here: setting production as tools wherever it used /// </summary> public override void OpenItem() { foreach (var eff in m_effects) { var products = Productions.GetProductions(eff.Value.m_name); foreach (GameAbstractItem prod in products) { if (prod.m_isItOpen > 0) { GameMaterial mat = (GameMaterial)prod; bool hasItTheSame = false; foreach (var effect in mat.m_tools) { hasItTheSame |= (effect.m_toolLink.m_name == m_name && effect.m_name == eff.Value.m_name); } if (hasItTheSame) { continue; } else { ItemsEffect neff = new ItemsEffect(eff.Value); neff.m_production = mat; mat.m_tools.Add(neff); ArrowScript asc = ArrowScript.NewArrowScript(neff.m_toolLink.m_thisObject, mat.m_thisObject); asc.m_isItTool = true; mat.m_thisObject.m_toolsTo.Add(asc); m_thisObject.m_toolsFrom.Add(asc); } } } } base.OpenItem(); }
/// <summary> /// Open item after research. /// Here: getting tools for production /// Could be changed by children /// </summary> public override void OpenItem() { List <ItemsEffect> tools = new List <ItemsEffect>(); foreach (string prod in m_productionType) { foreach (ItemsEffect effect in Productions.GetTools(prod.Trim())) { tools.Add(effect); } } foreach (var tool in tools) { if (tool.m_toolLink.m_isItOpen > 0) { bool hasItThesame = false; foreach (var eff in m_tools) { hasItThesame |= eff.m_toolLink.m_name == tool.m_toolLink.m_name; } if (hasItThesame) { continue; } else { try { ItemsEffect neff = new ItemsEffect(tool); m_tools.Add(neff); ArrowScript asc = ArrowScript.NewArrowScript(neff.m_toolLink.m_thisObject, m_thisObject); asc.m_isItTool = true; m_thisObject.m_toolsTo.Add(asc); neff.m_toolLink.m_thisObject.m_toolsFrom.Add(asc); } catch (Exception ex) { Debug.LogError(ex.Message); } } } } for (int i = 0; i < 10; i++) { m_productQueue.Enqueue(0); } base.OpenItem(); }