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 void AddBuildSymbol(KAnim.Build.Symbol symbol)
 {
     if (!frameElementSymbolIndices.ContainsKey(symbol.hash))
     {
         frameElementSymbolIndices.Add(symbol.hash, frameElementSymbols.Count);
     }
     frameElementSymbols.Add(symbol);
 }
示例#3
0
 public override void UpdateHidden()
 {
     for (int i = 0; i < base.curBuild.symbols.Length; i++)
     {
         KAnim.Build.Symbol symbol = base.curBuild.symbols[i];
         bool is_visible           = !hiddenSymbols.Contains(symbol.hash);
         base.symbolInstanceGpuData.SetVisible(i, is_visible);
     }
     SetDirty();
 }
示例#4
0
 public void SetSymbolTint(KAnimHashedString symbol_name, Color color)
 {
     KAnim.Build.Symbol symbol = KAnimBatchManager.Instance().GetBatchGroupData(GetBatchGroupID(false)).GetSymbol(symbol_name);
     if (symbol != null)
     {
         base.symbolInstanceGpuData.SetSymbolTint(symbol.symbolIndexInSourceBuild, color);
         SuspendUpdates(false);
         SetDirty();
     }
 }
示例#5
0
    public void WriteAnimData(int start_index, float[] data)
    {
        List <KAnim.Anim.Frame>        animFrames        = GetAnimFrames();
        List <KAnim.Anim.FrameElement> animFrameElements = GetAnimFrameElements();
        int num = 1 + ((animFrames.Count != 0) ? animFrames.Count : symbolFrameInstances.Count);

        if (animFrames.Count == 0 && symbolFrameInstances.Count == 0 && animFrameElements.Count == 0)
        {
            Debug.LogError("Eh, no data " + animFrames.Count + " " + symbolFrameInstances.Count + " " + animFrameElements.Count);
        }
        data[start_index++] = (float)num;
        data[start_index++] = (float)animFrames.Count;
        data[start_index++] = (float)animFrameElements.Count;
        data[start_index++] = (float)symbolFrameInstances.Count;
        if (animFrames.Count == 0)
        {
            for (int i = 0; i < symbolFrameInstances.Count; i++)
            {
                WriteAnimFrame(data, start_index, i, i, 1, i);
                start_index += 4;
            }
            for (int j = 0; j < symbolFrameInstances.Count; j++)
            {
                WriteAnimFrameElement(data, start_index, j, j, Matrix2x3.identity, Color.white, 0);
                start_index += 16;
            }
        }
        else
        {
            for (int k = 0; k < animFrames.Count; k++)
            {
                Write(data, start_index, k, animFrames[k]);
                start_index += 4;
            }
            for (int l = 0; l < animFrameElements.Count; l++)
            {
                KAnim.Anim.FrameElement element = animFrameElements[l];
                if (element.symbol == KGlobalAnimParser.MISSING_SYMBOL)
                {
                    WriteAnimFrameElement(data, start_index, -1, l, Matrix2x3.identity, Color.white, 0);
                }
                else
                {
                    KAnim.Build.Symbol buildSymbol = GetBuildSymbol(element.symbolIdx);
                    if (buildSymbol == null)
                    {
                        Debug.LogError("Missing symbol for Anim Frame Element: [" + HashCache.Get().Get(element.symbol) + ": " + element.symbol + "]");
                    }
                    int frameIdx = buildSymbol.GetFrameIdx(element.frame);
                    Write(data, start_index, frameIdx, l, element);
                }
                start_index += 16;
            }
        }
    }
    private void ApplyShape(KAnim.Build.Symbol variation_symbol, KBatchedAnimController controller, KAnimFile shapes_file, HashedString symbol_name_in_shape_file, bool should_use_sideways_symbol)
    {
        HashedString hashedString = HASH_NEUTRAL;

        if (currentExpression != null)
        {
            hashedString = currentExpression.face.hash;
        }
        KAnim.Anim anim = null;
        KAnim.Anim.FrameElement frameElement = default(KAnim.Anim.FrameElement);
        bool flag  = false;
        bool flag2 = false;

        for (int i = 0; i < shapes_file.GetData().animCount; i++)
        {
            if (flag)
            {
                break;
            }
            KAnim.Anim anim2 = shapes_file.GetData().GetAnim(i);
            if (anim2.hash == hashedString)
            {
                anim = anim2;
                KAnim.Anim.Frame frame = anim.GetFrame(shapes_file.GetData().build.batchTag, 0);
                for (int j = 0; j < frame.numElements; j++)
                {
                    KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(shapes_file.GetData().animBatchTag);
                    frameElement = batchGroupData.GetFrameElement(frame.firstElementIdx + j);
                    if (!(frameElement.symbol != symbol_name_in_shape_file))
                    {
                        if (flag2 || !should_use_sideways_symbol)
                        {
                            flag = true;
                        }
                        flag2 = true;
                        break;
                    }
                }
            }
        }
        if (anim == null)
        {
            DebugUtil.Assert(false, "Could not find shape for expression: " + HashCache.Get().Get(hashedString));
        }
        if (!flag2)
        {
            DebugUtil.Assert(false, "Could not find shape element for shape:" + HashCache.Get().Get(variation_symbol.hash));
        }
        KAnim.Build.Symbol symbol          = KAnimBatchManager.Instance().GetBatchGroupData(controller.batchGroupID).GetSymbol(symbol_name_in_shape_file);
        KBatchGroupData    batchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(variation_symbol.build.batchTag);

        KAnim.Build.SymbolFrameInstance symbol_frame_instance = batchGroupData2.symbolFrameInstances[variation_symbol.firstFrameIdx + frameElement.frame];
        symbol_frame_instance.buildImageIdx = GetComponent <SymbolOverrideController>().GetAtlasIdx(variation_symbol.build.GetTexture(0));
        controller.SetSymbolOverride(symbol.firstFrameIdx, symbol_frame_instance);
    }
示例#7
0
    private static void AddMouthOverride(Instance smi)
    {
        SymbolOverrideController component  = smi.GetComponent <SymbolOverrideController>();
        KBatchedAnimController   component2 = smi.GetComponent <KBatchedAnimController>();

        KAnim.Build.Symbol symbol = component2.AnimFiles[0].GetData().build.GetSymbol("sq_mouth_cheeks");
        if (symbol != null)
        {
            component.AddSymbolOverride("sq_mouth", symbol, 0);
        }
    }
        public void LayEgg()
        {
            fertility.value = 0f;
            Vector3 position = base.smi.transform.GetPosition();

            position.z = Grid.GetLayerZ(Grid.SceneLayer.Ore);
            float num     = UnityEngine.Random.value;
            Tag   invalid = Tag.Invalid;

            foreach (BreedingChance breedingChance in breedingChances)
            {
                num -= breedingChance.weight;
                if (num <= 0f)
                {
                    invalid = breedingChance.egg;
                    break;
                }
            }
            if (GenericGameSettings.instance.acceleratedLifecycle)
            {
                float num2 = 0f;
                foreach (BreedingChance breedingChance2 in breedingChances)
                {
                    if (breedingChance2.weight > num2)
                    {
                        num2    = breedingChance2.weight;
                        invalid = breedingChance2.egg;
                    }
                }
            }
            Debug.Assert(invalid != Tag.Invalid, "Didn't pick an egg to lay. Weights weren't normalized?");
            GameObject prefab     = Assets.GetPrefab(invalid);
            GameObject gameObject = egg = Util.KInstantiate(prefab, position);
            SymbolOverrideController component = GetComponent <SymbolOverrideController>();
            string str = "egg01";

            IncubationMonitor.Def def        = prefab.GetDef <IncubationMonitor.Def>();
            CreatureBrain         component2 = Assets.GetPrefab(def.spawnedCreature).GetComponent <CreatureBrain>();

            if (!string.IsNullOrEmpty(component2.symbolPrefix))
            {
                str = component2.symbolPrefix + "egg01";
            }
            KAnim.Build.Symbol symbol = egg.GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build.GetSymbol(str);
            if (symbol != null)
            {
                component.AddSymbolOverride(targetEggSymbol, symbol, 0);
            }
            Trigger(1193600993, egg);
        }
 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;
     }
 }
示例#10
0
    private static KAnim.Build.Symbol GetSymbol(KAnimFile anim_file, string symbol_name)
    {
        KAnim.Build.Symbol result = anim_file.GetData().build.symbols[0];
        KAnimHashedString  y      = new KAnimHashedString(symbol_name);

        KAnim.Build.Symbol[] symbols = anim_file.GetData().build.symbols;
        foreach (KAnim.Build.Symbol symbol in symbols)
        {
            if (symbol.hash == y)
            {
                result = symbol;
                break;
            }
        }
        return(result);
    }
示例#11
0
    private void DoAttachSnapOn(SnapPoint point)
    {
        OverrideEntry value       = null;
        KAnimFile     buildFile   = point.buildFile;
        string        symbol_name = string.Empty;

        if (overrideMap.TryGetValue(point.pointName, out value))
        {
            buildFile   = value.buildFile;
            symbol_name = value.symbolName;
        }
        KAnim.Build.Symbol       symbol    = GetSymbol(buildFile, symbol_name);
        SymbolOverrideController component = GetComponent <SymbolOverrideController>();

        component.AddSymbolOverride(point.overrideSymbol, symbol, 5);
        kanimController.SetSymbolVisiblity(point.overrideSymbol, true);
    }
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = idle;
     idle.ToggleMainStatusItem(Db.Get().BuildingStatusItems.Baited).Enter(delegate(StatesInstance smi)
     {
         Element element                    = ElementLoader.FindElementByName(smi.master.baitElement.ToString());
         KAnim.Build build                  = element.substance.anim.GetData().build;
         KAnim.Build.Symbol symbol          = build.GetSymbol(new KAnimHashedString(build.name));
         HashedString target_symbol         = "snapTo_bait";
         SymbolOverrideController component = smi.GetComponent <SymbolOverrideController>();
         component.AddSymbolOverride(target_symbol, symbol, 0);
     }).TagTransition(GameTags.LureUsed, destroy, false);
     destroy.PlayAnim("use").EventHandler(GameHashes.AnimQueueComplete, delegate(StatesInstance smi)
     {
         Util.KDestroyGameObject(smi.master.gameObject);
     });
 }
示例#13
0
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = idle;
     idle.PlayAnim("off", KAnim.PlayMode.Loop).Enter(delegate(StatesInstance smi)
     {
         if (smi.master.activeBaitSetting != Tag.Invalid)
         {
             if (smi.master.baitStorage.IsEmpty())
             {
                 smi.master.CreateFetchChore();
             }
             else if (smi.master.operational.IsOperational)
             {
                 smi.GoTo(working);
             }
         }
     }).EventTransition(GameHashes.OnStorageChange, working, (StatesInstance smi) => !smi.master.baitStorage.IsEmpty() && smi.master.activeBaitSetting != Tag.Invalid && smi.master.operational.IsOperational)
     .EventTransition(GameHashes.OperationalChanged, working, (StatesInstance smi) => !smi.master.baitStorage.IsEmpty() && smi.master.activeBaitSetting != Tag.Invalid && smi.master.operational.IsOperational);
     working.Enter(delegate(StatesInstance smi)
     {
         smi.master.GetComponent <KSelectable>().RemoveStatusItem(Db.Get().BuildingStatusItems.AwaitingBaitDelivery, false);
         HashedString batchTag              = ElementLoader.FindElementByName(smi.master.activeBaitSetting.ToString()).substance.anim.batchTag;
         KAnim.Build build                  = ElementLoader.FindElementByName(smi.master.activeBaitSetting.ToString()).substance.anim.GetData().build;
         KAnim.Build.Symbol symbol          = build.GetSymbol(new KAnimHashedString(build.name));
         HashedString target_symbol         = "slime_mold";
         SymbolOverrideController component = smi.GetComponent <SymbolOverrideController>();
         component.TryRemoveSymbolOverride(target_symbol, 0);
         component.AddSymbolOverride(target_symbol, symbol, 0);
         smi.GetSMI <Lure.Instance>().SetActiveLures(new Tag[1]
         {
             smi.master.activeBaitSetting
         });
     }).Exit(ClearBait).QueueAnim("working_pre", false, null)
     .QueueAnim("working_loop", true, null)
     .EventTransition(GameHashes.OnStorageChange, empty, (StatesInstance smi) => smi.master.baitStorage.IsEmpty() && smi.master.activeBaitSetting != Tag.Invalid)
     .EventTransition(GameHashes.OperationalChanged, idle, (StatesInstance smi) => !smi.master.operational.IsOperational && !smi.master.baitStorage.IsEmpty());
     empty.QueueAnim("working_pst", false, null).QueueAnim("off", false, null).Enter(delegate(StatesInstance smi)
     {
         smi.master.CreateFetchChore();
     })
     .EventTransition(GameHashes.OnStorageChange, working, (StatesInstance smi) => !smi.master.baitStorage.IsEmpty() && smi.master.operational.IsOperational)
     .EventTransition(GameHashes.OperationalChanged, working, (StatesInstance smi) => !smi.master.baitStorage.IsEmpty() && smi.master.operational.IsOperational);
 }
示例#14
0
 private void Write(float[] data, int startIndex, int thisFrameIndex, int atlasIndex, KAnim.Build.SymbolFrameInstance symbol_frame_instance)
 {
     data[startIndex++] = (float)atlasIndex;
     data[startIndex++] = (float)thisFrameIndex;
     data[startIndex++] = (float)symbol_frame_instance.symbolIdx;
     KAnim.Build.SymbolFrame symbolFrame = symbol_frame_instance.symbolFrame;
     KAnim.Build.Symbol      buildSymbol = GetBuildSymbol(symbol_frame_instance.symbolIdx);
     if (buildSymbol == null || symbolFrame == null)
     {
         data[startIndex++] = 0f;
         data[startIndex++] = 0f;
         data[startIndex++] = 0f;
         data[startIndex++] = 0f;
     }
     else
     {
         data[startIndex++] = (float)buildSymbol.numFrames;
         data[startIndex++] = (float)buildSymbol.flags;
         if (firstSymbolIndex.ContainsKey(buildSymbol.build.fileHash))
         {
             data[startIndex++] = (float)firstSymbolIndex[buildSymbol.build.fileHash];
         }
         else
         {
             data[startIndex++] = 0f;
         }
         data[startIndex++] = (float)buildSymbol.symbolIndexInSourceBuild;
     }
     data[startIndex++] = 3.452817E+09f;
     if (symbolFrame != null)
     {
         data[startIndex++] = symbolFrame.bboxMin.x;
         data[startIndex++] = symbolFrame.bboxMin.y;
         data[startIndex++] = symbolFrame.bboxMax.x;
         data[startIndex++] = symbolFrame.bboxMax.y;
         data[startIndex++] = symbolFrame.uvMin.x;
         data[startIndex++] = symbolFrame.uvMin.y;
         data[startIndex++] = symbolFrame.uvMax.x;
         data[startIndex++] = symbolFrame.uvMax.y;
     }
 }
示例#15
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));
 }
        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);
                }
            }
        }
    public void AddAccessories(KAnimFile default_build, ResourceSet parent)
    {
        KAnim.Build        build  = file.GetData().build;
        KAnim.Build.Symbol symbol = default_build.GetData().build.GetSymbol(targetSymbolId);
        string             text   = Id.ToLower();

        if (symbol != null)
        {
            string    id        = text + "_DEFAULT";
            Accessory accessory = new Accessory(id, parent, this, default_build.batchTag, symbol);
            accessories.Add(accessory);
            HashCache.Get().Add(accessory.IdHash.HashValue, accessory.Id);
        }
        for (int i = 0; i < build.symbols.Length; i++)
        {
            string text2 = HashCache.Get().Get(build.symbols[i].hash);
            if (text2.StartsWith(text))
            {
                Accessory accessory2 = new Accessory(text2, parent, this, file.batchTag, build.symbols[i]);
                accessories.Add(accessory2);
                HashCache.Get().Add(accessory2.IdHash.HashValue, accessory2.Id);
            }
        }
    }
    public static int ParseBuildData(KBatchGroupData data, KAnimHashedString fileNameHash, FastReader reader, List <Texture2D> textures)
    {
        CheckHeader("BILD", reader);
        int num = reader.ReadInt32();

        if (num != 10 && num != 9)
        {
            Debug.LogError(fileNameHash + " has invalid build.bytes version [" + num + "]");
            return(-1);
        }
        KAnimGroupFile.Group group = KAnimGroupFile.GetGroup(data.groupID);
        if (group == null)
        {
            Debug.LogErrorFormat("[{1}] Failed to get group [{0}]", data.groupID, fileNameHash.DebuggerDisplay);
        }
        KAnim.Build build = null;
        int         num2  = reader.ReadInt32();
        int         num3  = reader.ReadInt32();

        build = data.AddNewBuildFile(fileNameHash);
        build.textureCount = textures.Count;
        if (textures.Count > 0)
        {
            data.AddTextures(textures);
        }
        build.symbols  = new KAnim.Build.Symbol[num2];
        build.frames   = new KAnim.Build.SymbolFrame[num3];
        build.name     = reader.ReadKleiString();
        build.batchTag = ((!group.swapTarget.IsValid) ? data.groupID : group.target);
        build.fileHash = fileNameHash;
        int num4 = 0;

        for (int i = 0; i < build.symbols.Length; i++)
        {
            KAnimHashedString  hash   = new KAnimHashedString(reader.ReadInt32());
            KAnim.Build.Symbol symbol = new KAnim.Build.Symbol();
            symbol.build = build;
            symbol.hash  = hash;
            if (num > 9)
            {
                symbol.path = new KAnimHashedString(reader.ReadInt32());
            }
            symbol.colourChannel            = new KAnimHashedString(reader.ReadInt32());
            symbol.flags                    = reader.ReadInt32();
            symbol.firstFrameIdx            = data.symbolFrameInstances.Count;
            symbol.numFrames                = reader.ReadInt32();
            symbol.symbolIndexInSourceBuild = i;
            int num5 = 0;
            for (int j = 0; j < symbol.numFrames; j++)
            {
                KAnim.Build.SymbolFrame         symbolFrame = new KAnim.Build.SymbolFrame();
                KAnim.Build.SymbolFrameInstance item        = default(KAnim.Build.SymbolFrameInstance);
                item.symbolFrame           = symbolFrame;
                symbolFrame.fileNameHash   = fileNameHash;
                symbolFrame.sourceFrameNum = reader.ReadInt32();
                symbolFrame.duration       = reader.ReadInt32();
                item.buildImageIdx         = data.textureStartIndex[fileNameHash] + reader.ReadInt32();
                if (item.buildImageIdx >= textures.Count + data.textureStartIndex[fileNameHash])
                {
                    Debug.LogErrorFormat("{0} Symbol: [{1}] tex count: [{2}] buildImageIdx: [{3}] group total [{4}]", fileNameHash.ToString(), symbol.hash, textures.Count, item.buildImageIdx, data.textureStartIndex[fileNameHash]);
                }
                item.symbolIdx = data.GetSymbolCount();
                num5           = Math.Max(symbolFrame.sourceFrameNum + symbolFrame.duration, num5);
                float num6 = reader.ReadSingle();
                float num7 = reader.ReadSingle();
                float num8 = reader.ReadSingle();
                float num9 = reader.ReadSingle();
                symbolFrame.bboxMin = new Vector2(num6 - num8 * 0.5f, num7 - num9 * 0.5f);
                symbolFrame.bboxMax = new Vector2(num6 + num8 * 0.5f, num7 + num9 * 0.5f);
                float x     = reader.ReadSingle();
                float num10 = reader.ReadSingle();
                float x2    = reader.ReadSingle();
                float num11 = reader.ReadSingle();
                symbolFrame.uvMin  = new Vector2(x, 1f - num10);
                symbolFrame.uvMax  = new Vector2(x2, 1f - num11);
                build.frames[num4] = symbolFrame;
                data.symbolFrameInstances.Add(item);
                num4++;
            }
            symbol.numLookupFrames = num5;
            data.AddBuildSymbol(symbol);
            build.symbols[i] = symbol;
        }
        ParseHashTable(reader);
        return(build.index);
    }
示例#19
0
    protected virtual List <GameObject> SpawnOrderProduct(ComplexRecipe recipe)
    {
        List <GameObject> list = new List <GameObject>();

        SimUtil.DiseaseInfo diseaseInfo = default(SimUtil.DiseaseInfo);
        diseaseInfo.count = 0;
        diseaseInfo.idx   = 0;
        float num  = 0f;
        float num2 = 0f;

        ComplexRecipe.RecipeElement[] ingredients = recipe.ingredients;
        foreach (ComplexRecipe.RecipeElement recipeElement in ingredients)
        {
            num2 += recipeElement.amount;
        }
        ComplexRecipe.RecipeElement[] ingredients2 = recipe.ingredients;
        foreach (ComplexRecipe.RecipeElement recipeElement2 in ingredients2)
        {
            float num3 = recipeElement2.amount / num2;
            buildStorage.ConsumeAndGetDisease(recipeElement2.material, recipeElement2.amount, out SimUtil.DiseaseInfo disease_info, out float aggregate_temperature);
            if (disease_info.count > diseaseInfo.count)
            {
                diseaseInfo = disease_info;
            }
            num += aggregate_temperature * num3;
        }
        ComplexRecipe.RecipeElement[] results = recipe.results;
        foreach (ComplexRecipe.RecipeElement recipeElement3 in results)
        {
            GameObject gameObject = buildStorage.FindFirst(recipeElement3.material);
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
            {
                Edible component = gameObject.GetComponent <Edible>();
                if ((bool)component)
                {
                    ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, 0f - component.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.CRAFTED_USED, "{0}", component.GetProperName()), UI.ENDOFDAYREPORT.NOTES.CRAFTED_CONTEXT);
                }
            }
            switch (resultState)
            {
            case ResultState.PassTemperature:
            case ResultState.Heated:
            {
                GameObject prefab      = Assets.GetPrefab(recipeElement3.material);
                GameObject gameObject2 = GameUtil.KInstantiate(prefab, Grid.SceneLayer.Ore, null, 0);
                int        cell        = Grid.PosToCell(this);
                gameObject2.transform.SetPosition(Grid.CellToPosCCC(cell, Grid.SceneLayer.Ore) + outputOffset);
                PrimaryElement component2 = gameObject2.GetComponent <PrimaryElement>();
                component2.Units       = recipeElement3.amount;
                component2.Temperature = ((resultState != 0) ? heatedTemperature : num);
                gameObject2.SetActive(true);
                float num4 = recipeElement3.amount / recipe.TotalResultUnits();
                component2.AddDisease(diseaseInfo.idx, Mathf.RoundToInt((float)diseaseInfo.count * num4), "ComplexFabricator.CompleteOrder");
                gameObject2.GetComponent <KMonoBehaviour>().Trigger(748399584, null);
                list.Add(gameObject2);
                if (storeProduced)
                {
                    outStorage.Store(gameObject2, false, false, true, false);
                }
                break;
            }

            case ResultState.Melted:
                if (storeProduced)
                {
                    float temperature = ElementLoader.GetElement(recipeElement3.material).lowTemp + (ElementLoader.GetElement(recipeElement3.material).highTemp - ElementLoader.GetElement(recipeElement3.material).lowTemp) / 2f;
                    outStorage.AddLiquid(ElementLoader.GetElementID(recipeElement3.material), recipeElement3.amount, temperature, 0, 0, false, true);
                }
                break;
            }
            if (list.Count > 0)
            {
                SymbolOverrideController component3 = GetComponent <SymbolOverrideController>();
                if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                {
                    KBatchedAnimController component4 = list[0].GetComponent <KBatchedAnimController>();
                    KAnim.Build            build      = component4.AnimFiles[0].GetData().build;
                    KAnim.Build.Symbol     symbol     = build.GetSymbol(build.name);
                    if (symbol != null)
                    {
                        component3.TryRemoveSymbolOverride("output_tracker", 0);
                        component3.AddSymbolOverride("output_tracker", symbol, 0);
                    }
                    else
                    {
                        Debug.LogWarning(component3.name + " is missing symbol " + build.name);
                    }
                }
            }
        }
        return(list);
    }
 public static void PostParse(KBatchGroupData data)
 {
     for (int i = 0; i < data.GetSymbolCount(); i++)
     {
         KAnim.Build.Symbol symbol = data.GetSymbol(i);
         if (symbol == null)
         {
             Debug.LogWarning("Symbol null for [" + data.groupID + "] idx: [" + i + "]");
         }
         else
         {
             if (symbol.numLookupFrames <= 0)
             {
                 int num = symbol.numFrames;
                 for (int j = symbol.firstFrameIdx; j < symbol.firstFrameIdx + symbol.numFrames; j++)
                 {
                     KAnim.Build.SymbolFrameInstance symbolFrameInstance = data.GetSymbolFrameInstance(j);
                     num = Mathf.Max(num, symbolFrameInstance.symbolFrame.sourceFrameNum + symbolFrameInstance.symbolFrame.duration);
                 }
                 symbol.numLookupFrames = num;
             }
             symbol.frameLookup = new int[symbol.numLookupFrames];
             if (symbol.numLookupFrames <= 0)
             {
                 Debug.LogWarning("No lookup frames for  [" + data.groupID + "] build: [" + symbol.build.name + "] idx: [" + i + "] id: [" + symbol.hash + "]");
             }
             else
             {
                 for (int k = 0; k < symbol.numLookupFrames; k++)
                 {
                     symbol.frameLookup[k] = -1;
                 }
                 for (int l = symbol.firstFrameIdx; l < symbol.firstFrameIdx + symbol.numFrames; l++)
                 {
                     KAnim.Build.SymbolFrameInstance symbolFrameInstance2 = data.GetSymbolFrameInstance(l);
                     if (symbolFrameInstance2.symbolFrame == null)
                     {
                         Debug.LogWarning("No symbol frame  [" + data.groupID + "] symFrameIdx: [" + l + "] id: [" + symbol.hash + "]");
                     }
                     else
                     {
                         for (int m = symbolFrameInstance2.symbolFrame.sourceFrameNum; m < symbolFrameInstance2.symbolFrame.sourceFrameNum + symbolFrameInstance2.symbolFrame.duration; m++)
                         {
                             if (m >= symbol.frameLookup.Length)
                             {
                                 Debug.LogWarning("Too many lookup frames [" + m + ">=" + symbol.frameLookup.Length + "] for  [" + data.groupID + "] idx: [" + i + "] id: [" + symbol.hash + "]");
                             }
                             else
                             {
                                 symbol.frameLookup[m] = l;
                             }
                         }
                     }
                 }
                 string text = HashCache.Get().Get(symbol.path);
                 if (!string.IsNullOrEmpty(text))
                 {
                     int num2 = text.IndexOf("/");
                     if (num2 != -1)
                     {
                         string text2 = text.Substring(0, num2);
                         symbol.folder = new KAnimHashedString(text2);
                         HashCache.Get().Add(symbol.folder.HashValue, text2);
                     }
                 }
             }
         }
     }
 }
示例#21
0
 public void LoadAll()
 {
     Debug.Assert(!hasCompletedLoadAll, "You cannot load all the anim data twice!");
     fileData.Clear();
     for (int i = 0; i < groups.Count; i++)
     {
         if (!groups[i].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", i);
         }
         KBatchGroupData kBatchGroupData = null;
         kBatchGroupData = ((!groups[i].target.IsValid) ? KAnimBatchManager.Instance().GetBatchGroupData(groups[i].id) : KAnimBatchManager.Instance().GetBatchGroupData(groups[i].target));
         HashedString batchTag = groups[i].id;
         if (groups[i].renderType == KAnimBatchGroup.RendererType.AnimOnly)
         {
             if (!groups[i].swapTarget.IsValid)
             {
                 continue;
             }
             kBatchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(groups[i].swapTarget);
             batchTag        = groups[i].swapTarget;
         }
         for (int j = 0; j < groups[i].files.Count; j++)
         {
             KAnimFile kAnimFile = groups[i].files[j];
             if ((UnityEngine.Object)kAnimFile != (UnityEngine.Object)null && kAnimFile.buildBytes != null && !fileData.ContainsKey(kAnimFile.GetInstanceID()))
             {
                 if (kAnimFile.buildBytes.Length == 0)
                 {
                     Debug.LogWarning("Build File [" + kAnimFile.GetData().name + "] has 0 bytes");
                 }
                 else
                 {
                     HashedString hash = new HashedString(kAnimFile.name);
                     HashCache.Get().Add(hash.HashValue, kAnimFile.name);
                     KAnimFileData file = KGlobalAnimParser.Get().GetFile(kAnimFile);
                     file.maxVisSymbolFrames = 0;
                     file.batchTag           = batchTag;
                     file.buildIndex         = KGlobalAnimParser.ParseBuildData(kBatchGroupData, hash, new FastReader(kAnimFile.buildBytes), kAnimFile.textureList);
                     fileData.Add(kAnimFile.GetInstanceID(), file);
                 }
             }
         }
     }
     for (int k = 0; k < groups.Count; k++)
     {
         if (groups[k].renderType == KAnimBatchGroup.RendererType.AnimOnly)
         {
             KBatchGroupData batchGroupData  = KAnimBatchManager.Instance().GetBatchGroupData(groups[k].swapTarget);
             KBatchGroupData batchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[k].animTarget);
             for (int l = 0; l < batchGroupData.builds.Count; l++)
             {
                 KAnim.Build build = batchGroupData.builds[l];
                 if (build != null && build.symbols != null)
                 {
                     for (int m = 0; m < build.symbols.Length; m++)
                     {
                         KAnim.Build.Symbol symbol = build.symbols[m];
                         if (symbol != null && symbol.hash.IsValid() && batchGroupData2.GetFirstIndex(symbol.hash) == -1)
                         {
                             KAnim.Build.Symbol symbol2 = new KAnim.Build.Symbol();
                             symbol2.build                    = build;
                             symbol2.hash                     = symbol.hash;
                             symbol2.path                     = symbol.path;
                             symbol2.colourChannel            = symbol.colourChannel;
                             symbol2.flags                    = symbol.flags;
                             symbol2.firstFrameIdx            = batchGroupData2.symbolFrameInstances.Count;
                             symbol2.numFrames                = symbol.numFrames;
                             symbol2.symbolIndexInSourceBuild = batchGroupData2.frameElementSymbols.Count;
                             for (int n = 0; n < symbol2.numFrames; n++)
                             {
                                 KAnim.Build.SymbolFrameInstance symbolFrameInstance = batchGroupData.GetSymbolFrameInstance(n + symbol.firstFrameIdx);
                                 KAnim.Build.SymbolFrameInstance item = default(KAnim.Build.SymbolFrameInstance);
                                 item.symbolFrame   = symbolFrameInstance.symbolFrame;
                                 item.buildImageIdx = -1;
                                 item.symbolIdx     = batchGroupData2.GetSymbolCount();
                                 batchGroupData2.symbolFrameInstances.Add(item);
                             }
                             batchGroupData2.AddBuildSymbol(symbol2);
                         }
                     }
                 }
             }
         }
     }
     for (int num = 0; num < groups.Count; num++)
     {
         if (!groups[num].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", num);
         }
         if (groups[num].renderType != KAnimBatchGroup.RendererType.DontRender)
         {
             KBatchGroupData kBatchGroupData2 = null;
             if (groups[num].animTarget.IsValid)
             {
                 kBatchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num].animTarget);
                 if (kBatchGroupData2 == null)
                 {
                     Debug.LogErrorFormat("Anim group is null for [{0}] -> [{1}]", groups[num].id, groups[num].animTarget);
                 }
             }
             else
             {
                 kBatchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num].id);
                 if (kBatchGroupData2 == null)
                 {
                     Debug.LogErrorFormat("Anim group is null for [{0}]", groups[num].id);
                 }
             }
             for (int num2 = 0; num2 < groups[num].files.Count; num2++)
             {
                 KAnimFile kAnimFile2 = groups[num].files[num2];
                 if ((UnityEngine.Object)kAnimFile2 != (UnityEngine.Object)null && kAnimFile2.animBytes != null)
                 {
                     if (kAnimFile2.animBytes.Length == 0)
                     {
                         Debug.LogWarning("Anim File [" + kAnimFile2.GetData().name + "] has 0 bytes");
                     }
                     else
                     {
                         if (!fileData.ContainsKey(kAnimFile2.GetInstanceID()))
                         {
                             KAnimFileData file2 = KGlobalAnimParser.Get().GetFile(kAnimFile2);
                             file2.maxVisSymbolFrames = 0;
                             file2.batchTag           = groups[num].id;
                             fileData.Add(kAnimFile2.GetInstanceID(), file2);
                         }
                         HashedString  fileNameHash = new HashedString(kAnimFile2.name);
                         FastReader    reader       = new FastReader(kAnimFile2.animBytes);
                         KAnimFileData animFile     = fileData[kAnimFile2.GetInstanceID()];
                         KGlobalAnimParser.ParseAnimData(kBatchGroupData2, fileNameHash, reader, animFile);
                     }
                 }
             }
         }
     }
     for (int num3 = 0; num3 < groups.Count; num3++)
     {
         if (!groups[num3].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", num3);
         }
         KBatchGroupData kBatchGroupData3 = null;
         if (groups[num3].target.IsValid)
         {
             kBatchGroupData3 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num3].target);
             if (kBatchGroupData3 == null)
             {
                 Debug.LogErrorFormat("Group is null for  [{0}] target [{1}]", groups[num3].id, groups[num3].target);
             }
         }
         else
         {
             kBatchGroupData3 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num3].id);
             if (kBatchGroupData3 == null)
             {
                 Debug.LogErrorFormat("Group is null for [{0}]", groups[num3].id);
             }
         }
         KGlobalAnimParser.PostParse(kBatchGroupData3);
     }
     hasCompletedLoadAll = true;
 }
    public static Sprite GetUISpriteFromMultiObjectAnim(KAnimFile animFile, string animName = "ui", bool centered = false, string symbolName = "")
    {
        Tuple <KAnimFile, string, bool> key = new Tuple <KAnimFile, string, bool>(animFile, animName, centered);

        if (knownUISprites.ContainsKey(key))
        {
            return(knownUISprites[key]);
        }
        if ((UnityEngine.Object)animFile == (UnityEngine.Object)null)
        {
            DebugUtil.LogWarningArgs(animName, "missing Anim File");
            return(null);
        }
        KAnimFileData data = animFile.GetData();

        if (data == null)
        {
            DebugUtil.LogWarningArgs(animName, "KAnimFileData is null");
            return(null);
        }
        if (data.build == null)
        {
            return(null);
        }
        KAnim.Anim.Frame frame = KAnim.Anim.Frame.InvalidFrame;
        for (int i = 0; i < data.animCount; i++)
        {
            KAnim.Anim anim = data.GetAnim(i);
            if (anim.name == animName)
            {
                frame = anim.GetFrame(data.batchTag, 0);
            }
        }
        if (!frame.IsValid())
        {
            DebugUtil.LogWarningArgs($"missing '{animName}' anim in '{animFile}'");
            return(null);
        }
        if (data.elementCount == 0)
        {
            return(null);
        }
        KAnim.Anim.FrameElement frameElement = default(KAnim.Anim.FrameElement);
        if (string.IsNullOrEmpty(symbolName))
        {
            symbolName = animName;
        }
        frameElement = data.FindAnimFrameElement(symbolName);
        KAnim.Build.Symbol symbol = data.build.GetSymbol(frameElement.symbol);
        if (symbol == null)
        {
            DebugUtil.LogWarningArgs(animFile.name, animName, "placeSymbol [", frameElement.symbol, "] is missing");
            return(null);
        }
        int frame2 = frameElement.frame;

        KAnim.Build.SymbolFrameInstance frame3      = symbol.GetFrame(frame2);
        KAnim.Build.SymbolFrame         symbolFrame = frame3.symbolFrame;
        if (symbolFrame == null)
        {
            DebugUtil.LogWarningArgs(animName, "SymbolFrame [", frameElement.frame, "] is missing");
            return(null);
        }
        Texture2D texture = data.build.GetTexture(0);
        float     x       = symbolFrame.uvMin.x;
        float     x2      = symbolFrame.uvMax.x;
        float     y       = symbolFrame.uvMax.y;
        float     y2      = symbolFrame.uvMin.y;
        int       num     = (int)((float)texture.width * Mathf.Abs(x2 - x));
        int       num2    = (int)((float)texture.height * Mathf.Abs(y2 - y));
        float     num3    = Mathf.Abs(symbolFrame.bboxMax.x - symbolFrame.bboxMin.x);
        Rect      rect    = default(Rect);

        rect.width  = (float)num;
        rect.height = (float)num2;
        rect.x      = (float)(int)((float)texture.width * x);
        rect.y      = (float)(int)((float)texture.height * y);
        float pixelsPerUnit = 100f;

        if (num != 0)
        {
            pixelsPerUnit = 100f / (num3 / (float)num);
        }
        Sprite sprite = Sprite.Create(texture, rect, (!centered) ? Vector2.zero : new Vector2(0.5f, 0.5f), pixelsPerUnit, 0u, SpriteMeshType.FullRect);

        sprite.name         = $"{texture.name}:{animName}:{frameElement.frame.ToString()}:{centered}";
        knownUISprites[key] = sprite;
        return(sprite);
    }
示例#23
0
            public static bool Prefix(ComplexFabricator __instance, ref ComplexRecipe recipe, ref List <GameObject> __result)
            {
                if (recipe == GeneticSamplerConfig.RECIPE_RECOMBINATION)
                {
                    Debug.Log("Should recombinate");
                    var ingredient_0 = recipe.ingredients[0];
                    Debug.Log(ingredient_0);
                    float   amount  = ingredient_0.amount;
                    var     tag     = ingredient_0.material;
                    Storage storage = __instance.buildStorage;
                    Debug.Log(amount);
                    Debug.Log(tag);
                    Debug.Log(storage.items.Count);
                    DebugHelper.LogForEach(storage.items);
                    for (int index = 0; index < storage.items.Count && (double)amount > 0.0; ++index)
                    {
                        GameObject item_0 = storage.items[index];
                        Debug.Log(item_0);
                        Debug.Log(item_0.HasTag(tag));
                        if (!((UnityEngine.Object)item_0 == (UnityEngine.Object)null) && item_0.HasTag(tag))
                        {
                            Debug.Log("About to add traits to add");

                            var traitsToAdd = GeneticTraits.GeneticTraits.ChooseTraitsFromEggToEgg(item_0).Select(Db.Get().traits.Get);
                            //to the result



                            List <GameObject>   gameObjectList = new List <GameObject>();
                            SimUtil.DiseaseInfo diseaseInfo;
                            diseaseInfo.count = 0;
                            diseaseInfo.idx   = (byte)0;
                            float num1 = 0.0f;
                            float num2 = 0.0f;
                            foreach (ComplexRecipe.RecipeElement ingredient in recipe.ingredients)
                            {
                                num2 += ingredient.amount;
                            }
                            foreach (ComplexRecipe.RecipeElement ingredient in recipe.ingredients)
                            {
                                float num3 = ingredient.amount / num2;
                                SimUtil.DiseaseInfo disease_info;
                                float aggregate_temperature;
                                __instance.buildStorage.ConsumeAndGetDisease(ingredient.material, ingredient.amount, out disease_info, out aggregate_temperature);
                                if (disease_info.count > diseaseInfo.count)
                                {
                                    diseaseInfo = disease_info;
                                }
                                num1 += aggregate_temperature * num3;
                            }
                            foreach (ComplexRecipe.RecipeElement result in recipe.results)
                            {
                                GameObject first = __instance.buildStorage.FindFirst(result.material);
                                if ((UnityEngine.Object)first != (UnityEngine.Object)null)
                                {
                                    Edible component = first.GetComponent <Edible>();
                                    if ((bool)((UnityEngine.Object)component))
                                    {
                                        ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, -component.Calories, StringFormatter.Replace((string)UI.ENDOFDAYREPORT.NOTES.CRAFTED_USED, "{0}", component.GetProperName()), (string)UI.ENDOFDAYREPORT.NOTES.CRAFTED_CONTEXT);
                                    }
                                }
                                switch (__instance.resultState)
                                {
                                case ComplexFabricator.ResultState.PassTemperature:
                                case ComplexFabricator.ResultState.Heated:
                                    GameObject go   = GameUtil.KInstantiate(Assets.GetPrefab(result.material), Grid.SceneLayer.Ore, (string)null, 0);
                                    int        cell = Grid.PosToCell((KMonoBehaviour)__instance);
                                    go.transform.SetPosition(Grid.CellToPosCCC(cell, Grid.SceneLayer.Ore) + __instance.outputOffset);
                                    PrimaryElement component1 = go.GetComponent <PrimaryElement>();
                                    component1.Units       = result.amount;
                                    component1.Temperature = __instance.resultState != ComplexFabricator.ResultState.PassTemperature ? __instance.heatedTemperature : num1;
                                    go.SetActive(true);
                                    float num3 = result.amount / recipe.TotalResultUnits();
                                    component1.AddDisease(diseaseInfo.idx, Mathf.RoundToInt((float)diseaseInfo.count * num3), "ComplexFabricator.CompleteOrder");
                                    go.GetComponent <KMonoBehaviour>().Trigger(748399584, (object)null);

                                    var gtc = go.AddOrGet <GeneticTraitComponent>();
                                    gtc.addTraits(traitsToAdd, item_0);

                                    gameObjectList.Add(go);
                                    if (__instance.storeProduced)
                                    {
                                        __instance.outStorage.Store(go, false, false, true, false);
                                        break;
                                    }
                                    break;

                                case ComplexFabricator.ResultState.Melted:
                                    if (__instance.storeProduced)
                                    {
                                        float temperature = ElementLoader.GetElement(result.material).lowTemp + (float)(((double)ElementLoader.GetElement(result.material).highTemp - (double)ElementLoader.GetElement(result.material).lowTemp) / 2.0);
                                        __instance.outStorage.AddLiquid(ElementLoader.GetElementID(result.material), result.amount, temperature, (byte)0, 0, false, true);
                                        break;
                                    }
                                    break;
                                }
                                if (gameObjectList.Count > 0)
                                {
                                    SymbolOverrideController component2 = __instance.GetComponent <SymbolOverrideController>();
                                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                                    {
                                        KAnim.Build        build  = gameObjectList[0].GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build;
                                        KAnim.Build.Symbol symbol = build.GetSymbol((KAnimHashedString)build.name);
                                        if (symbol != null)
                                        {
                                            component2.TryRemoveSymbolOverride((HashedString)"output_tracker", 0);
                                            component2.AddSymbolOverride((HashedString)"output_tracker", symbol, 0);
                                        }
                                        else
                                        {
                                            Debug.LogWarning((object)(component2.name + " is missing symbol " + build.name));
                                        }
                                    }
                                }
                            }
                            __result = gameObjectList;
                        }
                    }

                    return(false);
                }
                else
                {
                    Debug.Log("Should NO recombinate");
                    return(true);
                }
            }
示例#24
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);
     }
 }
示例#25
0
 public Accessory(string id, ResourceSet parent, AccessorySlot slot, HashedString batchSource, KAnim.Build.Symbol symbol)
     : base(id, parent, null)
 {
     this.slot        = slot;
     this.symbol      = symbol;
     this.batchSource = batchSource;
 }