local assets=
{
    Asset("ANIM", "anim/galientsword.zip"),
    Asset("ANIM", "anim/swap_galientsword.zip"),
  
    Asset("ATLAS", "images/inventoryimages/galientsword.xml"),
    Asset("IMAGE", "images/inventoryimages/galientsword.tex"),
}




local function OnEquip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_galientsword", "swap_galientsword")
    owner.AnimState:Show("ARM_carry")
    owner.AnimState:Hide("ARM_normal")
     local light2 = inst.entity:AddLight()
    light2:SetFalloff(.3)
    light2:SetIntensity(.8)
    light2:SetRadius(3)
    light2:Enable(true)
    light2:SetColour(255/255, 88/255, 112/255)   
end

local function onattack_galient(inst, attacker, data)



       local x, y, z = inst.Transform:GetWorldPosition()
        if attacker then
    --SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get())
        -- SpawnPrefab("collapse_big").Transform:SetPosition(inst:GetPosition():Get())
        -- SpawnPrefab("caster_ring_fx").Transform:SetPosition(inst:GetPosition():Get())
       SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get())

      for aaa = x-6, x+6, 1 do
        SpawnPrefab("caster_ring_fx").Transform:SetPosition(aaa,y,z-6)
        SpawnPrefab("caster_ring_fx").Transform:SetPosition(aaa,y,z+6)
      end
      for bbb = z-6, z+6, 1 do
        SpawnPrefab("caster_ring_fx").Transform:SetPosition(x-6,y,bbb)
        SpawnPrefab("caster_ring_fx").Transform:SetPosition(x+6,y,bbb)
      end

     end
 

   inst.components.finiteuses:Use(1)
end

  
local function OnUnequip(inst, owner)
    owner.AnimState:Hide("ARM_carry")
    owner.AnimState:Show("ARM_normal")
     local light2 = inst.entity:AddLight()
    light2:SetFalloff(.3)
    light2:SetIntensity(.8)
    light2:SetRadius(3)
    light2:Enable(true)
    light2:SetColour(255/255, 88/255, 112/255)   
end

--local function linkToBuilder(inst, builder)
	-- sound and anim reactions
	--if builder then
	--	SpawnPrefab("mossling_spin_fx").Transform:SetPosition(inst:GetPosition():Get())
	--end
--end
 
local function fn()
  
    local inst = CreateEntity()
 
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()
	inst.entity:AddMiniMapEntity()
     
    MakeInventoryPhysics(inst)   
      
    inst.AnimState:SetBank("galientsword")
    inst.AnimState:SetBuild("galientsword")
    inst.AnimState:PlayAnimation("idle")
	
    inst.MiniMapEntity:SetIcon("galientsword.tex")
 
    inst:AddTag("sharp")
 
    if not TheWorld.ismastersim then
        return inst
    end
 
    inst.entity:SetPristine()
     
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(500)
	inst.components.weapon:SetOnAttack(onattack_galient)
  
    inst:AddComponent("inspectable")
      
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "galientsword"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/galientsword.xml"
		      
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

        inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(150)
    inst.components.finiteuses:SetUses(150)

    inst.components.finiteuses:SetOnFinished(inst.Remove)
	
    --if not inst.components.characterspecific then
  --  inst:AddComponent("characterspecific")
--end
 
   -- inst.components.characterspecific:SetOwner("archer")
   -- inst.components.characterspecific:SetStorable(true)
    --inst.components.characterspecific:SetComment("I don't feel safe near this...") 


	--inst.OnBuilt = linkToBuilder
     
    return inst
end
return  Prefab("common/inventory/ea", fn, assets) 