Exemplo n.º 1
0
    public static void AddHat(string hat_id, KBatchedAnimController controller)
    {
        AccessorySlot hat       = Db.Get().AccessorySlots.Hat;
        Accessory     accessory = hat.Lookup(hat_id);

        if (accessory == null)
        {
            Debug.LogWarning("Missing hat: " + hat_id);
        }
        Accessorizer component = controller.GetComponent <Accessorizer>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            Accessory accessory2 = component.GetAccessory(Db.Get().AccessorySlots.Hat);
            if (accessory2 != null)
            {
                component.RemoveAccessory(accessory2);
            }
            if (accessory != null)
            {
                component.AddAccessory(accessory);
            }
        }
        else
        {
            SymbolOverrideController component2 = controller.GetComponent <SymbolOverrideController>();
            component2.TryRemoveSymbolOverride(hat.targetSymbolId, 4);
            component2.AddSymbolOverride(hat.targetSymbolId, accessory.symbol, 4);
        }
        controller.SetSymbolVisiblity(hat.targetSymbolId, true);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, true);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, false);
    }
Exemplo n.º 2
0
    public static void RemoveHat(KBatchedAnimController controller)
    {
        AccessorySlot hat       = Db.Get().AccessorySlots.Hat;
        Accessorizer  component = controller.GetComponent <Accessorizer>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            Accessory accessory = component.GetAccessory(hat);
            if (accessory != null)
            {
                component.RemoveAccessory(accessory);
            }
        }
        else
        {
            controller.GetComponent <SymbolOverrideController>().TryRemoveSymbolOverride(hat.targetSymbolId, 4);
        }
        controller.SetSymbolVisiblity(hat.targetSymbolId, false);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, false);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, true);
    }
Exemplo n.º 3
0
 private void SetPortraitAnimator(IAssignableIdentity identity)
 {
     if (identity != null && !identity.IsNull())
     {
         if ((UnityEngine.Object)animController == (UnityEngine.Object)null)
         {
             animController = Util.KInstantiateUI(Assets.GetPrefab(new Tag("FullMinionUIPortrait")), duplicantAnimAnchor.gameObject, false).GetComponent <KBatchedAnimController>();
             animController.gameObject.SetActive(true);
             KCanvasScaler kCanvasScaler = UnityEngine.Object.FindObjectOfType <KCanvasScaler>();
             animController.animScale = baseCharacterScale * (1f / kCanvasScaler.GetCanvasScale());
             ScreenResize instance = ScreenResize.Instance;
             instance.OnResize = (System.Action)Delegate.Combine(instance.OnResize, new System.Action(OnResize));
         }
         string       value     = string.Empty;
         Accessorizer component = animController.GetComponent <Accessorizer>();
         for (int num = component.GetAccessories().Count - 1; num >= 0; num--)
         {
             component.RemoveAccessory(component.GetAccessories()[num].Get());
         }
         MinionIdentity       minionIdentity       = identity as MinionIdentity;
         StoredMinionIdentity storedMinionIdentity = identity as StoredMinionIdentity;
         Accessorizer         accessorizer         = null;
         if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
         {
             accessorizer = minionIdentity.GetComponent <Accessorizer>();
             foreach (ResourceRef <Accessory> accessory in accessorizer.GetAccessories())
             {
                 component.AddAccessory(accessory.Get());
             }
             value = minionIdentity.GetComponent <MinionResume>().CurrentHat;
         }
         else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null)
         {
             foreach (ResourceRef <Accessory> accessory2 in storedMinionIdentity.accessories)
             {
                 component.AddAccessory(accessory2.Get());
             }
             value = storedMinionIdentity.currentHat;
         }
         HashedString name = "anim_idle_healthy_kanim";
         idle_anim = Assets.GetAnim(name);
         if ((UnityEngine.Object)idle_anim != (UnityEngine.Object)null)
         {
             animController.AddAnimOverrides(idle_anim, 0f);
         }
         animController.Queue("idle_default", KAnim.PlayMode.Loop, 1f, 0f);
         AccessorySlot hat = Db.Get().AccessorySlots.Hat;
         animController.SetSymbolVisiblity(hat.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false);
         animController.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, string.IsNullOrEmpty(value) ? true : false);
         animController.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false);
         KAnim.Build.Symbol source_symbol  = null;
         KAnim.Build.Symbol source_symbol2 = null;
         if ((bool)accessorizer)
         {
             source_symbol  = accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol;
             source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol;
         }
         else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null)
         {
             source_symbol  = storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol;
             source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol;
         }
         animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HairAlways.targetSymbolId, source_symbol, 1);
         animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, source_symbol2, 1);
     }
 }