--[[
作者：小开心
请不要擅自修改或删除
请尊重版权
@

说明：
想患 懒癌强迫症
]]

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}

local prefabs = {

}

local start_inv = {
	"cheese",
	"cheese",
	"trumpet",
}

local function firefxfn(inst, phase) 
    if phase ~= "night" and inst.firefx then 
        inst.firefx:Remove() 
        inst.firefx = nil 
    elseif phase == "night" and inst.firefx == nil and not inst:HasTag("playerghosts") then
        local fx = SpawnPrefab("firework") 
        if fx then 
            local follower = fx.entity:AddFollower()
            follower:FollowSymbol(inst.GUID, "swap_hat", 0, -240, 0) 
            inst.firefx = fx
        end
    end
end

local function firefn( inst )
    firefxfn(inst, TheWorld.state.phase)
end

local function common_magicgirlpostinit(inst) 

	inst.MiniMapEntity:SetIcon( "nagisa.tex" )
	inst:AddTag("nagisa_build")

	if TheWorld:GetServerGameMode() == "MST" then 
        xk.magicgirl_server_data("/", "prefabs/nagisa").common_postinit(inst)
    end
end

local function master_magicgirlpostinit(inst)

	inst.soundsname = "willow"

	--inst:ListenForEvent("killed", onkilled)

	if TheWorld:GetServerGameMode() == "MST" then
        xk.magicgirl_server_data("Server/", "prefabs/nagisa").master_postinit(inst)
    end

    inst:ListenForEvent("ms_respawnedfromghost", firefn)
    inst:ListenForEvent("ms_becameghost", firefn)
    inst:WatchWorldState("phase", firefxfn )

    inst.OnLoad = firefn
end 

return MakePlayerCharacter("nagisa", prefabs, assets,  common_magicgirlpostinit, master_magicgirlpostinit, start_inv)
