コード例 #1
0
 private void RefreshMeter()
 {
     o2_meter.SetPositionPercent(suit_locker.OxygenAvailable);
     fuel_meter.SetPositionPercent(FuelAvailable);
     anim_controller.SetSymbolVisiblity("oxygen_yes_bloom", IsOxygenTankAboveMinimumLevel());
     anim_controller.SetSymbolVisiblity("petrol_yes_bloom", IsFuelTankAboveMinimumLevel());
 }
コード例 #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 void RefreshStorage()
 {
     if (!refreshingStorage)
     {
         refreshingStorage = true;
         float num = 0f;
         foreach (GameObject item in botStorage.items)
         {
             if (!((Object)item == (Object)null))
             {
                 num += item.GetComponent <PrimaryElement>().Mass;
                 int cell  = Grid.PosToCell(smi.transform.GetPosition());
                 int cell2 = Grid.CellBelow(Grid.CellBelow(cell));
                 item.transform.SetPosition(Grid.CellToPosCBC(cell2, Grid.SceneLayer.BuildingBack));
             }
         }
         if (num == 0f)
         {
             float num2 = 0f;
             foreach (GameObject item2 in topStorage.items)
             {
                 if (!((Object)item2 == (Object)null))
                 {
                     num2 += item2.GetComponent <PrimaryElement>().Mass;
                 }
             }
             if (num2 > 0f)
             {
                 anim.SetSymbolVisiblity(HASH_FEEDBALL, true);
                 anim.Play("ball", KAnim.PlayMode.Once, 1f, 0f);
                 Pickupable         pickupable = topStorage.items[0].GetComponent <Pickupable>().Take(massPerBall);
                 KAnim.Build.Symbol symbol     = pickupable.GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build.GetSymbol("algae");
                 if (symbol != null)
                 {
                     anim.GetComponent <SymbolOverrideController>().AddSymbolOverride(HASH_FEEDBALL, symbol, 0);
                 }
                 botStorage.Store(pickupable.gameObject, false, false, true, false);
                 int cell3 = Grid.PosToCell(smi.transform.GetPosition());
                 int cell4 = Grid.CellBelow(Grid.CellBelow(cell3));
                 pickupable.transform.SetPosition(Grid.CellToPosCBC(cell4, Grid.SceneLayer.BuildingUse));
             }
             else
             {
                 anim.SetSymbolVisiblity(HASH_FEEDBALL, false);
             }
         }
         refreshingStorage = false;
     }
 }
コード例 #4
0
    private void SetAnimToInfo()
    {
        GameObject               gameObject = Util.KInstantiate(Assets.GetPrefab("Meter".ToTag()), base.gameObject, null);
        GameObject               prefab     = Assets.GetPrefab(info.id);
        KBatchedAnimController   component  = GetComponent <KBatchedAnimController>();
        KBatchedAnimController   component2 = prefab.GetComponent <KBatchedAnimController>();
        SymbolOverrideController component3 = prefab.GetComponent <SymbolOverrideController>();
        KBatchedAnimController   component4 = gameObject.GetComponent <KBatchedAnimController>();

        component4.transform.SetLocalPosition(Vector3.forward);
        component4.AnimFiles  = component2.AnimFiles;
        component4.isMovable  = true;
        component4.animWidth  = component2.animWidth;
        component4.animHeight = component2.animHeight;
        if ((Object)component3 != (Object)null)
        {
            SymbolOverrideController symbolOverrideController         = SymbolOverrideControllerUtil.AddToPrefab(gameObject);
            SymbolOverrideController.SymbolEntry[] getSymbolOverrides = component3.GetSymbolOverrides;
            for (int i = 0; i < getSymbolOverrides.Length; i++)
            {
                SymbolOverrideController.SymbolEntry symbolEntry = getSymbolOverrides[i];
                symbolOverrideController.AddSymbolOverride(symbolEntry.targetSymbol, symbolEntry.sourceSymbol, 0);
            }
        }
        component4.initialAnim = component2.initialAnim;
        component4.initialMode = KAnim.PlayMode.Loop;
        KBatchedAnimTracker component5 = gameObject.GetComponent <KBatchedAnimTracker>();

        component5.controller = component;
        component5.symbol     = new HashedString("snapTO_object");
        component5.offset     = new Vector3(0f, 0.5f, 0f);
        gameObject.SetActive(true);
        component.SetSymbolVisiblity("snapTO_object", false);
        new KAnimLink(component, component4);
    }
コード例 #5
0
        private void OnStorageChange(object data)
        {
            var ore = storage.FindFirst(MATERIAL_FOR_TINKER);

            if (ore != null)
            {
                var oreAnimFile   = ore.GetComponent <KBatchedAnimController>().CurrentAnim;
                var oreAnimSymbol = oreAnimFile.animFile.build.symbols[0];
                soc.AddSymbolOverride(oreSymbolHash, oreAnimSymbol, 5);
                kbac.SetSymbolVisiblity(oreSymbolHash, true);
            }
            else
            {
                kbac.SetSymbolVisiblity(oreSymbolHash, false);
            }
        }
 public void Sim200ms(float dt)
 {
     if (sampleIdx < 8)
     {
         int i = Grid.PosToCell(this);
         if (Grid.Mass[i] > 0f)
         {
             samples[sampleIdx] = Grid.DiseaseCount[i];
             sampleIdx++;
         }
     }
     else
     {
         sampleIdx = 0;
         float currentValue = CurrentValue;
         if (activateAboveThreshold)
         {
             if ((currentValue > threshold && !base.IsSwitchedOn) || (currentValue <= threshold && base.IsSwitchedOn))
             {
                 Toggle();
             }
         }
         else if ((currentValue > threshold && base.IsSwitchedOn) || (currentValue <= threshold && !base.IsSwitchedOn))
         {
             Toggle();
         }
         animController.SetSymbolVisiblity(TINT_SYMBOL, currentValue > 0f);
     }
 }
コード例 #7
0
        private void OnStorageChanged(object data)
        {
            // inefficient - set the status of every symbol based on its presence
            foreach (Tag tag in ArtifactsFilterTagList)
            {
                anim.SetSymbolVisiblity(tag.ToString(), false);
            }
            foreach (Tag tag in storage.GetAllTagsInStorage())
            {
                anim.SetSymbolVisiblity(tag.ToString(), true);
            }
            // determine appropriate decor amount
            Attributes attributes = this.GetAttributes();

            if (decorModifier.Count > 0)
            {
                foreach (AttributeModifier attr in decorModifier.Values)
                {
                    attributes.Remove(attr);
                }
                decorModifier.Clear();
            }
            // probably need a hashmap from the tag of the artifact to the decor modifier and decor radius modifier for it so I can properly remove
            // and add the components
            foreach (GameObject go in storage.items)
            {
                if (go.GetComponent <DecorProvider>() != null)
                {
                    float  decorValue  = go.GetComponent <PrimaryElement>().Units *Mathf.Max(Db.Get().BuildingAttributes.Decor.Lookup(go).GetTotalValue() * STORED_DECOR_MODIFIER, MINIMUM_DECOR_PER_ITEM);
                    string description = string.Format(STRINGS.BUILDINGS.PREFABS.ITEMPEDESTAL.DISPLAYED_ITEM_FMT, go.GetComponent <KPrefabID>().PrefabTag.ProperName());
                    Tag    prefabTag   = go.GetComponent <KPrefabID>().PrefabTag;
                    if (decorModifier.ContainsKey(prefabTag))
                    {
                        decorModifier[prefabTag].SetValue(decorModifier[prefabTag].Value + decorValue);
                    }
                    else
                    {
                        decorModifier[prefabTag] = new AttributeModifier(Db.Get().BuildingAttributes.Decor.Id, decorValue, description, false, false, true);
                    }
                }
            }
            foreach (AttributeModifier attr in decorModifier.Values)
            {
                attributes.Add(attr);
            }
        }
コード例 #8
0
    private void SetAllowedDirection(WorkableReactable.AllowedDirection new_direction)
    {
        KBatchedAnimController component     = GetComponent <KBatchedAnimController>();
        DirectionInfo          directionInfo = directionInfos[(int)new_direction];
        bool flag        = directionInfo.allowLeft && directionInfo.allowRight;
        bool is_visible  = !flag && directionInfo.allowLeft;
        bool is_visible2 = !flag && directionInfo.allowRight;

        component.SetSymbolVisiblity("arrow2", flag);
        component.SetSymbolVisiblity("arrow_left", is_visible);
        component.SetSymbolVisiblity("arrow_right", is_visible2);
        if (new_direction != allowedDirection)
        {
            allowedDirection = new_direction;
            if (onDirectionChanged != null)
            {
                onDirectionChanged(allowedDirection);
            }
        }
    }
コード例 #9
0
        private void RefreshDepthAvailable()
        {
            bool waterFound;
            int  depthAvailable = GetDepthAvailable(parent, out waterFound);

            if (depthAvailable != previousDepthAvailable || waterFound != previousWaterFound)
            {
                KBatchedAnimController kBatchedAnimController = GetComponent <KBatchedAnimController>();
                if (depthAvailable == 0)
                {
                    kBatchedAnimController.enabled = false;
                }
                else
                {
                    kBatchedAnimController.enabled = true;
                    kBatchedAnimController.Offset  = new Vector3(0, -depthAvailable + 0.35f);
                    for (int i = 1; i <= MaxDepth; i++)
                    {
                        kBatchedAnimController.SetSymbolVisiblity("line" + i.ToString(), i <= depthAvailable);
                        kBatchedAnimController.SetSymbolVisiblity("lineplace" + i.ToString(), i <= depthAvailable);
                    }
                    kBatchedAnimController.sceneLayer = Grid.SceneLayer.BuildingBack;
                    kBatchedAnimController.Play(kBatchedAnimController.initialAnim, KAnim.PlayMode.Loop, 1f, 0f);
                }
                if (occupyTiles)
                {
                    OccupyArea(parent, depthAvailable);
                }
                if (!isPreview)
                {
                    KSelectable kSelectable = parent.GetComponent <KSelectable>();
                    if (kSelectable != null)
                    {
                        kSelectable.ToggleStatusItem(statusItemNoDepth, depthAvailable == 0);
                        kSelectable.ToggleStatusItem(statusItemNoWater, depthAvailable > 0 && !waterFound);
                    }
                }
                previousDepthAvailable = depthAvailable;
                previousWaterFound     = waterFound;
            }
        }
コード例 #10
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        int cell = Grid.PosToCell(base.transform.GetPosition());

        Game.Instance.logicCircuitSystem.AddToNetworks(cell, this, false);
        Subscribe(774203113, OnBuildingBrokenDelegate);
        Subscribe(-1735440190, OnBuildingFullyRepairedDelegate);
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        component.SetSymbolVisiblity(OutlineSymbol, false);
    }
コード例 #11
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);
    }
コード例 #12
0
 private void DisplayDuplicants(RetiredColonyData data, GameObject container, int range_min = -1, int range_max = -1)
 {
     for (int num = container.transform.childCount - 1; num >= 0; num--)
     {
         UnityEngine.Object.DestroyImmediate(container.transform.GetChild(num).gameObject);
     }
     for (int i = 0; i < data.Duplicants.Length; i++)
     {
         if (i < range_min || (i > range_max && range_max != -1))
         {
             GameObject gameObject = new GameObject();
             gameObject.transform.SetParent(container.transform);
         }
         else
         {
             RetiredColonyData.RetiredDuplicantData retiredDuplicantData = data.Duplicants[i];
             GameObject          gameObject2 = Util.KInstantiateUI(duplicantPrefab, container, true);
             HierarchyReferences component   = gameObject2.GetComponent <HierarchyReferences>();
             component.GetReference <LocText>("NameLabel").SetText(retiredDuplicantData.name);
             component.GetReference <LocText>("AgeLabel").SetText(string.Format(UI.RETIRED_COLONY_INFO_SCREEN.DUPLICANT_AGE, retiredDuplicantData.age.ToString()));
             component.GetReference <LocText>("SkillLabel").SetText(string.Format(UI.RETIRED_COLONY_INFO_SCREEN.SKILL_LEVEL, retiredDuplicantData.skillPointsGained.ToString()));
             SymbolOverrideController reference = component.GetReference <SymbolOverrideController>("SymbolOverrideController");
             reference.RemoveAllSymbolOverrides(0);
             KBatchedAnimController componentInChildren = gameObject2.GetComponentInChildren <KBatchedAnimController>();
             componentInChildren.SetSymbolVisiblity("snapTo_neck", false);
             componentInChildren.SetSymbolVisiblity("snapTo_goggles", false);
             componentInChildren.SetSymbolVisiblity("snapTo_hat", false);
             componentInChildren.SetSymbolVisiblity("snapTo_hat_hair", false);
             foreach (KeyValuePair <string, string> accessory in retiredDuplicantData.accessories)
             {
                 KAnim.Build.Symbol symbol        = Db.Get().Accessories.Get(accessory.Value).symbol;
                 AccessorySlot      accessorySlot = Db.Get().AccessorySlots.Get(accessory.Key);
                 reference.AddSymbolOverride(accessorySlot.targetSymbolId, symbol, 0);
                 gameObject2.GetComponentInChildren <KBatchedAnimController>().SetSymbolVisiblity(accessory.Key, true);
             }
             reference.ApplyOverrides();
         }
     }
     StartCoroutine(ActivatePortraitsWhenReady(container));
 }
コード例 #13
0
    public static void ConfigureSymbols(GameObject go)
    {
        KBatchedAnimController component = go.GetComponent <KBatchedAnimController>();

        component.SetSymbolVisiblity("snapto_hat", false);
        component.SetSymbolVisiblity("snapTo_hat_hair", false);
        component.SetSymbolVisiblity("snapto_chest", false);
        component.SetSymbolVisiblity("snapto_neck", false);
        component.SetSymbolVisiblity("snapto_goggles", false);
        component.SetSymbolVisiblity("snapto_pivot", false);
        component.SetSymbolVisiblity("snapTo_rgtHand", false);
    }
コード例 #14
0
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        autoReplaceEntity               = true;
        statusItemNeed                  = Db.Get().BuildingStatusItems.NeedEgg;
        statusItemNoneAvailable         = Db.Get().BuildingStatusItems.NoAvailableEgg;
        statusItemAwaitingDelivery      = Db.Get().BuildingStatusItems.AwaitingEggDelivery;
        requiredSkillPerk               = Db.Get().SkillPerks.CanWrangleCreatures.Id;
        occupyingObjectRelativePosition = new Vector3(0.5f, 1f, -1f);
        synchronizeAnims                = false;
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        component.SetSymbolVisiblity("egg_target", false);
        meter = new MeterController(this, Meter.Offset.Infront, Grid.SceneLayer.NoLayer);
    }
コード例 #15
0
    private static void UpdateScales(Instance smi, float dt)
    {
        int num = (int)((float)smi.def.levelCount * smi.scaleGrowth.value / 100f);

        if (smi.currentScaleLevel != num)
        {
            KBatchedAnimController component = smi.GetComponent <KBatchedAnimController>();
            for (int i = 0; i < SCALE_SYMBOL_NAMES.Length; i++)
            {
                bool is_visible = i <= num - 1;
                component.SetSymbolVisiblity(SCALE_SYMBOL_NAMES[i], is_visible);
            }
            smi.currentScaleLevel = num;
        }
    }
コード例 #16
0
    private void ShowHelmet()
    {
        KBatchedAnimController assigneeController = GetAssigneeController();

        if (!((Object)assigneeController == (Object)null))
        {
            KAnimHashedString kAnimHashedString = new KAnimHashedString("snapTo_neck");
            if (!string.IsNullOrEmpty(anim_file))
            {
                KAnimFile anim = Assets.GetAnim(anim_file);
                assigneeController.GetComponent <SymbolOverrideController>().AddSymbolOverride(kAnimHashedString, anim.GetData().build.GetSymbol(kAnimHashedString), 6);
            }
            assigneeController.SetSymbolVisiblity(kAnimHashedString, true);
            is_shown = true;
            UpdateJets();
        }
    }
コード例 #17
0
 public FishFeederBot(Instance smi, float mass_per_ball, HashedString[] ball_symbols)
 {
     this.smi    = smi;
     massPerBall = mass_per_ball;
     anim        = GameUtil.KInstantiate(Assets.GetPrefab("FishFeederBot"), smi.transform.GetPosition(), Grid.SceneLayer.Front, null, 0).GetComponent <KBatchedAnimController>();
     anim.transform.SetParent(smi.transform);
     anim.gameObject.SetActive(true);
     anim.SetSceneLayer(Grid.SceneLayer.Building);
     anim.Play("ball", KAnim.PlayMode.Once, 1f, 0f);
     anim.Stop();
     foreach (HashedString hash in ball_symbols)
     {
         anim.SetSymbolVisiblity(hash, false);
     }
     Storage[] components = smi.gameObject.GetComponents <Storage>();
     topStorage = components[0];
     botStorage = components[1];
 }
コード例 #18
0
    protected override void OnSpawn()
    {
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        plasticMeter = new MeterController((KAnimControllerBase)component, "meter_target", "meter", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, new Vector3(0f, 0f, 0f), (string[])null);
        oilMeter     = new MeterController((KAnimControllerBase)component, "meter2_target", "meter2", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, new Vector3(0f, 0f, 0f), (string[])null);
        component.SetSymbolVisiblity("meter_target", true);
        float          positionPercent = 0f;
        PrimaryElement primaryElement  = storage.FindPrimaryElement(SimHashes.Petroleum);

        if ((Object)primaryElement != (Object)null)
        {
            positionPercent = Mathf.Clamp01(primaryElement.Mass / consumer.capacityKG);
        }
        oilMeter.SetPositionPercent(positionPercent);
        base.smi.StartSM();
        Subscribe(-1697596308, OnStorageChangedDelegate);
    }
コード例 #19
0
    private void HideHelmet()
    {
        is_shown = false;
        KBatchedAnimController assigneeController = GetAssigneeController();

        if (!((Object)assigneeController == (Object)null))
        {
            KAnimHashedString kAnimHashedString = "snapTo_neck";
            if (!string.IsNullOrEmpty(anim_file))
            {
                SymbolOverrideController component = assigneeController.GetComponent <SymbolOverrideController>();
                if ((Object)component == (Object)null)
                {
                    return;
                }
                component.RemoveSymbolOverride(kAnimHashedString, 6);
            }
            assigneeController.SetSymbolVisiblity(kAnimHashedString, false);
            UpdateJets();
        }
    }
コード例 #20
0
        private void FillFeeder(float mass)
        {
            KBatchedAnimController   component  = smi.GetComponent <KBatchedAnimController>();
            SymbolOverrideController component2 = smi.GetComponent <SymbolOverrideController>();

            KAnim.Build.Symbol symbol     = null;
            Storage            component3 = smi.GetComponent <Storage>();

            if (component3.items.Count > 0 && (Object)component3.items[0] != (Object)null)
            {
                symbol = smi.GetComponent <Storage>().items[0].GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build.GetSymbol("algae");
            }
            for (int i = 0; i < ballSymbols.Length; i++)
            {
                bool is_visible = mass > (float)(i + 1) * massPerBall;
                component.SetSymbolVisiblity(ballSymbols[i], is_visible);
                if (symbol != null)
                {
                    component2.AddSymbolOverride(ballSymbols[i], symbol, 0);
                }
            }
        }
コード例 #21
0
        protected override void OnSpawn()
        {
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.TintColour = new Color(0.5f, 0.5f, 1.0f, 1.0f);
            string name = component.name + ".gun";

            this.arm_go = new GameObject(name);
            this.arm_go.SetActive(value: false);
            this.arm_go.transform.parent = component.transform;
            this.looping_sounds          = this.arm_go.AddComponent <LoopingSounds>();
            this.rotateSound             = GlobalAssets.GetSound(this.rotateSound);
            KPrefabID kPrefabID = this.arm_go.AddComponent <KPrefabID>();

            kPrefabID.PrefabTag          = new Tag(name);
            this.arm_anim_ctrl           = this.arm_go.AddComponent <KBatchedAnimController>();
            this.arm_anim_ctrl.AnimFiles = new KAnimFile[1] {
                component.AnimFiles[0]
            };
            this.arm_anim_ctrl.initialAnim = "gun";
            this.arm_anim_ctrl.isMovable   = true;
            this.arm_anim_ctrl.sceneLayer  = Grid.SceneLayer.TransferArm;
            this.arm_anim_ctrl.TintColour  = new Color(0.5f, 0.5f, 1.0f, 1.0f);
            component.SetSymbolVisiblity("gun_target", is_visible: false);
            bool    symbolVisible;
            Vector4 column   = component.GetSymbolTransform(new HashedString("gun_target"), out symbolVisible).GetColumn(3);
            Vector3 position = column;

            position.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm);
            this.arm_go.transform.SetPosition(position);
            this.arm_go.SetActive(value: true);
            this.link = new KAnimLink(component, this.arm_anim_ctrl);
            this.SetupBeam();
            this.RotateArm(this.rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -this.arm_rot) * Vector3.up), warp: true, 0f);
            this.energyConsumer.UpdatePoweredStatus();
            this.operational.SetActive(true);
            this.selectable.AddStatusItem(charge_status, this);
            this.selectable.AddStatusItem(kills_status, this);
        }
コード例 #22
0
        private KBatchedAnimController AddGuide(KBatchedAnimController parent, string target_symbol, KAnimFile kanim, string animation, bool create_meter)
        {
            var go = new GameObject {
                name = parent.name + "." + animation
            };

            go.SetActive(false);
            go.transform.parent = parent.transform;
            var position = parent.transform.GetPosition();

            position.z = parent.transform.GetPosition().z + 0.1f; // Meter.Offset.Behind
            go.transform.SetPosition(position);
            var kbak = go.AddOrGet <KBatchedAnimController>();

            kbak.AnimFiles       = new KAnimFile[] { kanim ?? parent.AnimFiles[0] };
            kbak.initialAnim     = animation;
            kbak.fgLayer         = Grid.SceneLayer.NoLayer;
            kbak.initialMode     = KAnim.PlayMode.Paused;
            kbak.isMovable       = true;
            kbak.visibilityType  = KAnimControllerBase.VisibilityType.OffscreenUpdate;
            kbak.FlipX           = parent.FlipX;
            kbak.FlipY           = parent.FlipY;
            kbak.TintColour      = parent.TintColour;
            kbak.HighlightColour = parent.HighlightColour;
            if (create_meter)
            {
                var tracker = go.AddOrGet <KBatchedAnimTracker>();
                tracker.symbol            = new HashedString(target_symbol);
                tracker.matchParentOffset = true;
                _ = new MeterController(parent, kbak, target_symbol)
                {
                    gameObject = go
                };
            }
            parent.SetSymbolVisiblity(target_symbol, false);
            go.SetActive(true);
            return(kbak);
        }
コード例 #23
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        SetWorkTime(float.PositiveInfinity);
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        KAnimHashedString[] array = symbol_names;
        foreach (KAnimHashedString symbol in array)
        {
            component.SetSymbolVisiblity(symbol, false);
        }
        Building component2 = GetComponent <Building>();

        powerCell = component2.GetPowerOutputCell();
        OnActiveChanged(null);
        overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_generatormanual_kanim")
        };
        smi = new GeneratePowerSM.Instance(this);
        smi.StartSM();
        Game.Instance.energySim.AddManualGenerator(this);
    }
コード例 #24
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        hitEffectPrefab = Assets.GetPrefab("fx_dig_splash");
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();
        string name = component.name + ".gun";

        arm_go = new GameObject(name);
        arm_go.SetActive(false);
        arm_go.transform.parent = component.transform;
        looping_sounds          = arm_go.AddComponent <LoopingSounds>();
        rotateSound             = GlobalAssets.GetSound(rotateSound, false);
        KPrefabID kPrefabID = arm_go.AddComponent <KPrefabID>();

        kPrefabID.PrefabTag     = new Tag(name);
        arm_anim_ctrl           = arm_go.AddComponent <KBatchedAnimController>();
        arm_anim_ctrl.AnimFiles = new KAnimFile[1]
        {
            component.AnimFiles[0]
        };
        arm_anim_ctrl.initialAnim = "gun";
        arm_anim_ctrl.isMovable   = true;
        arm_anim_ctrl.sceneLayer  = Grid.SceneLayer.TransferArm;
        component.SetSymbolVisiblity("gun_target", false);
        bool    symbolVisible;
        Vector4 column   = component.GetSymbolTransform(new HashedString("gun_target"), out symbolVisible).GetColumn(3);
        Vector3 position = column;

        position.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm);
        arm_go.transform.SetPosition(position);
        arm_go.SetActive(true);
        link = new KAnimLink(component, arm_anim_ctrl);
        Subscribe(-592767678, OnOperationalChangedDelegate);
        RotateArm(rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -45f) * Vector3.up), true, 0f);
        StopDig();
        base.smi.StartSM();
    }
コード例 #25
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);
     }
 }
コード例 #26
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     anim.SetSymbolVisiblity("effect", false);
 }
コード例 #27
0
 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);
     }
 }