示例#1
0
        public bool Rem(Entity ent, bool recursive = true)
        {
            Contained con = ent.Get <Contained>();

            if (con == null || !con.ContainedBy(this.ent))
            {
                return(false);
            }
            if (items.Contains(ent.Key))
            {
                items.Remove(ent.Key);
                con.container = 0;
                return(true);
            }
            if (!recursive)
            {
                return(false);
            }
            foreach (uint key in items)
            {
                Entity    i  = this.ent.Pool[key];
                Container er = i.Get <Container>();
                if (er == null)
                {
                    continue;
                }
                if (er.Rem(ent))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        public bool ContainedBy(Entity ent)
        {
            Container er = ent.Get <Container>();

            if (er == null)
            {
                return(false);
            }
            if (!er.Contains(this.ent))
            {
                Contained ed = ent.Get <Contained>();
                return(ed != null && ed.ContainedBy(ent));
            }
            return(true);
        }
示例#3
0
        public bool Add(Entity ent)
        {
            Contained con = ent.Get <Contained>();

            if (con == null)
            {
                con = new Contained();
                ent.Add(con);
            }
            else if (con.container != 0)
            {
                return(false);
            }
            if (con.size != 0)
            {
                throw new NotImplementedException();
            }
            con.container = this.ent.Key;
            items.Add(ent.Key);
            return(true);
        }