39 lines
942 B
Plaintext
39 lines
942 B
Plaintext
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local Vex = require(ReplicatedStorage.Vex)
|
|
|
|
local Component = require(script.Parent)
|
|
|
|
local DestroyableComponent = setmetatable({},Component)
|
|
|
|
type self = {
|
|
model : Model,
|
|
HitBoxParts: {Part},
|
|
HitParams: OverlapParams,
|
|
}
|
|
|
|
shared.DESTROYABLE_TAG = "DESTROYABLE"
|
|
|
|
export type DestroyableComponent = typeof(setmetatable({}, DestroyableComponent)) & Component.Component
|
|
|
|
|
|
DestroyableComponent.__index = DestroyableComponent
|
|
|
|
function DestroyableComponent.new(parentKey,voxelModel : Model,mainModel,data)
|
|
local self = setmetatable(Component.new(parentKey) :: self,DestroyableComponent)
|
|
|
|
mainModel:AddTag(shared.DESTROYABLE_TAG)
|
|
self.model = voxelModel
|
|
local v = Vex.new(voxelModel,{voxelSize = .5,maxVoxels = 20000,lifetime = 1,useGreedyMesh = false,anchored = true,weldAdjacent = false})
|
|
self.VexObject = v
|
|
v:Destroy()
|
|
|
|
return self
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DestroyableComponent
|