Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _G = GLOBAL
- local EQUIPSLOTS = _G.EQUIPSLOTS
- local items_list = require("equip_list")
- --[[ Get our Configs ]]
- local ITEM_PREFABS = {}
- local FX_PREFABS = {}
- local function CategoryConfigs(data)
- for _, v in pairs(data) do
- local prefab = v.prefab
- if prefab then
- ITEM_PREFABS[prefab] = GetModConfigData(prefab)
- end
- if v.fx and v.fx.prefab then
- FX_PREFABS[v.fx.prefab] = GetModConfigData(v.fx.prefab)
- end
- end
- end
- for _, category in pairs(items_list) do
- CategoryConfigs(category.data)
- end
- --[[ Hide Helper Functions ]]
- local function HideHeadSlot(inst)
- local AnimState = inst.AnimState
- local build = inst:GetSkinBuild() or AnimState:GetBuild()
- AnimState:ClearOverrideSymbol("headbase_hat")
- AnimState:ClearOverrideSymbol("swap_hat")
- AnimState:ClearOverrideSymbol("swap_face")
- AnimState:ClearOverrideSymbol("face")
- AnimState:Show("HAIR_NOHAT")
- AnimState:Show("HAIR")
- AnimState:Show("HEAD")
- --You'd think at least one of these would work...
- AnimState:ShowSymbol("face")
- AnimState:OverrideSymbol("face", build, "face")
- AnimState:SetSymbolMultColour("face", 1, 1, 1, 1)
- --None of them work...
- -- This crashes the game, for some reason.
- --inst:ShowSkin()
- end
- local function HideBodySlot(AnimState)
- -- idk if this is bad practice but it works?
- AnimState:ClearOverrideSymbol("backpack")
- AnimState:ClearOverrideSymbol("swap_body_tall")
- AnimState:ClearOverrideSymbol("swap_body")
- end
- -- TODO: Determine what exactly `fx` for `alterguardianhat` and `minerhat` contain.
- local function HideItemFx(fx)
- -- If `item.fx` is an entity itself, then we can just remove it directly
- if fx.entity and FX_PREFABS[fx.prefab] then
- fx:Remove()
- return
- elseif fx.entity and not EQUIPSLOTS[fx.prefab] then
- return
- end
- -- Otherwise, `item.fx` is a table of entities
- for _, v in pairs(fx) do
- if v.entity and FX_PREFABS[v.prefab] then
- v:Remove()
- end
- end
- end
- --In case FX still sticks (like with 'lunarplanthat_fx' and 'voidclothhat_fx')
- local function RemovePlayerFX(inst)
- for _, ent in pairs(_G.Ents) do
- if ent and ent.entity and ent.entity:IsValid() and ent.prefab and FX_PREFABS[ent.prefab] then
- -- Check if it's following the player
- if ent.entity:GetParent() == inst and ent.Remove then
- ent:Remove()
- end
- end
- end
- end
- --[[ Hide Main Function ]]
- local function Hide(inst)
- local AnimState = inst.AnimState
- local inv = inst.replica.inventory
- local head_conf, body_conf
- local headslot = inv:GetEquippedItem(EQUIPSLOTS.HEAD)
- if headslot then
- head_conf = ITEM_PREFABS[headslot.prefab]
- end
- local bodyslot = inv:GetEquippedItem(EQUIPSLOTS.BODY)
- if bodyslot then
- body_conf = ITEM_PREFABS[bodyslot.prefab]
- end
- if headslot and head_conf then
- RemovePlayerFX(inst)
- if headslot.fx then
- HideItemFx(headslot.fx)
- end
- HideHeadSlot(inst)
- end
- -- evaluate them separately in case both are equipped
- -- this also allows you to use individual configs for headslots and bodyslots
- if bodyslot and body_conf then
- HideBodySlot(AnimState)
- if bodyslot.fx then
- HideItemFx(bodyslot.fx)
- end
- end
- end
- AddPlayerPostInit(function(inst)
- inst:ListenForEvent("equip", Hide)
- end)
- items_list = nil
Advertisement
Add Comment
Please, Sign In to add comment