Beispiel #1
0
 protected virtual void OnDeleteSubscribedToDeletionEvent(Entity entity)
 {
     if (entity == this.logicClass)
     {
         this.logicClass = null;
     }
     if (this.extendedProperties != null)
     {
         this.extendedProperties.OnDeleteSubscribedToDeletionEvent(entity);
     }
 }
Beispiel #2
0
 protected internal override void OnRemoveChild(Entity entity)
 {
     if (this.aBT != null)
     {
         LogicClass logicClass = entity as LogicClass;
         if (logicClass != null)
         {
             this.aBT.Remove(logicClass.ClassName);
         }
     }
     base.OnRemoveChild(entity);
 }
Beispiel #3
0
 private void A()
 {
     if (this.aBT == null)
     {
         this.aBT = new Dictionary <string, LogicClass>();
         foreach (Entity current in base.Children)
         {
             LogicClass logicClass = current as LogicClass;
             if (logicClass != null)
             {
                 this.aBT.Add(logicClass.ClassName, logicClass);
             }
         }
     }
 }
Beispiel #4
0
        public LogicClass CreateStaticClass(string className)
        {
            this.A();
            LogicClass logicClass = this.GetByName(className);

            if (logicClass != null)
            {
                Log.Fatal("LogicClassManager: already create class \"{0}\"", className);
                return(null);
            }
            logicClass           = (LogicClass)Entities.Instance.Create(EntityTypes.Instance.GetByName("LogicClass"), this);
            logicClass.ClassName = className;
            logicClass.PostCreate();
            this.aBT.Add(className, logicClass);
            return(logicClass);
        }
Beispiel #5
0
        protected virtual bool OnLoad(TextBlock block)
        {
            if (block.IsAttributeExist("logicClass"))
            {
                this.logicClass = (Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(block.GetAttribute("logicClass"))) as LogicClass);
            }
            if (this.logicObject == null && this.logicClass != null)
            {
                this.CreateLogicObject();
                TextBlock textBlock = block.FindChild("logicObject");
                if (textBlock != null && !this.logicObject.A(textBlock))
                {
                    return(false);
                }
            }
            string text = this.Type.Name;

            if (this.name != "")
            {
                text += string.Format(" ({0})", this.name);
            }
            text = string.Format("Entity: \"{0}\"", text);
            for (EntityTypes.ClassInfo classInfo = this.Type.ClassInfo; classInfo != null; classInfo = classInfo.BaseClassInfo)
            {
                foreach (EntityTypes.ClassInfo.EntitySerializableFieldItem current in classInfo.EntitySerializableFields)
                {
                    if (/*EntitySystemWorld.Instance.isEntitySerializable(current.SupportedSerializationTypes) &&*/ !EntityHelper.LoadFieldValue(true, this, current.Field, block, text))
                    {
                        return(false);
                    }
                }
            }
            string text2 = null;

            if (block.IsAttributeExist("subscriptionsToDeletionEvent"))
            {
                text2 = block.GetAttribute("subscriptionsToDeletionEvent");
            }
            else if (block.IsAttributeExist("relationships"))
            {
                text2 = block.GetAttribute("relationships");
            }
            else if (block.IsAttributeExist("relations"))
            {
                text2 = block.GetAttribute("relations");
            }
            if (text2 != null)
            {
                string[] array = text2.Split(new char[]
                {
                    ' '
                }, StringSplitOptions.RemoveEmptyEntries);
                this.subscriptionsToDeletionEvent = new List <Entity>(Math.Max(array.Length, 4));
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string s = array2[i];
                    Entity loadingEntityBySerializedUIN = Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(s));
                    if (loadingEntityBySerializedUIN != null)
                    {
                        this.subscriptionsToDeletionEvent.Add(loadingEntityBySerializedUIN);
                    }
                }
            }
            TextBlock textBlock2 = block.FindChild("extendedProperties");

            if (textBlock2 != null)
            {
                string typeClass = textBlock2.GetAttribute("class");
                Type   type      = EntitySystemWorld.Instance.FindEntityClassType(typeClass);
                if (type == null)
                {
                    Log.Error("Extended properties class \"{0}\" not exists.", typeClass);
                    return(false);
                }
                this.CreateExtendedProperties(type);
                if (!this.extendedProperties.OnLoad(textBlock2))
                {
                    return(false);
                }
            }
            if (block.IsAttributeExist("textUserData"))
            {
                string attribute2 = block.GetAttribute("textUserData");
                if (!string.IsNullOrEmpty(attribute2))
                {
                    this.SetTag("TextUserData", attribute2);
                }
            }
            return(true);
        }