//public override bool OnEffect(string effectType, object t, object p, float duration, UUID id) //{ // bool noteable = LogEvent(new SimObjectEvent(effectType, SimEventType.EFFECT, SimEventStatus.Once, this, t, p, duration, id)); // //todo // if (noteable) WorldSystem.SendNewEvent("on-effect", effectType, this, t, p, duration, id); // return noteable; // //throw new NotImplementedException(); //} public override bool LogEvent(CogbotEvent SE) { string typeUse = SE.Verb; object[] args1_N = SE.GetArgs(); // does this backwards to the first argument is the most reliavant object for (int i = args1_N.Length - 1; i >= 0; i--) { object o = args1_N[i]; if (o == this) { continue; //skip self } if (o is SimObject) { KnownSimObjects.Add((SimObject)o); } } _knownTypeUsages.AddTo(SimTypeSystem.CreateTypeUsage(typeUse)); bool noteable = base.LogEvent(SE); if (noteable) //if (theAvatar.Name.Contains("rael")) { //DLRConsole.DebugWriteLine(SE); } return(noteable); }
public SimTypeUsage OverrideProperties(SimTypeUsage use) { SimTypeUsage newUse = this; foreach (string prop in use.SpecifiedProperties) { newUse.SpecifiedProperties.Add(prop); System.Reflection.FieldInfo fi = newUse.GetType().GetField(prop); if (fi.FieldType == typeof(BotNeeds)) { continue; } SimTypeSystem.SetValue(fi, newUse, fi.GetValue(use)); } //if (use.SpecifiedProperties.Contains("TextName")) // newUse.TextName = use.TextName; //if (use.SpecifiedProperties.Contains("UseGrab")) // newUse.UseGrab = use.UseGrab; //if (use.SpecifiedProperties.Contains("UseSit")) // newUse.UseSit = use.UseSit; //if (use.SpecifiedProperties.Contains("LispScript")) // newUse.LispScript = use.LispScript; //if (use.SpecifiedProperties.Contains("UseAnim")) // newUse.UseAnim = use.UseAnim; newUse.ChangeActual = newUse.ChangeActual.Copy(); newUse.ChangeActual.AddFrom(use.ChangeActual); newUse.ChangePromise = newUse.ChangePromise.Copy(); newUse.ChangePromise.AddFrom(use.ChangePromise); return(newUse); }
public SimAvatarImpl(UUID id, WorldObjects objectSystem, Simulator sim) : base(id, objectSystem, sim) { Affordances.ObjectType.SuperType.Add(SimTypeSystem.GetObjectType("Avatar")); _knownTypeUsages = new ListAsSet <SimTypeUsage>(); WorldSystem.AddAvatar(this, id); }
public SimAvatarClient(UUID id, WorldObjects objectSystem, Simulator reg) : base(id, objectSystem, reg) { SingleInstance = this; Affordances.ObjectType.SuperType.Add(SimTypeSystem.GetObjectType("PlayerAvatar")); //try //{ // AspectName = slAvatar.Name; //} //catch (Exception) //{ // AspectName += objectSystem.client + "_Avatar_" + slAvatar.LocalID; //} //MakeEnterable(this); WorldSystem.AddAvatar(this, id); }
public override bool Matches(string name) { String n = GetName(); if (string.IsNullOrEmpty(n)) { return(string.IsNullOrEmpty(name)); } if (string.IsNullOrEmpty(name)) { return(false); } if (n.ToLower().Replace("_", " ").Trim() == (name.ToLower().Replace("_", " ").Trim())) { return(true); } return(SimTypeSystem.MatchString(base.ToString(), name) || SimTypeSystem.MatchString(ToString(), name)); }
static List <SimObjectType> DoGuessWork(Primitive.ObjectProperties props, SimObject obj, List <SimObjectType> possibles) { { { List <SimObjectType> objectTypesLocally = new List <SimObjectType>(); lock (SimTypeSystem.objectTypes) objectTypesLocally.AddRange(SimTypeSystem.objectTypes); foreach (SimObjectType otype in objectTypesLocally) { foreach (Regex smatch in otype.NoMatch) { // NoMatch if (smatch.IsMatch(props.Name.ToLower()) && smatch.IsMatch(props.Description.ToLower())) { goto nextOType; } } foreach (Object smatch in otype.CodeMatch) { // CodeMatch if (IsCodeMatch(obj, smatch)) { if (!possibles.Contains(otype)) { possibles.Add(otype); goto nextOType; } } else { possibles.Remove(otype); } } foreach (Regex smatch in otype.Match) { // Match if (smatch.IsMatch(props.Name.ToLower()) && smatch.IsMatch(props.Description.ToLower())) { if (!possibles.Contains(otype)) { possibles.Add(otype); SetNames(props, otype); } break; } } nextOType: { } } if (!String.IsNullOrEmpty(props.TouchName)) { string verb = props.TouchName; possibles.Add(SimTypeSystem.CreateObjectUse(verb, new object[] { "UseGrab", true , "TextName", verb })); } if (!String.IsNullOrEmpty(props.SitName)) { string verb = props.SitName; possibles.Add(SimTypeSystem.CreateObjectUse(verb, new object[] { "UseSit", true, "TextName", verb })); } return(possibles); } } }
public void ParseAffect(SimTypeUsage usage, object[] parseStr) { SimObjectType type = this; int i = 0; while (i < parseStr.Length) { if (parseStr[i] == null) { i++; continue; } string s = (string)parseStr[i++];//.ToString(); if (s == "SuperType") { String arg = parseStr[i++].ToString(); SimObjectType test = SimTypeSystem.FindObjectType(arg); if (test == null) { throw new Exception("unknown super type " + arg + " for " + type); } AddSuperType(test); //Not all types need to be by default usage types - was causing problems // use types are fined by "Verb" // usage = type.CreateObjectUsage(arg); continue; } //if (s == "Match") //{ // String arg = parseStr[i++].ToString(); // arg = SimTypeSystem.MakeRegExpression(arg); // type.Match.Add(new Regex(arg)); // continue; //} //if (s == "NoMatch") //{ // String arg = parseStr[i++].ToString(); // arg = SimTypeSystem.MakeRegExpression(arg); // type.NoMatch.Add(new Regex(arg)); // continue; //} if (s == "Verb") { String arg = parseStr[i++].ToString(); // TODO make sure creation order internalizes correctly SimObjectType superType = SimTypeSystem.CreateObjectUse(arg, new object[0]); AddSuperType(superType); usage = type.CreateObjectUsage(arg); continue; } // usage / distanceToExcite / etc FieldInfo fi = type.GetType().GetField(s); if (fi != null) { type.SpecifiedProperties.AddTo(fi.Name); SimTypeSystem.SetValue(fi, type, parseStr[i++]); continue; } fi = type.GetType().GetField(s + "s"); if (fi != null) { type.SpecifiedProperties.AddTo(fi.Name); SimTypeSystem.SetValue(fi, type, parseStr[i++]); continue; } if (usage == null) { if (type.IsUseType) { usage = type.CreateObjectUsage(type.GetTypeName()); } } fi = usage.GetType().GetField(s); if (fi != null) { usage.SpecifiedProperties.Add(fi.Name); SimTypeSystem.SetValue(fi, usage, parseStr[i++]); continue; } fi = usage.GetType().GetField(s + "s"); if (fi != null) { usage.SpecifiedProperties.Add(fi.Name); SimTypeSystem.SetValue(fi, usage, parseStr[i++]); continue; } // Hygiene / Hunger fi = typeof(BotNeeds).GetField(s); if (fi != null) { float ff = Single.Parse(parseStr[i++].ToString()); fi.SetValue(usage.ChangePromise, ff); ff = Single.Parse(parseStr[i++].ToString()); fi.SetValue(usage.ChangeActual, ff); continue; } DLRConsole.DebugWriteLine("ERROR: SimBots.ini-like dirrective unknown: '" + s + "'"); } }