Exemplo n.º 1
0
        internal static string GetClassName(Edict *entity)
        {
            // TODO: consider returning empty string?
            if (entity->v.classname == 0)
            {
                return(null);
            }

            IntPtr ptr = MetaModEngine.engineFunctions.SzFromIndex(entity->v.classname);

            return(Mono.Unix.UnixMarshal.PtrToString(ptr));
        }
Exemplo n.º 2
0
        public static IEnumerable <Entity> Find(string field, string val)
        {
            Entity first = Find(null, field, val);

            if (first == null)
            {
                yield break;
            }
            else
            {
                yield return(first);
            }

            Entity entity = first;

            while ((entity = Find(entity, field, val)).Pointer != first.Pointer)
            {
                yield return(entity);
            }
        }
Exemplo n.º 3
0
        public static Entity CreateEntity(IntPtr entityPointer)
        {
            if (entityPointer == IntPtr.Zero)
            {
                return(null);
            }

            int index = Entity.GetIndex(entityPointer);

            if (entityDictionary.ContainsKey(index))
            {
                return(entityDictionary[index]);
            }
            else
            {
                Edict *edict = (Edict *)entityPointer.ToPointer();
                // TODO: 1 and maxplayer can be bot or player
                if (index >= 1 && index <= Server.MaxPlayers)
                {
                    return(RegisterEntity(index, new Player(entityPointer)));
                }

                string classname = GetClassName(edict);

                if (classname.StartsWith("weapon_"))
                {
                    return(RegisterEntity(index, new CounterStrike.Weapon(edict)));
                }

                switch (classname)
                {
                case "player":
                    return(RegisterEntity(index, new Player(entityPointer)));

                default:
                    return(RegisterEntity(index, new Entity(entityPointer)));
                }
            }
        }
Exemplo n.º 4
0
 internal Entity(Edict *entity)
 {
     this.entity = entity;
     Pointer     = new IntPtr(entity);
 }
Exemplo n.º 5
0
        public static IEnumerable<Entity> Find(string field, string val)
        {
            Entity first = Find(null, field, val);

            if (first == null) {
                yield break;
            } else {
                yield return first;
            }

            Entity entity = first;

            while ((entity = Find(entity, field, val)).Pointer != first.Pointer) {
                yield return entity;
            }
        }
Exemplo n.º 6
0
 internal Entity(Edict *entity)
 {
     this.entity = entity;
     Pointer = new IntPtr(entity);
 }