Exemple #1
0
 protected override void Cleanup()
 {
     if (file_handle != IntPtr.Zero)
     {
         G_INTERNAL.FS_Close(file_handle);
     }
     file_handle = IntPtr.Zero;
 }
Exemple #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);
     }
 }
Exemple #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);
            }
Exemple #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);
            }
Exemple #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);
            }
Exemple #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);
 }
Exemple #7
0
 public static void Chat(string name, string message, Player recipient)
 {
     G_INTERNAL.G_ChatTo(name, message, recipient.clinum);
 }
Exemple #8
0
 public static void Chat(string name, string message)
 {
     G_INTERNAL.G_ChatAll(name, message);
 }
Exemple #9
0
 public static void PrintLine <T>(T v)
 {
     G_INTERNAL.G_PrintStr(v.ToString() + "\n");
 }
Exemple #10
0
        // ======================= //
        // -------- PRINT -------- //
        // ======================= //

        public static void Print <T>(T v)
        {
            G_INTERNAL.G_PrintStr(v.ToString());
        }
Exemple #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)));
 }
Exemple #12
0
 internal Player(Entity ent)
 {
     clinum = G_INTERNAL.G_PlayerFromEnt(ent.handle);
     entity = ent;
 }
Exemple #13
0
 public void Kill()
 {
     G_INTERNAL.G_NPC_Kill(entity.handle);
 }
Exemple #14
0
 protected override void Cleanup()
 {
     G_INTERNAL.G_DestroyEntity(handle);
 }
Exemple #15
0
 public Entity() : base(true)
 {
     handle = G_INTERNAL.G_CreateEntity();
 }
Exemple #16
0
 internal Entity(Player pl) : base(false)
 {
     handle = G_INTERNAL.G_EntFromPlayer(pl.clinum);
     player = pl;
 }