protected override void Cleanup() { if (file_handle != IntPtr.Zero) { G_INTERNAL.FS_Close(file_handle); } file_handle = IntPtr.Zero; }
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); } }
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); }
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); }
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); }
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); }
public static void Chat(string name, string message, Player recipient) { G_INTERNAL.G_ChatTo(name, message, recipient.clinum); }
public static void Chat(string name, string message) { G_INTERNAL.G_ChatAll(name, message); }
public static void PrintLine <T>(T v) { G_INTERNAL.G_PrintStr(v.ToString() + "\n"); }
// ======================= // // -------- PRINT -------- // // ======================= // public static void Print <T>(T v) { G_INTERNAL.G_PrintStr(v.ToString()); }
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))); }
internal Player(Entity ent) { clinum = G_INTERNAL.G_PlayerFromEnt(ent.handle); entity = ent; }
public void Kill() { G_INTERNAL.G_NPC_Kill(entity.handle); }
protected override void Cleanup() { G_INTERNAL.G_DestroyEntity(handle); }
public Entity() : base(true) { handle = G_INTERNAL.G_CreateEntity(); }
internal Entity(Player pl) : base(false) { handle = G_INTERNAL.G_EntFromPlayer(pl.clinum); player = pl; }