Пример #1
0
        public bool AddEntity(YmapEntityDef ent, int roomIndex)
        {
            if (ent == null)
            {
                return(false);
            }

            // entity already exists in our array. so we'll just add
            // it to the instanced entities list and continue.
            MloInstanceData mloInstance = ent.MloParent?.MloInstance;
            MCEntityDef     ymcent      = mloInstance?.TryGetArchetypeEntity(ent);

            if (ymcent != null)
            {
                return(true);
            }

            if (roomIndex > rooms.Length)
            {
                throw new ArgumentOutOfRangeException($"Room index {roomIndex} exceeds the amount of rooms in {Name}.");
            }

            var mcEntityDef = new MCEntityDef(ref ent._CEntityDef, this);

            // Add the new entity def to the entities list.
            AddEntity(ent, mcEntityDef);

            // Update the attached objects in the room index specified.
            AttachEntityToRoom(ent, roomIndex);
            return(true);
        }