コード例 #1
0
    private void UpdateVisualState(bool force = false)
    {
        bool flag = CurrentValue > threshold;

        if (flag != was_pressed || was_on != base.IsSwitchedOn || force)
        {
            KBatchedAnimController component = GetComponent <KBatchedAnimController>();
            if (flag)
            {
                if (force)
                {
                    component.Play((!base.IsSwitchedOn) ? "off_down" : "on_down", KAnim.PlayMode.Once, 1f, 0f);
                }
                else
                {
                    component.Play((!base.IsSwitchedOn) ? "off_down_pre" : "on_down_pre", KAnim.PlayMode.Once, 1f, 0f);
                    component.Queue((!base.IsSwitchedOn) ? "off_down" : "on_down", KAnim.PlayMode.Once, 1f, 0f);
                }
            }
            else if (force)
            {
                component.Play((!base.IsSwitchedOn) ? "off_up" : "on_up", KAnim.PlayMode.Once, 1f, 0f);
            }
            else
            {
                component.Play((!base.IsSwitchedOn) ? "off_up_pre" : "on_up_pre", KAnim.PlayMode.Once, 1f, 0f);
                component.Queue((!base.IsSwitchedOn) ? "off_up" : "on_up", KAnim.PlayMode.Once, 1f, 0f);
            }
            was_pressed = flag;
            was_on      = base.IsSwitchedOn;
        }
    }
コード例 #2
0
 private void OnOperationalChanged(object data)
 {
     if ((bool)data)
     {
         kbac.Queue("on_pre");
         kbac.Queue("on");
     }
     else
     {
         kbac.Queue("on_pst");
         kbac.Queue("off");
     }
 }
コード例 #3
0
    private void UpdateVisualization()
    {
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        component.Play((!switchedOn) ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0f);
        component.Queue((!switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
    }
コード例 #4
0
        private void UpdateVisualization()
        {
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.Play((HashedString)(this.switchedOn ? "on_pre" : "on_pst"), KAnim.PlayMode.Once, 1f, 0.0f);
            component.Queue((HashedString)(this.switchedOn ? "on" : "off"), KAnim.PlayMode.Once, 1f, 0.0f);
        }
コード例 #5
0
        private static void PlayRancherWorkingLoops(Instance smi)
        {
            KBatchedAnimController kBatchedAnimController = smi.sm.rancher.Get <KBatchedAnimController>(smi);

            for (int i = 0; i < smi.ranchStation.def.interactLoopCount; i++)
            {
                kBatchedAnimController.Queue("working_loop", KAnim.PlayMode.Once, 1f, 0f);
            }
        }
コード例 #6
0
 private void UpdateVisualState(bool force = false)
 {
     if (wasOn != switchedOn || force)
     {
         wasOn = switchedOn;
         KBatchedAnimController component = GetComponent<KBatchedAnimController>();
         component.Play((!switchedOn) ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0f);
         component.Queue((!switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
     }
 }
コード例 #7
0
    public void Sim200ms(float dt)
    {
        float    num      = kjConsumptionRate * dt;
        Vector2I vector2I = maxCheckOffset - minCheckOffset + 1;
        int      num2     = vector2I.x * vector2I.y;
        float    num3     = num / (float)num2;

        Grid.PosToXY(base.transform.GetPosition(), out int x, out int y);
        for (int i = minCheckOffset.y; i <= maxCheckOffset.y; i++)
        {
            for (int j = minCheckOffset.x; j <= maxCheckOffset.x; j++)
            {
                int num4 = Grid.XYToCell(x + j, y + i);
                if (Grid.IsValidCell(num4) && Grid.Temperature[num4] > minTemperature)
                {
                    kjConsumed += num3;
                    SimMessages.ModifyEnergy(num4, 0f - num3, 5000f, SimMessages.EnergySourceID.HeatBulb);
                }
            }
        }
        float num5 = lightKJConsumptionRate * dt;

        if (kjConsumed > num5)
        {
            if (!lightSource.enabled)
            {
                kanim.Play("open", KAnim.PlayMode.Once, 1f, 0f);
                kanim.Queue("on", KAnim.PlayMode.Once, 1f, 0f);
                lightSource.enabled = true;
            }
            kjConsumed -= num5;
        }
        else
        {
            if (lightSource.enabled)
            {
                kanim.Play("close", KAnim.PlayMode.Once, 1f, 0f);
                kanim.Queue("off", KAnim.PlayMode.Once, 1f, 0f);
            }
            lightSource.enabled = false;
        }
    }
コード例 #8
0
        protected override void InternalBegin()
        {
            reactor_navigator = reactor.GetComponent <Navigator>();
            KBatchedAnimController component = reactor.GetComponent <KBatchedAnimController>();

            component.AddAnimOverrides(Assets.GetAnim("anim_idle_distracted_kanim"), 1f);
            component.Play("idle_pre", KAnim.PlayMode.Once, 1f, 0f);
            component.Queue("idle_default", KAnim.PlayMode.Loop, 1f, 0f);
            checkpoint.OrphanReactable();
            checkpoint.CreateNewReactable();
        }
コード例 #9
0
        private void UpdateVisualState(bool force = false)
        {
            if (!(this.wasOn != this.switchedOn | force))
            {
                return;
            }
            this.wasOn = this.switchedOn;
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.Play((HashedString)(this.switchedOn ? "on_pre" : "on_pst"));
            component.Queue((HashedString)(this.switchedOn ? "on" : "off"));
        }
コード例 #10
0
        private void UpdateVisualState(bool force = false)
        {
            if (this.wasOn == this.switchedOn && !force)
            {
                return;
            }
            this.wasOn = this.switchedOn;
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.Play((HashedString)(!this.switchedOn ? "on_pst" : "on_pre"), KAnim.PlayMode.Once, 1f, 0.0f);
            component.Queue((HashedString)(!this.switchedOn ? "off" : "on"), KAnim.PlayMode.Once, 1f, 0.0f);
        }
コード例 #11
0
    private void UpdateVisualState(bool force = false)
    {
        if (this.wasOn == base.switchedOn && !force)
        {
            return;
        }
        this.wasOn = base.switchedOn;
        KBatchedAnimController component = base.GetComponent <KBatchedAnimController>();

        component.Play((!base.switchedOn) ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0f);
        component.Queue((!base.switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
    }
コード例 #12
0
        private void UpdateVisualState(bool force)
        {
            if (wasOn == switchedOn && !force)
            {
                return;
            }

            wasOn = switchedOn;

            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.Play(!this.switchedOn ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0.0f);
            component.Queue(!this.switchedOn ? "off" : "on", KAnim.PlayMode.Once, 1f, 0.0f);
        }
コード例 #13
0
    private void SetAnimator()
    {
        if ((UnityEngine.Object)animController == (UnityEngine.Object)null)
        {
            animController = Util.KInstantiateUI(Assets.GetPrefab(new Tag("MinionSelectPreview")), contentBody.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));
            Transform transform = animController.transform.parent.gameObject.transform.Find("BG");
            KBatchedAnimController kBatchedAnimController = (!((UnityEngine.Object)transform != (UnityEngine.Object)null)) ? null : transform.gameObject.GetComponent <KBatchedAnimController>();
            if ((UnityEngine.Object)kBatchedAnimController != (UnityEngine.Object)null)
            {
                kBatchedAnimController.animScale = baseCharacterScale * (1f / kCanvasScaler.GetCanvasScale());
            }
        }
        stats.ApplyTraits(animController.gameObject);
        stats.ApplyRace(animController.gameObject);
        stats.ApplyAccessories(animController.gameObject);
        stats.ApplyExperience(animController.gameObject);
        HashedString name = idleAnims[UnityEngine.Random.Range(0, idleAnims.Length)];

        idle_anim = Assets.GetAnim(name);
        if ((UnityEngine.Object)idle_anim != (UnityEngine.Object)null)
        {
            animController.AddAnimOverrides(idle_anim, 0f);
        }
        HashedString name2 = new HashedString("crewSelect_fx_kanim");
        KAnimFile    anim  = Assets.GetAnim(name2);

        if ((UnityEngine.Object)anim != (UnityEngine.Object)null)
        {
            animController.AddAnimOverrides(anim, 0f);
        }
        animController.Queue("idle_default", KAnim.PlayMode.Loop, 1f, 0f);
    }
コード例 #14
0
    private void OnStartedTalking(object data)
    {
        ConversationManager.StartedTalkingEvent startedTalkingEvent = (ConversationManager.StartedTalkingEvent)data;
        GameObject talker = startedTalkingEvent.talker;

        if ((Object)talker == (Object)base.worker.gameObject)
        {
            KBatchedAnimController component = base.worker.GetComponent <KBatchedAnimController>();
            string anim = startedTalkingEvent.anim;
            anim += Random.Range(1, 9).ToString();
            component.Play(anim, KAnim.PlayMode.Once, 1f, 0f);
            component.Queue("idle", KAnim.PlayMode.Loop, 1f, 0f);
        }
        else
        {
            Facing component2 = base.worker.GetComponent <Facing>();
            component2.Face(talker.transform.GetPosition());
            lastTalker = talker;
        }
    }
コード例 #15
0
 private void UpdateCircuit(bool should_update_anim = true)
 {
     if ((UnityEngine.Object)attachedWire != (UnityEngine.Object)null)
     {
         if (switchedOn)
         {
             attachedWire.Connect();
         }
         else
         {
             attachedWire.Disconnect();
         }
     }
     if (should_update_anim && wasOn != switchedOn)
     {
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         component.Play((!switchedOn) ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0f);
         component.Queue((!switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
         Game.Instance.userMenu.Refresh(base.gameObject);
     }
     wasOn = switchedOn;
 }
コード例 #16
0
 public void PlayAnims()
 {
     if (base.def.anims != null && base.def.anims.Length != 0)
     {
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         for (int i = 0; i < base.def.anims.Length; i++)
         {
             KAnim.PlayMode mode = KAnim.PlayMode.Once;
             if (base.def.loop && i == base.def.anims.Length - 1)
             {
                 mode = KAnim.PlayMode.Loop;
             }
             if (i == 0)
             {
                 component.Play(base.def.anims[i], mode, 1f, 0f);
             }
             else
             {
                 component.Queue(base.def.anims[i], mode, 1f, 0f);
             }
         }
     }
 }
コード例 #17
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);
     }
 }