-
-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathshort.zig
More file actions
33 lines (26 loc) · 1.46 KB
/
Copy pathshort.zig
File metadata and controls
33 lines (26 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const std = @import("std");
const main = @import("main");
const ProceduralItem = main.items.ProceduralItem;
pub const Data = packed struct(u128) { multStrength: f32, flatStrength: f32, pad: u64 = undefined };
pub const priority = 1;
pub fn loadData(zon: main.ZonElement) Data {
return .{
.multStrength = @max(0, zon.get(f32, "multStrength") orelse 0),
.flatStrength = @max(0, zon.get(f32, "flatStrength") orelse 0),
};
}
pub fn combineModifiers(data1: Data, data2: Data) ?Data {
return .{
.multStrength = std.math.hypot(data1.multStrength, data2.multStrength),
.flatStrength = std.math.hypot(data1.flatStrength, data2.flatStrength),
};
}
pub fn changeBlockRange(data: Data) struct { f32, f32 } {
return .{data.flatStrength, data.multStrength};
}
pub fn printTooltip(outString: *main.ListManaged(u8), data: Data) void {
if (data.multStrength != 0 and data.flatStrength != 0) outString.print("#f80088**Short**#808080 *Decreases range by **{d:.0}%** and **+{d:.0}**", .{data.multStrength*100, data.flatStrength});
if (data.multStrength != 0 and data.flatStrength == 0) outString.print("#f80088**Short**#808080 *Decreases range by **{d:.0}%**", .{data.multStrength*100});
if (data.multStrength == 0 and data.flatStrength != 0) outString.print("#f80088**Short**#808080 *Decreases range by **+{d:.0}**", .{data.flatStrength});
if (data.multStrength == 0 and data.flatStrength == 0) outString.print("#ff0000**Short did not find any multStrength and Flatstrength**", .{});
}