enough fonting, more servering?
This commit is contained in:
parent
e6d8607d3f
commit
b91bce8840
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "(lldb) Launch",
|
"name": "Client",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/zig-out/bin/client",
|
"program": "${workspaceFolder}/zig-out/bin/client",
|
||||||
@ -14,6 +14,17 @@
|
|||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"sourceLanguages": ["zig"]
|
"sourceLanguages": ["zig"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Server",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/zig-out/bin/server",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
"sourceLanguages": ["zig"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,9 +65,6 @@ pub fn main() !void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var vollkorn: [sizes.len]font.Font = undefined;
|
var vollkorn: [sizes.len]font.Font = undefined;
|
||||||
// var inconsolata: [sizes.len]font.Font = undefined;
|
|
||||||
// var arabic: [sizes.len]font.Font = undefined;
|
|
||||||
// // var japanese: [sizes.len]font.Font = undefined;
|
|
||||||
|
|
||||||
for (sizes, 0..) |pt, i| {
|
for (sizes, 0..) |pt, i| {
|
||||||
vollkorn[i] = try font.Font.init(
|
vollkorn[i] = try font.Font.init(
|
||||||
@ -75,28 +72,10 @@ pub fn main() !void {
|
|||||||
pt,
|
pt,
|
||||||
allocator
|
allocator
|
||||||
);
|
);
|
||||||
// inconsolata[i] = try font.Font.init(
|
|
||||||
// "assets/fonts/Inconsolata/static/Inconsolata-Regular.ttf",
|
|
||||||
// @intCast(pt),
|
|
||||||
// allocator
|
|
||||||
// );
|
|
||||||
// arabic[i] = try font.Font.init(
|
|
||||||
// "assets/fonts/Amiri/Amiri-Regular.ttf",
|
|
||||||
// @intCast(pt),
|
|
||||||
// allocator
|
|
||||||
// );
|
|
||||||
// japanese[i] = try font.Font.init(
|
|
||||||
// "assets/fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf",
|
|
||||||
// @intCast(pt),
|
|
||||||
// allocator
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
for (&vollkorn) |*f| f.deinit(allocator);
|
for (&vollkorn) |*f| f.deinit(allocator);
|
||||||
// for (&inconsolata) |*f| f.deinit(allocator);
|
|
||||||
// for (&arabic) |*f| f.deinit(allocator);
|
|
||||||
// for (&japanese) |*f| f.deinit(allocator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
font.shader = rl.LoadShader(null, "assets/text.frag");
|
font.shader = rl.LoadShader(null, "assets/text.frag");
|
||||||
@ -141,12 +120,8 @@ pub fn main() !void {
|
|||||||
|
|
||||||
// try stdout.flush();
|
// try stdout.flush();
|
||||||
|
|
||||||
// var the_chunk = try shared.chunk.initChunk(allocator);
|
var the_chunk = try shared.chunk.initChunk(allocator);
|
||||||
// defer shared.chunk.deinitChunk(&the_chunk, allocator);
|
defer shared.chunk.deinitChunk(&the_chunk, allocator);
|
||||||
|
|
||||||
// shared.chunk.updateChunk(&the_chunk);
|
|
||||||
|
|
||||||
//var elf = entity.Elf.init();
|
|
||||||
|
|
||||||
// var send_buf: [1024]u8 = undefined;
|
// var send_buf: [1024]u8 = undefined;
|
||||||
// var writer = if (connection) |*conn| conn.writer(&send_buf) else return;
|
// var writer = if (connection) |*conn| conn.writer(&send_buf) else return;
|
||||||
@ -179,14 +154,12 @@ pub fn main() !void {
|
|||||||
// rl.playMusicStream(music);
|
// rl.playMusicStream(music);
|
||||||
// std.log.info("is music playing? {}", .{rl.isMusicStreamPlaying(music)});
|
// std.log.info("is music playing? {}", .{rl.isMusicStreamPlaying(music)});
|
||||||
|
|
||||||
// var old_time : f32 = @floatCast(rl.getTime());
|
|
||||||
var old_time : f32 = @floatCast(rl.GetTime());
|
var old_time : f32 = @floatCast(rl.GetTime());
|
||||||
|
|
||||||
while (!rl.WindowShouldClose()) {
|
while (!rl.WindowShouldClose()) {
|
||||||
const tracy_main_zone = tracy.ZoneNC(@src(), "loop", 0x00_ff_00_00);
|
const tracy_main_zone = tracy.ZoneNC(@src(), "loop", 0x00_ff_00_00);
|
||||||
defer tracy_main_zone.End();
|
defer tracy_main_zone.End();
|
||||||
|
|
||||||
// const new_time : f32 = @floatCast(rl.getTime());
|
|
||||||
const new_time : f32 = @floatCast(rl.GetTime());
|
const new_time : f32 = @floatCast(rl.GetTime());
|
||||||
var frame_time = new_time - old_time;
|
var frame_time = new_time - old_time;
|
||||||
old_time = new_time;
|
old_time = new_time;
|
||||||
@ -197,7 +170,6 @@ pub fn main() !void {
|
|||||||
t += frame_time;
|
t += frame_time;
|
||||||
accumulator += frame_time * k;
|
accumulator += frame_time * k;
|
||||||
|
|
||||||
// std.log.info("t: {}", .{t});
|
|
||||||
|
|
||||||
// while (try host.service(0)) |event| switch (event) {
|
// while (try host.service(0)) |event| switch (event) {
|
||||||
// .connect => |data| {
|
// .connect => |data| {
|
||||||
@ -232,7 +204,6 @@ pub fn main() !void {
|
|||||||
// rl.updateMusicStream(music);
|
// rl.updateMusicStream(music);
|
||||||
|
|
||||||
while (accumulator > dt * k) {
|
while (accumulator > dt * k) {
|
||||||
// update(dt * cast(float) k);
|
|
||||||
accumulator -= dt * k;
|
accumulator -= dt * k;
|
||||||
gt += dt * k;
|
gt += dt * k;
|
||||||
}
|
}
|
||||||
@ -254,117 +225,6 @@ pub fn main() !void {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// arabic[0].render_text(
|
|
||||||
// "الليل طويل وبارد في الخارج",
|
|
||||||
// rl.Vector2{ .x = 0, .y = 100},
|
|
||||||
// true,
|
|
||||||
// .white,
|
|
||||||
// .blank,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// var y : f32 = 0;
|
|
||||||
// var it = std.mem.splitScalar(u8, lorem, '\n');
|
|
||||||
// while (it.next()) |line| {
|
|
||||||
// vollkorn[0].render_text(
|
|
||||||
// line,
|
|
||||||
// rl.Vector2{ .x = 0, .y = y},
|
|
||||||
// true,
|
|
||||||
// .white,
|
|
||||||
// .blank,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const font_linegap : f32 = @floatFromInt(vollkorn[0].face.size().metrics().height >> 6);
|
|
||||||
// const dpi_font_linegap = font_linegap / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// y += dpi_font_linegap;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// for (&vollkorn) |*f| {
|
|
||||||
// f.render_text(
|
|
||||||
// "Whereas, disregard and contempt for human rights have resulted!",
|
|
||||||
// rl.Vector2{ .x = 0, .y = y},
|
|
||||||
// true,
|
|
||||||
// .white,
|
|
||||||
// .blank,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
|
||||||
// // const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// // const font_descent : f32 = @floatFromInt(f.face.size().metrics().descender >> 6);
|
|
||||||
// // const dpi_font_descent = font_descent / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// const font_linegap : f32 = @floatFromInt(f.face.size().metrics().height >> 6);
|
|
||||||
// const dpi_font_linegap = font_linegap / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// y += dpi_font_linegap;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (&inconsolata) |*f| {
|
|
||||||
// f.render_text(
|
|
||||||
// "Whereas, disregard and contempt for human rights have resulted!",
|
|
||||||
// rl.Vector2{ .x = 0, .y = y},
|
|
||||||
// true,
|
|
||||||
// .white,
|
|
||||||
// .blank,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
|
||||||
// // const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// // const font_descent : f32 = @floatFromInt(f.face.size().metrics().descender >> 6);
|
|
||||||
// // const dpi_font_descent = font_descent / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// const font_linegap : f32 = @floatFromInt(f.face.size().metrics().height >> 6);
|
|
||||||
// const dpi_font_linegap = font_linegap / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// y += dpi_font_linegap;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (&japanese) |*f| {
|
|
||||||
// f.render_text(
|
|
||||||
// "外は夜が長くて寒い",
|
|
||||||
// c.Vector2{ .x = 0, .y = y},
|
|
||||||
// true,
|
|
||||||
// c.WHITE,
|
|
||||||
// c.BLANK,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
|
||||||
// const dpi_font_ascent = font_ascent / c.GetWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// y += dpi_font_ascent;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (&arabic) |*f| {
|
|
||||||
|
|
||||||
|
|
||||||
// const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
|
||||||
// const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
|
||||||
|
|
||||||
// y += dpi_font_ascent;
|
|
||||||
// }
|
|
||||||
// f.render_text(
|
|
||||||
// "Whereas, disregard and contempt for human rights have resulted!",
|
|
||||||
// rl.Vector2.init(0, 0),
|
|
||||||
// true,
|
|
||||||
// rl.Color.white,
|
|
||||||
// rl.Color.blank,
|
|
||||||
// false,
|
|
||||||
// true
|
|
||||||
// );
|
|
||||||
|
|
||||||
// rl.beginShaderMode(test_shader1);
|
// rl.beginShaderMode(test_shader1);
|
||||||
// rl.gl.rlBegin(rl.gl.rl_quads);
|
// rl.gl.rlBegin(rl.gl.rl_quads);
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
pub const c = @cImport({
|
pub const enet = @cImport({
|
||||||
// @cInclude("enet/enet.h");
|
@cInclude("enet/enet.h");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const zm = @import("zmath");
|
const zm = @import("zmath");
|
||||||
|
const enet = @import("c.zig").enet;
|
||||||
|
|
||||||
const shared = @import("shared");
|
const shared = @import("shared");
|
||||||
|
|
||||||
const chunk = @import("chunk.zig");
|
const chunk = @import("chunk.zig");
|
||||||
const server = @import("server.zig");
|
const server = @import("server.zig");
|
||||||
|
|
||||||
const dt : f32 = 1.0 / 200.0;
|
const dt : f32 = 1.0 / 200.0;
|
||||||
@ -13,38 +14,33 @@ var accumulator : f32 = 0;
|
|||||||
var k : f32 = 1.0;
|
var k : f32 = 1.0;
|
||||||
var frame : i32 = 0;
|
var frame : i32 = 0;
|
||||||
|
|
||||||
var stdout: *std.io.Writer = undefined;
|
var dbg_allocator = std.heap.DebugAllocator(.{}){};
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
std.log.info("Hello Server!", .{});
|
|
||||||
var dbg_allocator = std.heap.DebugAllocator(.{}).init;
|
|
||||||
defer _ = dbg_allocator.deinit();
|
|
||||||
const allocator = dbg_allocator.allocator();
|
const allocator = dbg_allocator.allocator();
|
||||||
|
defer {
|
||||||
|
const deinit_status = dbg_allocator.deinit();
|
||||||
|
if (deinit_status == .leak) {
|
||||||
|
@panic("LEAKED!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var stdout_buffer: [1024]u8 = undefined;
|
var stdout = std.fs.File.stdout();
|
||||||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
|
_ = try stdout.write("Hello, Server!\n");
|
||||||
stdout = &stdout_writer.interface;
|
|
||||||
|
|
||||||
try stdout.flush();
|
if (enet.enet_initialize() != 0) {
|
||||||
|
std.log.info("Failed to load ENet", .{});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// try znet.init();
|
defer enet.enet_deinitialize();
|
||||||
// defer znet.deinit();
|
|
||||||
|
|
||||||
// server.host = try znet.Host.init(.{
|
const address = enet.ENetAddress{ .host = enet.ENET_HOST_ANY, .port = shared.protocol.SERVER_PORT };
|
||||||
// .addr = try .init(.{
|
var host : ?*enet.ENetHost = null;
|
||||||
// .ip = .any,
|
|
||||||
// .port = .{ .uint = 5000 },
|
|
||||||
// }),
|
|
||||||
// .peer_limit = 32,
|
|
||||||
// .channel_limit = .max,
|
|
||||||
// .incoming_bandwidth = .unlimited,
|
|
||||||
// .outgoing_bandwidth = .unlimited,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const address = try std.net.Address.parseIp4("127.0.0.1", shared.protocol.SERVER_PORT);
|
host = enet.enet_host_create(&address, 32, 2, 0, 0);
|
||||||
// var tcp_server = try address.listen(.{});
|
defer enet.enet_host_destroy(host);
|
||||||
|
|
||||||
// defer tcp_server.deinit();
|
|
||||||
|
|
||||||
var the_chunk = try shared.chunk.initChunk(allocator);
|
var the_chunk = try shared.chunk.initChunk(allocator);
|
||||||
defer shared.chunk.deinitChunk(&the_chunk, allocator);
|
defer shared.chunk.deinitChunk(&the_chunk, allocator);
|
||||||
@ -62,7 +58,21 @@ pub fn main() !void {
|
|||||||
t += frame_time;
|
t += frame_time;
|
||||||
accumulator += frame_time * k;
|
accumulator += frame_time * k;
|
||||||
|
|
||||||
// std.log.info("t: {}", .{t});
|
var event = enet.ENetEvent{};
|
||||||
|
while (enet.enet_host_service(host, &event, 0) > 0) {
|
||||||
|
switch (event.type) {
|
||||||
|
enet.ENET_EVENT_TYPE_CONNECT => {
|
||||||
|
std.log.info("hello", .{});
|
||||||
|
},
|
||||||
|
enet.ENET_EVENT_TYPE_RECEIVE => {
|
||||||
|
std.log.info("hello", .{});
|
||||||
|
},
|
||||||
|
enet.ENET_EVENT_TYPE_DISCONNECT => {
|
||||||
|
std.log.info("hello", .{});
|
||||||
|
},
|
||||||
|
else => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// while (try server.host.service(0)) |event| switch (event) {
|
// while (try server.host.service(0)) |event| switch (event) {
|
||||||
// .connect => |data| {
|
// .connect => |data| {
|
||||||
@ -94,8 +104,10 @@ pub fn main() !void {
|
|||||||
// try shared.protocol.sendHello(w, .{ .msg = "Hello from server!" });
|
// try shared.protocol.sendHello(w, .{ .msg = "Hello from server!" });
|
||||||
|
|
||||||
try chunk.spawn(&the_chunk, shared.entity.Elf, allocator, .{
|
try chunk.spawn(&the_chunk, shared.entity.Elf, allocator, .{
|
||||||
.pos = zm.f32x4(1, 1, 0, 0),
|
.pos = zm.f32x4(1, 0, 0, 0),
|
||||||
|
.vel = zm.f32x4(0, 0, 0, 0),
|
||||||
.hp = 10,
|
.hp = 10,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// try chunk.spawn(&the_chunk, shared.entity.Monster, allocator, .{
|
// try chunk.spawn(&the_chunk, shared.entity.Monster, allocator, .{
|
||||||
|
|||||||
@ -7,17 +7,18 @@ pub const INVALID_ID: id = 0;
|
|||||||
|
|
||||||
pub const EntityKinds = .{
|
pub const EntityKinds = .{
|
||||||
Elf,
|
Elf,
|
||||||
Monster,
|
Cow,
|
||||||
Projectile,
|
Pig,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Elf = struct {
|
pub const Elf = struct {
|
||||||
id: id = INVALID_ID,
|
id: id = INVALID_ID,
|
||||||
pos: zm.Vec,
|
pos: zm.Vec,
|
||||||
|
vel: zm.Vec,
|
||||||
hp: i32,
|
hp: i32,
|
||||||
|
|
||||||
pub fn update(self: *Elf) void {
|
pub fn update(self: *Elf) void {
|
||||||
self.pos += zm.f32x4(1, 1, 0, 0);
|
self.pos += self.pos + self.vel;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_message(self: *Elf) protocol.Elf_v1 {
|
pub fn to_message(self: *Elf) protocol.Elf_v1 {
|
||||||
@ -25,19 +26,24 @@ pub const Elf = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Monster = struct {
|
pub const Cow = struct {
|
||||||
id: id = INVALID_ID,
|
|
||||||
pos: zm.Vec,
|
|
||||||
hp: i32,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Projectile = struct {
|
|
||||||
id: id = INVALID_ID,
|
id: id = INVALID_ID,
|
||||||
pos: zm.Vec,
|
pos: zm.Vec,
|
||||||
vel: zm.Vec,
|
vel: zm.Vec,
|
||||||
|
hp: i32,
|
||||||
|
|
||||||
pub fn update(self: *Projectile) void {
|
pub fn update(self: *Cow) void {
|
||||||
|
self.pos = self.pos + self.vel;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const Pig = struct {
|
||||||
|
id: id = INVALID_ID,
|
||||||
|
pos: zm.Vec,
|
||||||
|
vel: zm.Vec,
|
||||||
|
hp: i32,
|
||||||
|
|
||||||
|
pub fn update(self: *Pig) void {
|
||||||
self.pos = self.pos + self.vel;
|
self.pos = self.pos + self.vel;
|
||||||
std.log.info("pos=({})", .{self.pos});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,17 +13,17 @@ pub const Message = union(enum) {
|
|||||||
|
|
||||||
pub const SpawnEntity = union(enum) {
|
pub const SpawnEntity = union(enum) {
|
||||||
elf_v1: Elf_v1,
|
elf_v1: Elf_v1,
|
||||||
monster_v1: Monster_v1,
|
cow_v1: Cow_v1,
|
||||||
projectile_v1: Projectile_v1,
|
pig_v1: Pig_v1,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn makeSpawnMessage(comptime T: type, e: T) Message {
|
pub fn makeSpawnMessage(comptime T: type, e: T) Message {
|
||||||
if (T == entity.Elf) {
|
if (T == entity.Elf) {
|
||||||
return .{ .spawn_entity = .{ .elf_v1 = Elf_v1.init(e) } };
|
return .{ .spawn_entity = .{ .elf_v1 = Elf_v1.init(e) } };
|
||||||
} else if (T == entity.Monster) {
|
} else if (T == entity.Cow) {
|
||||||
return .{ .spawn_entity = .{ .monster_v1 = Monster_v1.init(e) } };
|
return .{ .spawn_entity = .{ .cow_v1 = Cow_v1.init(e) } };
|
||||||
} else if (T == entity.Projectile) {
|
} else if (T == entity.Pig) {
|
||||||
return .{ .spawn_entity = .{ .projectile_v1 = Projectile_v1.init(e) } };
|
return .{ .spawn_entity = .{ .pig_v1 = Pig_v1.init(e) } };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,26 +74,26 @@ pub const Elf_v1 = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Monster_v1 = struct {
|
pub const Cow_v1 = struct {
|
||||||
id: entity.id = entity.INVALID_ID,
|
id: entity.id = entity.INVALID_ID,
|
||||||
pos: zm.Vec,
|
pos: zm.Vec,
|
||||||
hp: i32,
|
hp: i32,
|
||||||
|
|
||||||
pub fn init(monster: entity.Monster) Monster_v1 {
|
pub fn init(cow: entity.Cow) Cow_v1 {
|
||||||
return .{
|
return .{
|
||||||
.id = monster.id,
|
.id = cow.id,
|
||||||
.pos = monster.pos,
|
.pos = cow.pos,
|
||||||
.hp = monster.hp,
|
.hp = cow.hp,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn encode(self: Monster_v1, w: *std.Io.Writer) !void {
|
// pub fn encode(self: Cow_v1, w: *std.Io.Writer) !void {
|
||||||
// try w.writeInt(u64, self.id, .little);
|
// try w.writeInt(u64, self.id, .little);
|
||||||
// try writeVec4(w, self.pos);
|
// try writeVec4(w, self.pos);
|
||||||
// try writeVec4(w, self.vel);
|
// try writeVec4(w, self.vel);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn decode(r: *std.Io.Reader) !Monster_v1 {
|
pub fn decode(r: *std.Io.Reader) !Cow_v1 {
|
||||||
return .{
|
return .{
|
||||||
.id = try r.readInt(u64, .little),
|
.id = try r.readInt(u64, .little),
|
||||||
.pos = try readVec4(r),
|
.pos = try readVec4(r),
|
||||||
@ -102,26 +102,26 @@ pub const Monster_v1 = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Projectile_v1 = struct {
|
pub const Pig_v1 = struct {
|
||||||
id: entity.id = entity.INVALID_ID,
|
id: entity.id = entity.INVALID_ID,
|
||||||
pos: zm.Vec,
|
pos: zm.Vec,
|
||||||
vel: zm.Vec,
|
vel: zm.Vec,
|
||||||
|
|
||||||
pub fn init(projectile: entity.Projectile) Projectile_v1 {
|
pub fn init(pig: entity.Pig) Pig_v1 {
|
||||||
return .{
|
return .{
|
||||||
.id = projectile.id,
|
.id = pig.id,
|
||||||
.pos = projectile.pos,
|
.pos = pig.pos,
|
||||||
.vel = projectile.vel,
|
.vel = pig.vel,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn encode(self: Projectile_v1, w: *std.Io.Writer) !void {
|
// pub fn encode(self: Pig_v1, w: *std.Io.Writer) !void {
|
||||||
// try w.writeInt(u64, self.id, .little);
|
// try w.writeInt(u64, self.id, .little);
|
||||||
// try writeVec4(w, self.pos);
|
// try writeVec4(w, self.pos);
|
||||||
// try writeVec4(w, self.vel);
|
// try writeVec4(w, self.vel);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn decode(r: *std.Io.Reader) !Projectile_v1 {
|
pub fn decode(r: *std.Io.Reader) !Pig_v1 {
|
||||||
return .{
|
return .{
|
||||||
.id = try r.readInt(u64, .little),
|
.id = try r.readInt(u64, .little),
|
||||||
.pos = try readVec4(r),
|
.pos = try readVec4(r),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user