コード例 #1
0
        internal static SimObjectType CreateInstanceType(string name)
        {
            SimObjectType type = new SimObjectType(name)
            {
                IsInstanceType = true
            };

            return(type);
        }
コード例 #2
0
        static public SimObjectType GetObjectType(string name)
        {
            SimObjectType type = FindObjectType(name);

            if (type == null)
            {
                type = new SimObjectType(name);
                lock (objectTypes) objectTypes.Add(type);
            }
            return(type);
        }
コード例 #3
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
 public SimObjectType IsSubType(SimObjectType superType)
 {
     if (superType == this) return this;
     lock (SuperType) foreach (SimObjectType st in SuperType)
     {
         if (st == superType) return st;
         if (st.SuperType.Contains(superType)) return st;
         SimObjectType found = st.IsSubType(superType);
         if (found != null) return found;
     }
     return null;
 }
コード例 #4
0
 public bool AddSuperType(SimObjectType test)
 {
     lock (SuperType)
     {
         if (SuperType.Contains(test))
         {
             return(false);
         }
         SuperType.Add(test);
         return(true);
     }
 }
コード例 #5
0
        static public SimObjectType SetSimType(string aspectName, Cons cons)
        {
            object[]      parseStr = ConsParams(cons);
            SimObjectType type     = GetObjectType(aspectName);
            SimTypeUsage  usage    = null;

            if (type.IsUseType)
            {
                usage = type.CreateObjectUsage(aspectName);
            }
            type.ParseAffect(usage, parseStr);
            return(type);
        }
コード例 #6
0
        static public SimTypeUsage CreateTypeUsage(string classname, params object[] parseStr)
        {
            if (parseStr.Length == 1 && parseStr[0] is object[])
            {
                parseStr = (object[])parseStr[0];
            }
            SimObjectType type = GetObjectType(classname);

            type.AddSuperType(USEABLE);
            type.IsUseType = true;
            SimTypeUsage usage = type.CreateObjectUsage(classname);

            type.ParseAffect(usage, parseStr);
            return(usage);
        }
コード例 #7
0
        static public SimObjectType CreateObjectType(string aspectName, params object[] parseStr)
        {
            if (parseStr.Length == 1 && parseStr[0] is object[])
            {
                parseStr = (object[])parseStr[0];
            }
            SimObjectType type1 = FindObjectType(aspectName);

            if (type1 == null)
            {
                type1 = new SimObjectType(aspectName);
                type1.ParseAffect(null, new object[] { "Match", "* " + aspectName + " *" });
                lock (objectTypes) objectTypes.Add(type1);
            }
            type1.ParseAffect(null, parseStr);
            return(type1);
        }
コード例 #8
0
        public string GetSitName()
        {
            if (!String.IsNullOrEmpty(SitName))
            {
                return(SitName);
            }
            List <SimObjectType> list = new List <SimObjectType>();

            AddAllTypes(list);
            list.Remove(this);
            SimObjectType pt = list.Find(delegate(SimObjectType sc)
            {
                String tn = sc.SitName;
                return(!String.IsNullOrEmpty(tn));
            });

            return(pt == null ? SitName : pt.SitName);
        }
コード例 #9
0
        public static void LoadConfig(string filename)
        {
            System.IO.FileStream f = System.IO.File.OpenRead(filename);
            StreamReader         r = new StreamReader(f);

            r.BaseStream.Seek(0, SeekOrigin.Begin);
            TextReader  tr     = r;
            Interpreter interp = ScriptInterpreterParent.Impl as Interpreter;

            while (tr.Peek() != -1)
            {
                Object read = interp.Read(filename, tr);
                if (interp.Eof(read))
                {
                    return;
                }
                Cons          cons = (Cons)read;
                SimObjectType type = LoadConfigCons(cons);
                type.cons = cons;
            }
        }
コード例 #10
0
        public SimObject FindSimObject(SimObjectType pUse, double maxXYDistance, double maxZDist)
        {
            double            myZ     = GlobalPosition.Z;
            IList <SimObject> objects = GetKnownObjects();

            lock (objects) foreach (SimObject O in objects)
                {
                    if (O.Distance(this) > maxXYDistance)
                    {
                        continue;
                    }
                    if (Math.Abs(O.GlobalPosition.Z - myZ) > maxZDist)
                    {
                        continue;
                    }
                    if (O.Affordances.IsTypeOf(pUse) != null)
                    {
                        return(O);
                    }
                }
            return(null);
        }
コード例 #11
0
        //static public string GetPrimTypeName(Primitive target)
        //{
        //    if (target.PrimData.PCode == PCode.Prim)
        //        return target.PrimData.Type.ToString();
        //    return target.PrimData.PCode.ToString();
        //}

        static private void SetNames(Primitive.ObjectProperties props, SimObjectType otype)
        {
            //= prim.Properties;
            if (props != null)
            {
                //      Primitive prim = null;
                if (String.IsNullOrEmpty(props.SitName))
                {
                    props.SitName = otype.GetSitName();
                    if (!String.IsNullOrEmpty(props.SitName))
                    {
                        // DLRConsole.WriteLine("[TODO] SetSitName(" + prim + "," + otype.GetSitName());
                    }
                }
                if (String.IsNullOrEmpty(props.TouchName))
                {
                    props.TouchName = otype.GetTouchName();
                    if (!String.IsNullOrEmpty(props.TouchName))
                    {
                        //  DLRConsole.WriteLine("[TODO] SetTextName(" + prim + "," + otype.GetTouchName());
                    }
                }
            }
        }
コード例 #12
0
 public SimObjectType IsSubType(SimObjectType superType)
 {
     if (superType == this)
     {
         return(this);
     }
     lock (SuperType) foreach (SimObjectType st in SuperType)
         {
             if (st == superType)
             {
                 return(st);
             }
             if (st.SuperType.Contains(superType))
             {
                 return(st);
             }
             SimObjectType found = st.IsSubType(superType);
             if (found != null)
             {
                 return(found);
             }
         }
     return(null);
 }
コード例 #13
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
 internal static SimObjectType CreateInstanceType(string name)
 {
     SimObjectType type = new SimObjectType(name) {IsInstanceType = true};
     return type;
 }
コード例 #14
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
 static public SimObjectType CreateObjectType(string aspectName, params object[] parseStr)
 {
     if (parseStr.Length == 1 && parseStr[0] is object[]) parseStr = (object[])parseStr[0];
     SimObjectType type1 = FindObjectType(aspectName);
     if (type1 == null)
     {
         type1 = new SimObjectType(aspectName);
         type1.ParseAffect(null, new object[] { "Match", "* " + aspectName + " *" });
         lock (objectTypes) objectTypes.Add(type1);
     }
     type1.ParseAffect(null, parseStr);
     return type1;
 }
コード例 #15
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
 static public SimObjectType GetObjectType(string name)
 {
     SimObjectType type = FindObjectType(name);
     if (type == null)
     {
         type = new SimObjectType(name);
         lock (objectTypes) objectTypes.Add(type);
     }
     return type;
 }
コード例 #16
0
        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 + "'");
            }
        }
コード例 #17
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
        //static public string GetPrimTypeName(Primitive target)
        //{
        //    if (target.PrimData.PCode == PCode.Prim)
        //        return target.PrimData.Type.ToString();
        //    return target.PrimData.PCode.ToString();
        //}

        static private void SetNames(Primitive.ObjectProperties props, SimObjectType otype)
        {
            //= prim.Properties;
            if (props != null)
            {
                //      Primitive prim = null;
                if (String.IsNullOrEmpty(props.SitName))
                {
                    props.SitName = otype.GetSitName();
                    if (!String.IsNullOrEmpty(props.SitName))
                    {
                        // DLRConsole.WriteLine("[TODO] SetSitName(" + prim + "," + otype.GetSitName());
                    }
                }
                if (String.IsNullOrEmpty(props.TouchName))
                {
                    props.TouchName = otype.GetTouchName();
                    if (!String.IsNullOrEmpty(props.TouchName))
                    {
                        //  DLRConsole.WriteLine("[TODO] SetTextName(" + prim + "," + otype.GetTouchName());
                    }
                }
            }
        }
コード例 #18
0
ファイル: SimAvatar.cs プロジェクト: drzo/opensim4opencog
 public SimObject FindSimObject(SimObjectType pUse, double maxXYDistance, double maxZDist)
 {
     double myZ = GlobalPosition.Z;
     IList<SimObject> objects = GetKnownObjects();
     lock (objects) foreach (SimObject O in objects)
         {
             if (O.Distance(this) > maxXYDistance) continue;
             if (Math.Abs(O.GlobalPosition.Z - myZ) > maxZDist) continue;
             if (O.Affordances.IsTypeOf(pUse) != null) return O;
         }
     return null;
 }
コード例 #19
0
ファイル: SimTypeSystem.cs プロジェクト: drzo/opensim4opencog
 public bool AddSuperType(SimObjectType test)
 {
     lock (SuperType)
     {
         if (SuperType.Contains(test)) return false;
         SuperType.Add(test);
         return true;
     }
 }