Backlog/depot/zuck/actors/ZuckPlayer.zig

54 lines
1.8 KiB
Zig

pub const BoxObject = struct {
playing: bool = false,
pub fn create(allocator: std.mem.Allocator, entity: core.Entity, params: core.SpawnParameters) !*@This() {
const position = params.posRot.position;
const box2 = entity;
const scene = box2.addComponent(core.Scene).?;
const mesh = box2.addComponent(rend.MeshComponent).?;
mesh.setMesh("m_crate");
mesh.setTexture("t_crate");
scene.setPosition(position);
scene.setScaleV(params.posRot.scale);
scene.setMobility(.moveable);
const collider = box2.addComponent(physics.PhysicsCollider).?;
try collider.setupByShapeName(core.MakeName("ph_small_box"), .{
.motion_type = .dynamic,
.object_layer = physics.ObjectLayers.moving,
.friction = 0.8,
.mass_properties_override = .{ .mass = 12 },
.override_mass_properties = .calc_inertia,
});
return try allocator.create(@This());
}
pub fn createSmoky(allocator: std.mem.Allocator, entity: core.Entity, params: core.SpawnParameters) !*@This() {
const rv = try create(allocator, entity, params);
const particle = entity.addComponent(rend.ParticleEmitter).?;
particle.start();
particle.gravity = .{ .y = 1.0 };
particle.particleVelocity = .{ .min = 0.6, .max = 1.2 };
particle.particleLife = .{ .min = 5, .max = 6 };
var name = core.MakeName("t_pixelSmoke");
particle.texture = rend.getTexture(&name).?;
return rv;
}
pub fn destroy(self: *@This(), alloc: std.mem.Allocator) void {
alloc.destroy(self);
}
};
const std = @import("std");
const Backlog = @import("Backlog");
const core = Backlog.core;
const rend = Backlog.rend;
const physics = Backlog.physics;