Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SynapseX Decompiler
- local PetRenderingService = {}
- local Services = require(game.ReplicatedStorage.Assets.Modules.Services)
- local rs = Services:GetService("RunService")
- local ts = Services:GetService("TweenService")
- local SoundService = require(game.ReplicatedStorage.Assets.Modules.SoundService)
- local ShinyModifier = Services:GetService("Library")("ShinyModifier")
- local Pet = require(script.PetClass)
- PetRenderingService.PetClass = Pet
- local pets = {}
- local player = game.Players.LocalPlayer
- local v2 = Vector2.new
- local v2_dot = v2().Dot
- local function toV2(vec)
- return v2(vec.X, vec.Z)
- end
- function PetRenderingService:CreatePet(plr, model, guid)
- local origin = plr.Character.PrimaryPart.Position - Vector3.new(0, 2.5, 0)
- if model.Shiny.Value == true then
- ShinyModifier:Modify(model)
- end
- local pet = Pet.new(plr, model, guid)
- pets[pet] = true
- self:UpdateOffsets(plr)
- pet:Spawn(origin)
- if model.Name == "Beta TV" and not model.Decore.Screen:FindFirstChild("TVManager") then
- spawn(function()
- require(script.TVManager)(model)
- end)
- end
- end
- function PetRenderingService:RemovePet(plr, guid)
- for pet in next, pets, nil do
- if pet.Owner == plr and pet.GUID == guid then
- pet:Destroy()
- pets[pet] = nil
- return
- end
- end
- end
- function PetRenderingService:UpdateOffsets(plr)
- local theirs = {}
- for pet in next, pets, nil do
- if pet.Owner == plr then
- theirs[#theirs + 1] = pet
- end
- end
- local number = #theirs
- local random = Random.new()
- local angle = math.pi * 2 / number
- for i = 1, number do
- local pet = theirs[i]
- pet.Offset = CFrame.Angles(0, angle * i + random:NextNumber(-angle * 0.3, angle * 0.3), 0) * Vector3.new(0, -2.5, pet.Radius)
- end
- end
- local function levelUp(pet, level)
- local glow = script.Glow:Clone()
- glow.Parent = pet.PrimaryPart
- glow:Emit(100)
- local gui = script.LevelUp:Clone()
- gui.Icon.ImageTransparency = 1
- gui.Icon.Size = UDim2.new()
- gui.Amount.TextTransparency = 1
- gui.Amount.TextStrokeTransparency = 1
- gui.Amount.Text = level
- gui.Parent = pet.PrimaryPart
- SoundService:Play({
- Parent = pet.PrimaryPart,
- Name = "LevelUp",
- Volume = 0.25
- })
- local icon = gui:FindFirstChild("Icon")
- if icon then
- ts:Create(icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {
- Rotation = 720,
- ImageTransparency = 0,
- Size = UDim2.new(1, 0, 1, 0)
- }):Play()
- end
- wait(0.5)
- local amt = gui:FindFirstChild("Amount")
- if amt then
- ts:Create(gui.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 0, TextStrokeTransparency = 0.5}):Play()
- delay(1.5, function()
- ts:Create(gui.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 1, TextStrokeTransparency = 1}):Play()
- ts:Create(gui.Icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 1}):Play()
- end)
- end
- delay(2, function()
- gui:Destroy()
- end)
- delay(5, function()
- glow:Destroy()
- end)
- end
- local function displayXP(pet, amount)
- local xp = script.XP:Clone()
- xp.Parent = pet.PrimaryPart
- if amount == "MAXED" then
- xp.Amount.Text = "MAX LEVEL!"
- else
- xp.Amount.Text = "+" .. amount
- end
- local del = math.random(75, 150) / 100
- ts:Create(xp, TweenInfo.new(del, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {
- StudsOffset = Vector3.new(0, 5, 0)
- }):Play()
- delay(del, function()
- ts:Create(xp.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 1, TextStrokeTransparency = 1}):Play()
- ts:Create(xp.Icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 1}):Play()
- wait(0.5)
- xp:Destroy()
- end)
- end
- function PetRenderingService:Initialize(Network)
- for _, b in pairs(game.Workspace.Pets:GetChildren()) do
- local owner = b.Owner.Value
- local guid = b.GUID.Value
- if owner and owner.Parent then
- PetRenderingService:CreatePet(owner, b, guid)
- else
- b:Destroy()
- end
- end
- Network:Bind("SpawnPet", function(plr, model, guid)
- PetRenderingService:CreatePet(plr, model, guid)
- self:UpdateOffsets(plr)
- end)
- Network:Bind("DespawnPet", function(plr, guid)
- PetRenderingService:RemovePet(plr, guid)
- self:UpdateOffsets(plr)
- end)
- Network:Bind("LevelPetUp", function(guid, level)
- for pet in next, pets, nil do
- if pet.Owner == player and pet.GUID == guid then
- levelUp(pet.Model, level)
- return
- end
- end
- end)
- Network:Bind("DisplayPetXP", function(xpTable)
- for i = 1, #xpTable do
- for pet in next, pets, nil do
- if pet.Owner == player and pet.GUID == xpTable[i][1] then
- displayXP(pet.Model, xpTable[i][2])
- break
- end
- end
- end
- end)
- rs:BindToRenderStep("PetRendering", Enum.RenderPriority.Character.Value + 1, function(dt)
- for pet in next, pets, nil do
- if not pet.Owner.Parent then
- pet:Destroy()
- pets[pet] = nil
- else
- pet:Update()
- end
- end
- end)
- end
- game.Players.PlayerRemoving:Connect(function(Player)
- for pet in next, pets, nil do
- if pet.Owner == Player then
- pet:Destroy()
- pets[pet] = nil
- end
- end
- end)
- return PetRenderingService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement