File size: 3,352 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
if not const.cmtVisible then return end
if FirstLoad then
C_CCMT = false
end
function SetC_CCMT(val)
if C_CCMT == val then
return
end
C_CCMT_Reset()
C_CCMT = val
end
function OnMsg.ChangeMap()
C_CCMT_Reset()
end
MapVar("CMT_ToHide", {})
MapVar("CMT_ToUnhide", {})
MapVar("CMT_Hidden", {})
CMT_Time = 300
CMT_OpacitySleep = 10
CMT_OpacityStep = Max(1, MulDivRound(CMT_OpacitySleep, 100, CMT_Time))
if FirstLoad then
g_CMTPaused = false
g_CMTPauseReasons = {}
end
function CMT_SetPause(s, reason)
if s then
g_CMTPauseReasons[reason] = true
g_CMTPaused = true
else
g_CMTPauseReasons[reason] = nil
if not next(g_CMTPauseReasons) then
g_CMTPaused = false
end
end
end
MapRealTimeRepeat( "CMT_V2_Thread", 0, function()
Sleep(CMT_OpacitySleep)
if g_CMTPaused then return end
--local startTs = GetPreciseTicks(1000)
if C_CCMT then
C_CCMT_Thread_Func(CMT_OpacityStep)
else
local opacity_step = CMT_OpacityStep
for k,v in next, CMT_ToHide do
if not IsValid(k) then
CMT_ToHide[k] = nil
else
local next_opacity = k:GetOpacity() - opacity_step
if next_opacity > 0 then
k:SetOpacity(next_opacity)
else
k:SetOpacity(0)
CMT_ToHide[k] = nil
CMT_Hidden[k] = true
end
end
end
for k,v in next, CMT_ToUnhide do
if not IsValid(k) then
CMT_ToUnhide[k] = nil
else
local next_opacity = k:GetOpacity() + opacity_step
if next_opacity < 100 then
k:SetOpacity(next_opacity)
else
k:SetOpacity(100)
k:ClearHierarchyGameFlags(const.gofSolidShadow + const.gofContourInner)
CMT_ToUnhide[k] = nil
end
end
end
end
--local endTs = GetPreciseTicks(1000)
--print("CMT_V2_Thread time", endTs - startTs)
end)
function IsContourObject(obj)
return const.SlabSizeX and IsKindOf(obj, "Slab")
end
function CMT(obj, b)
if C_CCMT then
C_CCMT_Hide(obj, not not b)
return
end
if b then
if CMT_ToHide[obj] or CMT_Hidden[obj] then return end
if CMT_ToUnhide[obj] then
CMT_ToUnhide[obj] = nil
end
CMT_ToHide[obj] = true
obj:SetHierarchyGameFlags(const.gofSolidShadow)
if IsContourObject(obj) then
obj:SetHierarchyGameFlags(const.gofContourInner)
end
else
if CMT_ToUnhide[obj] or not CMT_ToHide[obj] and not CMT_Hidden[obj] then return end
if CMT_ToHide[obj] then
CMT_ToHide[obj] = nil
end
if IsEditorActive() then
obj:SetOpacity(100)
obj:ClearHierarchyGameFlags(const.gofSolidShadow + const.gofContourInner)
else
CMT_ToUnhide[obj] = true
end
if CMT_Hidden[obj] then
CMT_Hidden[obj] = nil
end
end
end
local function ShowAllKeyObjectsAndClearTable(table)
for obj, _ in pairs(table) do
if IsValid(obj) then
obj:SetOpacity(100)
obj:ClearHierarchyGameFlags(const.gofSolidShadow + const.gofContourInner)
end
table[obj] = nil
end
end
function OnMsg.ChangeMapDone(map)
if string.find(map, "MainMenu") then
CMT_SetPause(true, "MainMenu")
else
CMT_SetPause(false, "MainMenu")
end
end
function OnMsg.GameEnterEditor()
C_CCMT_ShowAllAndReset()
ShowAllKeyObjectsAndClearTable(CMT_ToHide)
ShowAllKeyObjectsAndClearTable(CMT_ToUnhide)
ShowAllKeyObjectsAndClearTable(CMT_Hidden)
end
function CMT_IsObjVisible(o)
if not C_CCMT then
return o:GetGameFlags(const.gofSolidShadow) == 0 or CMT_ToUnhide[o]
else
return C_CCMT_GetObjCMTState(o) < const.cmtHidden
end
end
|