idk
This commit is contained in:
parent
05c424e6c1
commit
519f7966b7
@ -9,67 +9,64 @@ local rBotUtils = require(rUtils.sharedBotUtils)
|
||||
local rData = ReplicatedStorage.Data
|
||||
local rWeaponData = require(rData.WeaponData)
|
||||
|
||||
|
||||
local Component = script.Parent.Component
|
||||
local HitboxComponent = require(Component.HitboxComponent)
|
||||
local ProjectileComponent = require(Component.ProjectileComponent)
|
||||
local HealthComponent = require(Component.HealthComponent)
|
||||
local DestroyableComponent = require(Component.DestroyableComponent)
|
||||
|
||||
local Janitor = require(ReplicatedStorage:WaitForChild("Janitor"))
|
||||
local Janitor = require(workspace:WaitForChild("Janitor"))
|
||||
|
||||
GameObject.__index = GameObject
|
||||
|
||||
type self = {
|
||||
key : string,
|
||||
owner : number?,
|
||||
model : Model?,
|
||||
type : string,
|
||||
active : boolean,
|
||||
|
||||
Janitor : typeof(Janitor.new()),
|
||||
|
||||
Components : {
|
||||
Projectile : ProjectileComponent.ProjectileComponent,
|
||||
Hitbox : HitboxComponent.HitboxComponent,
|
||||
Health : HealthComponent.HealthComponent,
|
||||
Destroyable : DestroyableComponent.DestroyableComponent
|
||||
key: string,
|
||||
owner: number?,
|
||||
model: Model?,
|
||||
type: string,
|
||||
active: boolean,
|
||||
|
||||
Janitor: typeof(Janitor.new()),
|
||||
|
||||
Components: {
|
||||
Projectile: ProjectileComponent.ProjectileComponent,
|
||||
Hitbox: HitboxComponent.HitboxComponent,
|
||||
Health: HealthComponent.HealthComponent,
|
||||
Destroyable: DestroyableComponent.DestroyableComponent,
|
||||
},
|
||||
|
||||
timepassed : number,
|
||||
tickspassed : number,
|
||||
|
||||
|
||||
timepassed: number,
|
||||
tickspassed: number,
|
||||
}
|
||||
|
||||
--GameObject(TurnEnd, TurnStart, OnDestroy, Tick) Anything that needs this is a gameobject
|
||||
|
||||
export type GameObject = typeof(setmetatable({} :: self, GameObject))
|
||||
|
||||
export type GameObject = typeof( setmetatable({} :: self, GameObject) )
|
||||
function GameObject.new(key: string?, model: Model, userId: number?, active)
|
||||
local self = setmetatable({} :: self, GameObject)
|
||||
|
||||
function GameObject.new(key : string?,model : Model,userId : number?,active)
|
||||
local self = setmetatable({} :: self,GameObject)
|
||||
|
||||
key = key or HttpServ:GenerateGUID(false)
|
||||
print(key)
|
||||
self.owner = userId
|
||||
self.model = model
|
||||
self.Janitor = Janitor.new()
|
||||
self.Janitor = Janitor.new()
|
||||
self.key = key
|
||||
self.timepassed = 0
|
||||
self.tickspassed = 0
|
||||
self.active = active
|
||||
|
||||
|
||||
self.Components = {}
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-- DONT OVERWRITE THESE
|
||||
function GameObject:_Init()
|
||||
if self.model then
|
||||
self.model:SetAttribute("key",self.key)
|
||||
self.model:SetAttribute("key", self.key)
|
||||
end
|
||||
|
||||
|
||||
self:_ResetMass()
|
||||
self:OnCreate()
|
||||
self:_Store()
|
||||
@ -78,7 +75,7 @@ end
|
||||
|
||||
-- DONT OVERWRITE THESE
|
||||
function GameObject:_Store()
|
||||
ObjectManager.Store(self.key,self)
|
||||
ObjectManager.Store(self.key, self)
|
||||
end
|
||||
|
||||
-- DONT OVERWRITE THESE
|
||||
@ -93,13 +90,13 @@ function GameObject:_ResetMass()
|
||||
local self = self :: GameObject
|
||||
if self.model then
|
||||
local primaryPart = self.model.PrimaryPart
|
||||
for i,v in pairs(self.model:GetDescendants()) do
|
||||
for i, v in pairs(self.model:GetDescendants()) do
|
||||
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
|
||||
if primaryPart == v or v.Parent.Name == "Hitbox" then
|
||||
continue
|
||||
end
|
||||
v.Massless = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -107,7 +104,7 @@ end
|
||||
-- DONT OVERWRITE THESE
|
||||
function GameObject:_BeforeTick(dt)
|
||||
local self = self :: GameObject
|
||||
|
||||
|
||||
self.timepassed += dt
|
||||
self.tickspassed += 1
|
||||
end
|
||||
@ -118,7 +115,7 @@ function GameObject:_Destroy()
|
||||
pcall(function()
|
||||
self:BeforeDestroy()
|
||||
end)
|
||||
|
||||
|
||||
pcall(function()
|
||||
if self.model then
|
||||
self.model:Destroy()
|
||||
@ -126,7 +123,6 @@ function GameObject:_Destroy()
|
||||
self.Janitor:Destroy()
|
||||
ObjectManager._Free(self.key)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@ -136,38 +132,30 @@ end
|
||||
--if true resolve can resolve early(if all gameobjects agree :o)
|
||||
function GameObject:ShouldEnd()
|
||||
if self.model then
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function GameObject:GetWeaponData(name) : rWeaponData.WeaponData
|
||||
function GameObject:GetWeaponData(name): rWeaponData.WeaponData
|
||||
return rWeaponData[name]
|
||||
end
|
||||
|
||||
function GameObject:OnHit()
|
||||
local self = self :: GameObject
|
||||
|
||||
end
|
||||
|
||||
function GameObject:OnTurnEnd()
|
||||
local self = self :: GameObject
|
||||
|
||||
end
|
||||
|
||||
function GameObject:Tick(dt)
|
||||
|
||||
end
|
||||
function GameObject:Tick(dt) end
|
||||
|
||||
function GameObject:OnCreate()
|
||||
local self = self :: GameObject
|
||||
|
||||
end
|
||||
--Before Destroying
|
||||
function GameObject:BeforeDestroy()
|
||||
local self = self :: GameObject
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
return GameObject
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user