Пример #1
0
        internal void OnAddedToBattle(EntityParam param)
        {
            SyncEventHelper.SpawnEntity(this.GetType().Name, param);
            this._rid  = param.rid;
            this._data = ModelFactory.GetEntityData(Utils.GetIDFromRID(this._rid));
            this.property.Init(this._data);
            this.property.Equal(Attr.Position, param.position);
            this.property.Equal(Attr.Direction, param.direction);
            this.size          = this._data.size * this.property.scale;
            this.bornPosition  = param.position;
            this.bornDirection = param.direction;
            AIData[] aiDatas = this._data.aiDatas;
            if (aiDatas != null)
            {
                int count = aiDatas.Length;
                for (int i = 0; i < count; i++)
                {
                    this.CreateAIEvaluator(aiDatas[i]);
                }
            }

            this.InternalOnAddedToBattle(param);

            SyncEventHelper.EntityAttrInitialized(this.rid);

            if (!string.IsNullOrEmpty(this._data.script))
            {
                this._script = new Script(this, this.battle.luaEnv, this._data.script);
                this._script.Call(Script.S_ON_ENTITY_ADDED_TO_BATTLE);
            }
        }