コード例 #1
0
ファイル: EntityMob.cs プロジェクト: StevilKnevil/Substrate
 public EntityMob(TypedEntity e)
     : base(e)
 {
     EntityMob e2 = e as EntityMob;
     if (e2 != null) {
         _attackTime = e2._attackTime;
         _deathTime = e2._deathTime;
         _health = e2._health;
         _hurtTime = e2._hurtTime;
         _activeEffects = e2._activeEffects;
     }
 }
コード例 #2
0
ファイル: EntityMob.cs プロジェクト: IAAA-Lab/EINA-TO-NBT
 protected EntityMob(string id)
     : base(id)
 {
     _activeEffects = new ActiveEffects();
 }
コード例 #3
0
ファイル: EntityMob.cs プロジェクト: StevilKnevil/Substrate
        public override TypedEntity LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;
            if (ctree == null || base.LoadTree(tree) == null) {
                return null;
            }

            _attackTime = ctree["AttackTime"].ToTagShort();
            _deathTime = ctree["DeathTime"].ToTagShort();
            _health = ctree["Health"].ToTagShort();
            _hurtTime = ctree["HurtTime"].ToTagShort();

            if (ctree.ContainsKey("ActiveEffects")) {
                TagNodeCompound ae = ctree["ActiveEffects"].ToTagCompound();

                _activeEffects = new ActiveEffects();
                _activeEffects.Id = ae["Id"].ToTagByte();
                _activeEffects.Amplifier = ae["Amplifier"].ToTagByte();
                _activeEffects.Duration = ae["Duration"].ToTagInt();
            }

            return this;
        }
コード例 #4
0
        public override TypedEntity LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null || base.LoadTree(tree) == null)
            {
                return(null);
            }

            _attackTime = ctree["AttackTime"].ToTagShort();
            _deathTime  = ctree["DeathTime"].ToTagShort();
            _health     = ctree["Health"].ToTagShort();
            _hurtTime   = ctree["HurtTime"].ToTagShort();
            if (ctree.ContainsKey("CanPickUpLoot"))
            {
                _canPickUpLoot = ctree["CanPickUpLoot"].ToTagByte();
            }
            if (ctree.ContainsKey("PersistenceRequired"))
            {
                _persistenceRequired = ctree["PersistenceRequired"].ToTagByte();
            }
            if (ctree.ContainsKey("CustomNameVisible"))
            {
                _customNameVisible = ctree["CustomNameVisible"].ToTagByte();
            }
            if (ctree.ContainsKey("CustomName"))
            {
                _customName = ctree["CustomName"].ToTagString();
            }


            if (ctree.ContainsKey("ActiveEffects"))
            {
                TagNodeList ae = ctree["ActiveEffects"].ToTagList();

                _activeEffects = new List <ActiveEffects>();
                foreach (TagNode tag in ae)
                {
                    TagNodeCompound effectTag = tag.ToTagCompound();
                    ActiveEffects   effect    = new ActiveEffects();
                    effect.Id        = effectTag["Id"].ToTagByte();
                    effect.Amplifier = effectTag["Amplifier"].ToTagByte();
                    effect.Duration  = effectTag["Duration"].ToTagInt();
                    effect.Ambient   = effectTag["Ambient"].ToTagByte() == 1;
                    _activeEffects.Add(effect);
                }
            }
            if (ctree.ContainsKey("Equipment"))
            {
                TagNodeList eq = ctree["Equipment"].ToTagList();

                for (int i = 0; i < 5 && i < eq.Count; i++)
                {
                    _equipment[i] = new Item().LoadTree(eq[i]);
                }
            }
            if (ctree.ContainsKey("DropChances"))
            {
                TagNodeList dc = ctree["DropChances"].ToTagList();

                for (int i = 0; i < 5 && i < dc.Count; i++)
                {
                    _dropChances[i] = dc[i].ToTagFloat();
                }
            }

            return(this);
        }