public void ApplyShape()
    {
        KBatchedAnimController component  = GetComponent <KBatchedAnimController>();
        Accessorizer           component2 = GetComponent <Accessorizer>();
        KAnimFile anim = Assets.GetAnim("head_master_swap_kanim");
        bool      should_use_sideways_symbol = ShouldUseSidewaysSymbol(component);

        BlinkMonitor.Instance sMI = component2.GetSMI <BlinkMonitor.Instance>();
        if (sMI.IsNullOrStopped() || !sMI.IsBlinking())
        {
            Accessory          accessory = component2.GetAccessory(Db.Get().AccessorySlots.Eyes);
            KAnim.Build.Symbol symbol    = accessory.symbol;
            ApplyShape(symbol, component, anim, "snapto_eyes", should_use_sideways_symbol);
        }
        SpeechMonitor.Instance sMI2 = component2.GetSMI <SpeechMonitor.Instance>();
        if (sMI2.IsNullOrStopped() || !sMI2.IsPlayingSpeech())
        {
            Accessory          accessory2 = component2.GetAccessory(Db.Get().AccessorySlots.Mouth);
            KAnim.Build.Symbol symbol2    = accessory2.symbol;
            ApplyShape(symbol2, component, anim, "snapto_mouth", should_use_sideways_symbol);
        }
        else
        {
            sMI2.DrawMouth();
        }
    }
예제 #2
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);
    }
예제 #3
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);
    }
 public static void SetPortraitData(IAssignableIdentity identityObject, KBatchedAnimController controller, bool useDefaultExpression = true)
 {
     if (identityObject == null)
     {
         controller.gameObject.SetActive(false);
     }
     else
     {
         MinionIdentity minionIdentity = identityObject as MinionIdentity;
         if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null)
         {
             MinionAssignablesProxy minionAssignablesProxy = identityObject as MinionAssignablesProxy;
             if ((UnityEngine.Object)minionAssignablesProxy != (UnityEngine.Object)null && minionAssignablesProxy.target != null)
             {
                 minionIdentity = (minionAssignablesProxy.target as MinionIdentity);
             }
         }
         controller.gameObject.SetActive(true);
         controller.Play("ui_idle", KAnim.PlayMode.Once, 1f, 0f);
         SymbolOverrideController component = controller.GetComponent <SymbolOverrideController>();
         component.RemoveAllSymbolOverrides(0);
         if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
         {
             Accessorizer component2 = minionIdentity.GetComponent <Accessorizer>();
             foreach (AccessorySlot resource in Db.Get().AccessorySlots.resources)
             {
                 Accessory accessory = component2.GetAccessory(resource);
                 if (accessory != null)
                 {
                     component.AddSymbolOverride(resource.targetSymbolId, accessory.symbol, 0);
                     controller.SetSymbolVisiblity(resource.targetSymbolId, true);
                 }
             }
             component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(component2.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1);
             RefreshHat(minionIdentity, controller);
         }
         else
         {
             StoredMinionIdentity storedMinionIdentity = identityObject as StoredMinionIdentity;
             if ((UnityEngine.Object)storedMinionIdentity == (UnityEngine.Object)null)
             {
                 MinionAssignablesProxy minionAssignablesProxy2 = identityObject as MinionAssignablesProxy;
                 if ((UnityEngine.Object)minionAssignablesProxy2 != (UnityEngine.Object)null && minionAssignablesProxy2.target != null)
                 {
                     storedMinionIdentity = (minionAssignablesProxy2.target as StoredMinionIdentity);
                 }
             }
             if (!((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null))
             {
                 controller.gameObject.SetActive(false);
                 return;
             }
             foreach (AccessorySlot resource2 in Db.Get().AccessorySlots.resources)
             {
                 Accessory accessory2 = storedMinionIdentity.GetAccessory(resource2);
                 if (accessory2 != null)
                 {
                     component.AddSymbolOverride(resource2.targetSymbolId, accessory2.symbol, 0);
                     controller.SetSymbolVisiblity(resource2.targetSymbolId, true);
                 }
             }
             component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1);
             RefreshHat(storedMinionIdentity, controller);
         }
         float animScale = 1f;
         if ((UnityEngine.Object)GameScreenManager.Instance != (UnityEngine.Object)null && (UnityEngine.Object)GameScreenManager.Instance.ssOverlayCanvas != (UnityEngine.Object)null)
         {
             animScale = 0.2f * (1f / GameScreenManager.Instance.ssOverlayCanvas.GetComponent <KCanvasScaler>().GetUserScale());
         }
         controller.animScale = animScale;
         string s = "ui";
         controller.Play(s, KAnim.PlayMode.Loop, 1f, 0f);
         controller.SetSymbolVisiblity("snapTo_neck", false);
         controller.SetSymbolVisiblity("snapTo_goggles", false);
     }
 }
예제 #5
0
    protected override void OnSpawn()
    {
        if (addToIdentityList)
        {
            ValidateProxy();
            CleanupLimboMinions();
        }
        PathProber component = GetComponent <PathProber>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetGroupProber(MinionGroupProber.Get());
        }
        SetName(name);
        if (nameStringKey == null)
        {
            nameStringKey = name;
        }
        SetGender(gender);
        if (genderStringKey == null)
        {
            genderStringKey = "NB";
        }
        if (addToIdentityList)
        {
            Components.MinionIdentities.Add(this);
            if (!base.gameObject.HasTag(GameTags.Dead))
            {
                Components.LiveMinionIdentities.Add(this);
            }
        }
        SymbolOverrideController component2 = GetComponent <SymbolOverrideController>();

        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            Accessorizer component3 = base.gameObject.GetComponent <Accessorizer>();
            if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
            {
                bodyData = default(KCompBuilder.BodyData);
                component3.GetBodySlots(ref bodyData);
                string text = HashCache.Get().Get(component3.GetAccessory(Db.Get().AccessorySlots.HeadShape).symbol.hash);
                string str  = text.Replace("headshape", "cheek");
                component2.AddSymbolOverride("snapto_cheek", Assets.GetAnim("head_swap_kanim").GetData().build.GetSymbol(str), 1);
                component2.AddSymbolOverride(Db.Get().AccessorySlots.HairAlways.targetSymbolId, component3.GetAccessory(Db.Get().AccessorySlots.Hair).symbol, 1);
                component2.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(component3.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1);
            }
        }
        voiceId  = "0";
        voiceId += (voiceIdx + 1).ToString();
        Prioritizable component4 = GetComponent <Prioritizable>();

        if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            component4.showIcon = false;
        }
        Pickupable component5 = GetComponent <Pickupable>();

        if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
        {
            component5.carryAnimOverride = Assets.GetAnim("anim_incapacitated_carrier_kanim");
        }
        ApplyCustomGameSettings();
    }
예제 #6
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);
     }
 }