Пример #1
0
    public void Unequip(Equippable equippable)
    {
        AssignableSlotInstance slot = GetSlot(equippable.slot);

        slot.Unassign(true);
        equippable.Trigger(-170173755, this);
        GameObject targetGameObject = GetTargetGameObject();

        if ((bool)targetGameObject)
        {
            targetGameObject.Trigger(-1285462312, equippable.GetComponent <KPrefabID>());
            KBatchedAnimController component = targetGameObject.GetComponent <KBatchedAnimController>();
            if (!destroyed)
            {
                if ((Object)equippable.def.BuildOverride != (Object)null && (Object)component != (Object)null)
                {
                    component.GetComponent <SymbolOverrideController>().TryRemoveBuildOverride(equippable.def.BuildOverride.GetData(), equippable.def.BuildOverridePriority);
                }
                Attributes attributes = targetGameObject.GetAttributes();
                if (attributes != null)
                {
                    foreach (AttributeModifier attributeModifier in equippable.def.AttributeModifiers)
                    {
                        attributes.Remove(attributeModifier);
                    }
                }
                if (!equippable.def.IsBody)
                {
                    SnapOn component2 = targetGameObject.GetComponent <SnapOn>();
                    component2.DetachSnapOnByName(equippable.def.SnapOn);
                    if (equippable.def.SnapOn1 != null)
                    {
                        component2.DetachSnapOnByName(equippable.def.SnapOn1);
                    }
                }
                if ((bool)equippable.transform.parent)
                {
                    Storage component3 = equippable.transform.parent.GetComponent <Storage>();
                    if ((bool)component3)
                    {
                        component3.Drop(equippable.gameObject, true);
                    }
                }
                SetEquippableStoredModifiers(equippable, false);
                equippable.transform.parent = null;
                equippable.transform.SetPosition(targetGameObject.transform.GetPosition() + Vector3.up / 2f);
                KBatchedAnimController component4 = equippable.GetComponent <KBatchedAnimController>();
                if ((bool)component4)
                {
                    component4.SetSceneLayer(Grid.SceneLayer.Ore);
                }
                if (!((Object)component == (Object)null))
                {
                    if (refreshHandle.TimeRemaining > 0f)
                    {
                        refreshHandle.ClearScheduler();
                    }
                    refreshHandle = GameScheduler.Instance.Schedule("ChangeEquipment", 1f, delegate
                    {
                        GameObject gameObject = (!((Object)this != (Object)null)) ? null : GetTargetGameObject();
                        if ((bool)gameObject)
                        {
                            CreatureSimTemperatureTransfer component5 = gameObject.GetComponent <CreatureSimTemperatureTransfer>();
                            if ((Object)component5 != (Object)null)
                            {
                                component5.RefreshRegistration();
                            }
                        }
                    }, null, null);
                }
            }
            Game.Instance.Trigger(-2146166042, null);
        }
    }