public AIBase(StandardMob obj) { attachedObject = obj; }
static void UpdateObjectInfo() { if (currentObject == null) { return; } if (currentObject is StandardMob s) { //isEntity = true; AIType.Visible = true; AIActive.Visible = true; currentMob = s; entityName.SetText(currentObject.GetType().Name); AIType.displayLabel.SetText(currentMob.mobAI.type.ToString()); AIActive.displayLabel.SetText(currentMob.mobAI.active.ToString()); } else { AIType.Visible = false; AIActive.Visible = false; entityName.SetText("Selected Object is not Entity"); } if (objectData != null) { List <UIButton> b = new List <UIButton>(); FieldInfo[] props = currentObject.GetType().GetFields().Where(prop => Attribute.IsDefined(prop, typeof(Editable))).ToArray(); foreach (FieldInfo f in props) { UITypeBox tb = new UITypeBox(0, 0, objectData.width1, objectData.height1, 2, 1, TextureManager.TextureNames.button); tb.text.SetText(f.Name + ":" + f.GetValue(currentObject).ToString()); tb.text.SetLayer(1); tb.valueAction = () => { string val = tb.text.GetText(); val = val.Substring(val.IndexOf(':') + 1); try { if (val.Length > 0) { if (f.FieldType.Equals(typeof(String))) { f.SetValue(currentObject, val); } else { f.SetValue(currentObject, int.Parse(val)); } currentObject.ModificationAction(); } } catch (FormatException) { System.Diagnostics.Debug.WriteLine("Invalid Format, could not update Value"); } }; b.Add(tb); } objectData.displaySize = (b.Count > 5) ? 5.5f : b.Count; objectData.SetDropdowns(b.ToArray()); objectName.SetText(currentObject.GetType().Name); objectData.showDrops = true; moveBut.Visible = true; } else { objectData.displayLabel.SetText("No Object Selected"); } }