Jump to content

Fuelweaver's death camera lock on other creatures?


Recommended Posts

local focustime = {
	bee = 3,
	toadstool = 5,
}

local function OnFocusCamera(inst)
	local player = GLOBAL.TheFocalPoint.entity:GetParent()
	if player ~= nil then
		GLOBAL.TheFocalPoint:PushTempFocus(inst, 6, 22, 6)
	end
end

local function DoDeathFocus(inst)
	if inst.modcamerafocusdeath:value() then
		if inst.modcamerafocusdeathtask == nil then
			inst.modcamerafocusdeathtask = inst:DoPeriodicTask(0, OnFocusCamera)
		end
	elseif inst.modcamerafocusdeathtask ~= nil then
		inst.modcamerafocusdeathtask:Cancel()
		inst.modcamerafocusdeathtask = nil
	end
end

local function CancelDeathFocus(inst)
	inst.modcamerafocusdeath:set(false)
end

local function TriggerDeathFocus(inst)
	inst.modcamerafocusdeath:set(true)
	inst:DoTaskInTime(focustime[inst.prefab], CancelDeathFocus)
end

local function DeathFocusInit(inst)
	inst.modcamerafocusdeath:set_local(false)
	if not GLOBAL.TheNet:IsDedicated() then
		inst:ListenForEvent("modcamerafocusdeathdirty", DoDeathFocus)
	end
	if GLOBAL.TheWorld.ismastersim then
		inst:ListenForEvent("death", TriggerDeathFocus)
	end
end

local function DeathFocus(inst)
	inst.modcamerafocusdeathtask = nil
	inst.modcamerafocusdeath = GLOBAL.net_bool(inst.GUID, "mod.modcamerafocusdeath", "modcamerafocusdeathdirty")
	inst:DoTaskInTime(0, DeathFocusInit)
end

for k, v in pairs(focustime) do
	AddPrefabPostInit(k, DeathFocus)
end

 

Link to comment
Share on other sites

Spoiler
2 hours ago, DarkXero said:


local focustime = {
	bee = 3,
	toadstool = 5,
}

local function OnFocusCamera(inst)
	local player = GLOBAL.TheFocalPoint.entity:GetParent()
	if player ~= nil then
		GLOBAL.TheFocalPoint:PushTempFocus(inst, 6, 22, 6)
	end
end

local function DoDeathFocus(inst)
	if inst.modcamerafocusdeath:value() then
		if inst.modcamerafocusdeathtask == nil then
			inst.modcamerafocusdeathtask = inst:DoPeriodicTask(0, OnFocusCamera)
		end
	elseif inst.modcamerafocusdeathtask ~= nil then
		inst.modcamerafocusdeathtask:Cancel()
		inst.modcamerafocusdeathtask = nil
	end
end

local function CancelDeathFocus(inst)
	inst.modcamerafocusdeath:set(false)
end

local function TriggerDeathFocus(inst)
	inst.modcamerafocusdeath:set(true)
	inst:DoTaskInTime(focustime[inst.prefab], CancelDeathFocus)
end

local function DeathFocusInit(inst)
	inst.modcamerafocusdeath:set_local(false)
	if not GLOBAL.TheNet:IsDedicated() then
		inst:ListenForEvent("modcamerafocusdeathdirty", DoDeathFocus)
	end
	if GLOBAL.TheWorld.ismastersim then
		inst:ListenForEvent("death", TriggerDeathFocus)
	end
end

local function DeathFocus(inst)
	inst.modcamerafocusdeathtask = nil
	inst.modcamerafocusdeath = GLOBAL.net_bool(inst.GUID, "mod.modcamerafocusdeath", "modcamerafocusdeathdirty")
	inst:DoTaskInTime(0, DeathFocusInit)
end

for k, v in pairs(focustime) do
	AddPrefabPostInit(k, DeathFocus)
end

 

 

Thanks! Would you allow me to upload it on the Steam Workshop (if you haven't done so already)? Mostly just so I don't have to redownload it manually... I'll give you full credit on the workshop page if you want it...

Link to comment
Share on other sites

1 hour ago, Electroely said:

Thanks! Would you allow me to upload it on the Steam Workshop (if you haven't done so already)? Mostly just so I don't have to redownload it manually... I'll give you full credit on the workshop page if you want it...

Go ahead and do as you please. I don't need credit.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...