Пример #1
0
 protected override void Cleanup()
 {
     if (file_handle != IntPtr.Zero)
     {
         G_INTERNAL.FS_Close(file_handle);
     }
     file_handle = IntPtr.Zero;
 }
Пример #2
0
 internal Entity(IntPtr ent_ptr) : base(false)
 {
     handle = ent_ptr;
     if (G_INTERNAL.G_IsPlayer(handle))
     {
         player = new Player(this);
     }
     if (G_INTERNAL.G_IsNPC(handle))
     {
         npc = new NPC(this);
     }
 }
Пример #3
0
            public int Write(byte[] data)
            {
                if (openMode != OpenMode.WRITE)
                {
                    throw new SVException("write operation not allowed");
                }
                IntPtr data_ptr = Marshal.AllocHGlobal(data.Length);

                Marshal.Copy(data, 0, data_ptr, data.Length);
                int len = G_INTERNAL.FS_Write(file_handle, data_ptr, data.Length);

                Marshal.FreeHGlobal(data_ptr);
                return(len);
            }
Пример #4
0
            public byte[] Read(int len)
            {
                if (openMode != OpenMode.READ)
                {
                    throw new SVException("read operation not allowed");
                }
                IntPtr data_ptr = Marshal.AllocHGlobal(len);
                int    alen     = G_INTERNAL.FS_Read(file_handle, data_ptr, len);

                byte[] data = new byte[alen];
                Marshal.Copy(data_ptr, data, 0, alen);
                Marshal.FreeHGlobal(data_ptr);
                return(data);
            }
Пример #5
0
            public File(string path, OpenMode om) : base(true)
            {
                switch (om)
                {
                case OpenMode.READ:
                    file_handle = G_INTERNAL.FS_OpenR(path);
                    break;

                case OpenMode.WRITE:
                    file_handle = G_INTERNAL.FS_OpenW(path);
                    break;
                }
                openMode = om;
                if (file_handle == IntPtr.Zero)
                {
                    disposed = true;
                    throw new SVException("file not found");
                }
                length = G_INTERNAL.FS_Length(file_handle);
            }
Пример #6
0
 public static Entity[] FindEntitiesByTargetname(string name)
 {
     IntPtr[] ent_ptrs = G_INTERNAL.G_FindEntitiesBySharpTargetname(name);
     Entity[] ents     = ent_ptrs.Select(x => new Entity(x)).ToArray();
     return(ents);
 }
Пример #7
0
 public static void Chat(string name, string message, Player recipient)
 {
     G_INTERNAL.G_ChatTo(name, message, recipient.clinum);
 }
Пример #8
0
 public static void Chat(string name, string message)
 {
     G_INTERNAL.G_ChatAll(name, message);
 }
Пример #9
0
 public static void PrintLine <T>(T v)
 {
     G_INTERNAL.G_PrintStr(v.ToString() + "\n");
 }
Пример #10
0
        // ======================= //
        // -------- PRINT -------- //
        // ======================= //

        public static void Print <T>(T v)
        {
            G_INTERNAL.G_PrintStr(v.ToString());
        }
Пример #11
0
 public static Entity SpawnNPC(string type, Vec3 origin, float yaw = 0, int health = 0)
 {
     return(new Entity(G_INTERNAL.G_SpawnNPC(type, origin.valp, yaw, health)));
 }
Пример #12
0
 internal Player(Entity ent)
 {
     clinum = G_INTERNAL.G_PlayerFromEnt(ent.handle);
     entity = ent;
 }
Пример #13
0
 public void Kill()
 {
     G_INTERNAL.G_NPC_Kill(entity.handle);
 }
Пример #14
0
 protected override void Cleanup()
 {
     G_INTERNAL.G_DestroyEntity(handle);
 }
Пример #15
0
 public Entity() : base(true)
 {
     handle = G_INTERNAL.G_CreateEntity();
 }
Пример #16
0
 internal Entity(Player pl) : base(false)
 {
     handle = G_INTERNAL.G_EntFromPlayer(pl.clinum);
     player = pl;
 }