public void AddAnims(KAnimFile anim_file)
    {
        KAnimFileData data = anim_file.GetData();

        if (data == null)
        {
            Debug.LogError("AddAnims() Null animfile data");
        }
        else
        {
            maxSymbols = Mathf.Max(maxSymbols, data.maxVisSymbolFrames);
            for (int i = 0; i < data.animCount; i++)
            {
                KAnim.Anim anim = data.GetAnim(i);
                if (anim.animFile.hashName != data.hashName)
                {
                    Debug.LogErrorFormat("How did we get an anim from another file? [{0}] != [{1}] for anim [{2}]", data.name, anim.animFile.name, i);
                }
                anims[anim.hash] = new AnimLookupData
                {
                    animIndex = anim.index
                };
            }
            if (usingNewSymbolOverrideSystem && data.buildIndex != -1 && data.build.symbols != null && data.build.symbols.Length > 0)
            {
                SymbolOverrideController component = GetComponent <SymbolOverrideController>();
                component.AddBuildOverride(anim_file.GetData(), -1);
            }
        }
    }
    private Chore CreateWorkChore()
    {
        ChoreType learnSkill = Db.Get().ChoreTypes.LearnSkill;
        KAnimFile anim       = Assets.GetAnim("anim_hat_kanim");

        return(new WorkChore <RoleStation>(learnSkill, this, null, true, null, null, null, false, null, false, true, anim, false, true, false, PriorityScreen.PriorityClass.personalNeeds, 5, false, false));
    }
    private void RebuildOverrides(KAnimFile kanim_file)
    {
        bool flag = false;

        overrideAnims.Clear();
        for (int i = 0; i < overrideAnimFiles.Count; i++)
        {
            OverrideAnimFileData overrideAnimFileData = overrideAnimFiles[i];
            KAnimFileData        data = overrideAnimFileData.file.GetData();
            for (int j = 0; j < data.animCount; j++)
            {
                KAnim.Anim anim = data.GetAnim(j);
                if (anim.animFile.hashName != data.hashName)
                {
                    Debug.LogError($"How did we get an anim from another file? [{data.name}] != [{anim.animFile.name}] for anim [{j}]");
                }
                AnimLookupData value = default(AnimLookupData);
                value.animIndex = anim.index;
                HashedString hashedString = new HashedString(anim.name);
                if (!overrideAnims.ContainsKey(hashedString))
                {
                    overrideAnims[hashedString] = value;
                }
                if (curAnim != null && curAnim.hash == hashedString && (UnityEngine.Object)overrideAnimFileData.file == (UnityEngine.Object)kanim_file)
                {
                    flag = true;
                }
            }
        }
        if (flag)
        {
            Restart(curAnim.name, mode, playSpeed, 0f);
        }
    }
Esempio n. 4
0
    public GameObject CreatePrefab()
    {
        string    id          = "ResearchDatabank";
        string    name        = ITEMS.INDUSTRIAL_PRODUCTS.RESEARCH_DATABANK.NAME;
        string    desc        = ITEMS.INDUSTRIAL_PRODUCTS.RESEARCH_DATABANK.DESC;
        float     mass        = 1f;
        bool      unitMass    = true;
        KAnimFile anim        = Assets.GetAnim("floppy_disc_kanim");
        string    initialAnim = "object";

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Front;
        EntityTemplates.CollisionShape collisionShape = EntityTemplates.CollisionShape.CIRCLE;
        float      width        = 0.35f;
        float      height       = 0.35f;
        bool       isPickupable = true;
        List <Tag> list         = new List <Tag>();

        list.Add(GameTags.IndustrialIngredient);
        list.Add(GameTags.Experimental);
        list = list;
        GameObject     gameObject     = EntityTemplates.CreateLooseEntity(id, name, desc, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, SimHashes.Creature, list);
        EntitySplitter entitySplitter = gameObject.AddOrGet <EntitySplitter>();

        entitySplitter.maxStackSize = (float)ROCKETRY.DESTINATION_RESEARCH.BASIC;
        return(gameObject);
    }
Esempio n. 5
0
    public GameObject CreatePrefab()
    {
        string         id          = "ShockWorm";
        string         name        = STRINGS.CREATURES.SPECIES.SHOCKWORM.NAME;
        string         desc        = STRINGS.CREATURES.SPECIES.SHOCKWORM.DESC;
        float          mass        = 50f;
        KAnimFile      anim        = Assets.GetAnim("shockworm_kanim");
        string         initialAnim = "idle";
        EffectorValues tIER        = DECOR.BONUS.TIER0;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, null, 293f);
        GameObject     template    = gameObject;

        FactionManager.FactionID faction = FactionManager.FactionID.Hostile;
        initialAnim = null;
        desc        = "FlyerNavGrid1x2";
        NavType navType = NavType.Hover;

        mass = 2f;
        name = "Meat";
        int   onDeathDropCount = 3;
        float fREEZING_        = TUNING.CREATURES.TEMPERATURE.FREEZING_1;
        float hOT_             = TUNING.CREATURES.TEMPERATURE.HOT_1;

        EntityTemplates.ExtendEntityToBasicCreature(template, faction, initialAnim, desc, navType, 32, mass, name, onDeathDropCount, true, true, fREEZING_, hOT_, TUNING.CREATURES.TEMPERATURE.FREEZING_2, TUNING.CREATURES.TEMPERATURE.HOT_2);
        gameObject.AddOrGet <LoopingSounds>();
        Weapon weapon = gameObject.AddWeapon(3f, 6f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.AreaOfEffect, 10, 4f);

        weapon.AddEffect("WasAttacked", 1f);
        SoundEventVolumeCache.instance.AddVolume("shockworm_kanim", "Shockworm_attack_arc", NOISE_POLLUTION.CREATURES.TIER6);
        return(gameObject);
    }
Esempio n. 6
0
    public string GetGroupName(KAnimFile kaf)
    {
        switch (TagGroup)
        {
        case GroupBy.__IGNORE__:
            return(null);

        case GroupBy.NamedGroupNoSplit:
            return(TargetBuild);

        case GroupBy.NamedGroup:
        {
            string fileName = Path.GetFileName(kaf.homedirectory);
            foreach (KeyValuePair <string, List <string> > defaultBuild in DefaultBuilds)
            {
                if (defaultBuild.Value.Contains(fileName))
                {
                    return(defaultBuild.Key);
                }
            }
            return(TargetBuild);
        }

        case GroupBy.Folder:
            return(Path.GetFileName(directory) + (groupFiles.Count / 10).ToString());

        case GroupBy.DontGroup:
            return(kaf.name);

        default:
            return(null);
        }
    }
    protected override void OnSpawn()
    {
        GetComponent <Storage>().SetOffsets(DELIVERY_OFFSETS);
        Storage component = GetComponent <Storage>();
        Storage storage   = component;

        storage.OnWorkableEventCB = (Action <Workable.WorkableEvent>)Delegate.Combine(storage.OnWorkableEventCB, new Action <Workable.WorkableEvent>(OnWorkEvent));
        KAnimFile anim = Assets.GetAnim("anim_bury_dupe_kanim");
        int       num  = 0;

        while (true)
        {
            KAnim.Anim anim2 = anim.GetData().GetAnim(num);
            if (anim2 == null)
            {
                break;
            }
            if (anim2.name == "working_pre")
            {
                float workTime = (float)(anim2.numFrames - 3) / anim2.frameRate;
                component.SetWorkTime(workTime);
                break;
            }
            num++;
        }
        base.OnSpawn();
        base.smi.StartSM();
        Components.Graves.Add(this);
    }
Esempio n. 8
0
    public void RegisterEquipment(IEquipmentConfig config)
    {
        EquipmentDef equipmentDef      = config.CreateEquipmentDef();
        string       id                = equipmentDef.Id;
        string       name              = equipmentDef.Name;
        string       recipeDescription = equipmentDef.RecipeDescription;
        float        mass              = equipmentDef.Mass;
        bool         unitMass          = true;
        KAnimFile    anim              = equipmentDef.Anim;
        string       initialAnim       = "object";

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore;
        EntityTemplates.CollisionShape collisionShape = equipmentDef.CollisionShape;
        float      width         = equipmentDef.width;
        float      height        = equipmentDef.height;
        bool       isPickupable  = true;
        SimHashes  outputElement = equipmentDef.OutputElement;
        GameObject gameObject    = EntityTemplates.CreateLooseEntity(id, name, recipeDescription, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, outputElement, null);
        Equippable equippable    = gameObject.AddComponent <Equippable>();

        equippable.def = equipmentDef;
        Debug.Assert((Object)equippable.def != (Object)null);
        equippable.slotID = equipmentDef.Slot;
        Debug.Assert(equippable.slot != null);
        config.DoPostConfigure(gameObject);
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
    }
    public GameObject CreatePrefab()
    {
        string         id          = "BasicForagePlantPlanted";
        string         name        = STRINGS.CREATURES.SPECIES.BASICFORAGEPLANTPLANTED.NAME;
        string         desc        = STRINGS.CREATURES.SPECIES.BASICFORAGEPLANTPLANTED.DESC;
        float          mass        = 100f;
        KAnimFile      anim        = Assets.GetAnim("muckroot_kanim");
        string         initialAnim = "idle";
        EffectorValues tIER        = DECOR.BONUS.TIER1;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingBack, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, 293f);

        gameObject.AddOrGet <SimTemperatureTransfer>();
        OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>();

        occupyArea.objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        gameObject.AddOrGet <EntombVulnerable>();
        gameObject.AddOrGet <DrowningMonitor>();
        gameObject.AddOrGet <Prioritizable>();
        gameObject.AddOrGet <Uprootable>();
        gameObject.AddOrGet <UprootedMonitor>();
        gameObject.AddOrGet <Harvestable>();
        gameObject.AddOrGet <HarvestDesignatable>();
        SeedProducer seedProducer = gameObject.AddOrGet <SeedProducer>();

        seedProducer.Configure("BasicForagePlant", SeedProducer.ProductionType.DigOnly, 1);
        gameObject.AddOrGet <BasicForagePlantPlanted>();
        gameObject.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        return(gameObject);
    }
Esempio n. 10
0
        public GameObject CreatePrefab()
        {
            string    name        = "Bark Skin";
            string    desc        = "Are produced by wooden hatch";
            float     mass        = 1f;//too litle, add more later
            bool      unitMass    = false;
            KAnimFile anim        = Assets.GetAnim("bark_skin_kanim");
            string    initialAnim = "object";

            Grid.SceneLayer sceneLayer = Grid.SceneLayer.Front;
            EntityTemplates.CollisionShape collisionShape = EntityTemplates.CollisionShape.CIRCLE;
            float      width          = 0.35f;
            float      height         = 0.35f;
            bool       isPickupable   = true;
            List <Tag> additionalTags = new List <Tag>
            {
                GameTags.IndustrialIngredient,
                GameTags.Organics
            };
            GameObject gameObject = EntityTemplates.CreateLooseEntity(ID, name, desc, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, SimHashes.Creature, additionalTags);

            gameObject.AddOrGet <EntitySplitter>();
            gameObject.AddOrGet <SimpleMassStatusItem>();
            return(gameObject);
        }
 protected override void OnSpawn()
 {
     base.OnSpawn();
     if (!IsThereLiquid())
     {
         base.gameObject.DeleteObject();
     }
     else
     {
         Grid.Objects[Grid.PosToCell(base.gameObject), 8] = base.gameObject;
         new WorkChore <Moppable>(Db.Get().ChoreTypes.Mop, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
         SetWorkTime(float.PositiveInfinity);
         KSelectable component = GetComponent <KSelectable>();
         component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().MiscStatusItems.WaitingForMop, null);
         Subscribe(493375141, OnRefreshUserMenuDelegate);
         overrideAnims = new KAnimFile[1]
         {
             Assets.GetAnim("anim_mop_dirtywater_kanim")
         };
         partitionerEntry = GameScenePartitioner.Instance.Add("Moppable.OnSpawn", base.gameObject, new Extents(Grid.PosToCell(this), new CellOffset[1]
         {
             new CellOffset(0, 0)
         }), GameScenePartitioner.Instance.liquidChangedLayer, OnLiquidChanged);
         Refresh();
         Subscribe(-1432940121, OnReachableChangedDelegate);
         ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
         instance.StartSM();
         SimAndRenderScheduler.instance.Remove(this);
     }
 }
    public GameObject CreatePrefab()
    {
        string    id          = "BabyCrabShell";
        string    name        = ITEMS.INDUSTRIAL_PRODUCTS.CRAB_SHELL.NAME;
        string    desc        = ITEMS.INDUSTRIAL_PRODUCTS.CRAB_SHELL.DESC;
        float     mass        = 5f;
        bool      unitMass    = true;
        KAnimFile anim        = Assets.GetAnim("crabshells_small_kanim");
        string    initialAnim = "object";

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Front;
        EntityTemplates.CollisionShape collisionShape = EntityTemplates.CollisionShape.RECTANGLE;
        float      width        = 0.9f;
        float      height       = 0.6f;
        bool       isPickupable = true;
        List <Tag> list         = new List <Tag>();

        list.Add(GameTags.IndustrialIngredient);
        list.Add(GameTags.Organics);
        list = list;
        GameObject gameObject = EntityTemplates.CreateLooseEntity(id, name, desc, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, SimHashes.Creature, list);

        gameObject.AddOrGet <EntitySplitter>();
        gameObject.AddOrGet <SimpleMassStatusItem>();
        EntityTemplates.CreateAndRegisterCompostableFromPrefab(gameObject);
        return(gameObject);
    }
Esempio n. 13
0
 private bool AddFile(int groupIndex, KAnimFile file)
 {
     if (!groups[groupIndex].files.Contains(file))
     {
         Pair <HashedString, HashedString> pair = new Pair <HashedString, HashedString>(file.homedirectory, groups[groupIndex].id);
         bool flag = false;
         for (int i = 0; i < currentGroup.Count; i++)
         {
             Pair <HashedString, HashedString> pair2 = currentGroup[i];
             if (pair2.first == (HashedString)file.homedirectory)
             {
                 currentGroup[i] = pair;
                 flag            = true;
                 break;
             }
         }
         if (!flag)
         {
             currentGroup.Add(pair);
         }
         groups[groupIndex].files.Add(file);
         return(true);
     }
     return(false);
 }
    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();
        }
    }
        protected override void OnPrefabInit()
        {
            base.OnPrefabInit();
            resetProgressOnStop = true;
            showProgressBar     = false;
            SetWorkTime(float.PositiveInfinity);
            workLayer = Grid.SceneLayer.BuildingFront;
            var kanim = Assets.GetAnim("anim_interacts_suitrecharger_kanim");

            overrideAnims    = new KAnimFile[] { kanim };
            synchronizeAnims = true;
            if (SuitRecharging == null)
            {
                SuitRecharging = new StatusItem(
                    id: nameof(SuitRecharging),
                    name: DUPLICANTS.CHORES.RECHARGE.STATUS,
                    tooltip: DUPLICANTS.CHORES.RECHARGE.TOOLTIP,
                    icon: string.Empty,
                    icon_type: StatusItem.IconType.Info,
                    notification_type: NotificationType.Neutral,
                    allow_multiples: false,
                    render_overlay: OverlayModes.None.ID,
                    status_overlays: (int)StatusItem.StatusItemOverlays.None);
                // привязываемся к длительности анимации

                /*
                 * working_pre = 4.033333
                 * working_loop = 2
                 * working_pst = 4.333333
                 */
                warmupTime = Utils.GetAnimDuration(kanim, "working_pre");
                сhargeTime = 2 * Utils.GetAnimDuration(kanim, "working_loop");
            }
            workerStatusItem = SuitRecharging;
        }
Esempio n. 16
0
    public GameObject CreatePrefab()
    {
        string         id          = "BeanPlant";
        string         name        = STRINGS.CREATURES.SPECIES.BEAN_PLANT.NAME;
        string         desc        = STRINGS.CREATURES.SPECIES.BEAN_PLANT.DESC;
        float          mass        = 2f;
        KAnimFile      anim        = Assets.GetAnim("beanplant_kanim");
        string         initialAnim = "idle_empty";
        EffectorValues tIER        = DECOR.BONUS.TIER1;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingFront, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, null, 258.15f);

        EntityTemplates.ExtendEntityToBasicPlant(gameObject, 198.15f, 248.15f, 273.15f, 323.15f, null, true, 0f, 0.15f, "BeanPlantSeed", true, true, true, true, 2400f);
        EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = SimHashes.Ethanol.CreateTag(),
                massConsumptionRate = 0.0333333351f
            }
        });
        EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = SimHashes.Dirt.CreateTag(),
                massConsumptionRate = 0.008333334f
            }
        });
        PressureVulnerable pressureVulnerable  = gameObject.AddOrGet <PressureVulnerable>();
        PressureVulnerable pressureVulnerable2 = pressureVulnerable;

        mass = 0.025f;
        float pressureLethalLow = 0f;

        SimHashes[] safeAtmospheres = new SimHashes[1]
        {
            SimHashes.CarbonDioxide
        };
        pressureVulnerable2.Configure(mass, pressureLethalLow, 10f, 30f, safeAtmospheres);
        UprootedMonitor component = gameObject.GetComponent <UprootedMonitor>();

        component.monitorCell = new CellOffset(0, -1);
        gameObject.AddOrGet <StandardCropPlant>();
        GameObject plant = gameObject;

        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Harvest;
        initialAnim = "BeanPlantSeed";
        desc        = STRINGS.CREATURES.SPECIES.SEEDS.BEAN_PLANT.NAME;
        name        = STRINGS.CREATURES.SPECIES.SEEDS.BEAN_PLANT.DESC;
        anim        = Assets.GetAnim("seed_beanplant_kanim");
        List <Tag> list = new List <Tag>();

        list.Add(GameTags.CropSeed);
        list = list;
        GameObject gameObject2 = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 4, STRINGS.CREATURES.SPECIES.BEAN_PLANT.DOMESTICATEDDESC, EntityTemplates.CollisionShape.RECTANGLE, 0.6f, 0.3f, null, string.Empty, false);

        EntityTemplates.ExtendEntityToFood(gameObject2, FOOD.FOOD_TYPES.BEAN);
        EntityTemplates.CreateAndRegisterPreviewForPlant(gameObject2, "BeanPlant_preview", Assets.GetAnim("beanplant_kanim"), "place", 1, 2);
        return(gameObject);
    }
Esempio n. 17
0
 public AccessorySlots(ResourceSet parent, KAnimFile default_build = null, KAnimFile swap_build = null, KAnimFile torso_swap_build = null)
     : base("AccessorySlots", parent)
 {
     if ((Object)swap_build == (Object)null)
     {
         swap_build = Assets.GetAnim("head_swap_kanim");
         parent     = Db.Get().Accessories;
     }
     if ((Object)default_build == (Object)null)
     {
         default_build = Assets.GetAnim("body_comp_default_kanim");
     }
     if ((Object)torso_swap_build == (Object)null)
     {
         torso_swap_build = Assets.GetAnim("body_swap_kanim");
     }
     Eyes       = new AccessorySlot("Eyes", this, swap_build, null);
     Hair       = new AccessorySlot("Hair", this, swap_build, null);
     HeadShape  = new AccessorySlot("HeadShape", this, swap_build, null);
     Mouth      = new AccessorySlot("Mouth", this, swap_build, null);
     Hat        = new AccessorySlot("Hat", this, swap_build, null);
     HatHair    = new AccessorySlot("Hat_Hair", this, swap_build, null);
     HairAlways = new AccessorySlot("Hair_Always", this, swap_build, "hair");
     Body       = new AccessorySlot("Body", this, torso_swap_build, null);
     Arm        = new AccessorySlot("Arm", this, torso_swap_build, null);
     foreach (AccessorySlot resource in resources)
     {
         resource.AddAccessories(default_build, parent);
     }
 }
    public GameObject CreatePrefab()
    {
        string    iD          = ID;
        string    name        = ITEMS.INDUSTRIAL_PRODUCTS.BASIC_FABRIC.NAME;
        string    desc        = ITEMS.INDUSTRIAL_PRODUCTS.BASIC_FABRIC.DESC;
        float     mass        = 1f;
        bool      unitMass    = true;
        KAnimFile anim        = Assets.GetAnim("swampreedwool_kanim");
        string    initialAnim = "object";

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.BuildingBack;
        EntityTemplates.CollisionShape collisionShape = EntityTemplates.CollisionShape.RECTANGLE;
        float      width        = 0.8f;
        float      height       = 0.45f;
        bool       isPickupable = true;
        int        sortOrder    = SORTORDER.BUILDINGELEMENTS + BasicFabricTuning.SORTORDER;
        List <Tag> list         = new List <Tag>();

        list.Add(GameTags.IndustrialIngredient);
        list.Add(GameTags.BuildingFiber);
        list = list;
        GameObject gameObject = EntityTemplates.CreateLooseEntity(iD, name, desc, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, sortOrder, SimHashes.Creature, list);

        gameObject.AddOrGet <EntitySplitter>();
        PrefabAttributeModifiers prefabAttributeModifiers = gameObject.AddOrGet <PrefabAttributeModifiers>();

        prefabAttributeModifiers.AddAttributeDescriptor(decorModifier);
        return(gameObject);
    }
Esempio n. 19
0
    public GameObject CreatePrefab()
    {
        string         id          = "PrickleFlower";
        string         name        = STRINGS.CREATURES.SPECIES.PRICKLEFLOWER.NAME;
        string         desc        = STRINGS.CREATURES.SPECIES.PRICKLEFLOWER.DESC;
        float          mass        = 1f;
        KAnimFile      anim        = Assets.GetAnim("bristleblossom_kanim");
        string         initialAnim = "idle_empty";
        EffectorValues tIER        = DECOR.BONUS.TIER1;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingFront, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, null, 293f);
        GameObject     template    = gameObject;

        mass = 218.15f;
        float temperature_warning_low  = 278.15f;
        float temperature_warning_high = 303.15f;
        float temperature_lethal_high  = 398.15f;

        SimHashes[] safe_elements = new SimHashes[3]
        {
            SimHashes.Oxygen,
            SimHashes.ContaminatedOxygen,
            SimHashes.CarbonDioxide
        };
        initialAnim = PrickleFruitConfig.ID;
        EntityTemplates.ExtendEntityToBasicPlant(template, mass, temperature_warning_low, temperature_warning_high, temperature_lethal_high, safe_elements, true, 0f, 0.15f, initialAnim, true, true, true, true, 2400f);
        EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = GameTags.Water,
                massConsumptionRate = 0.0333333351f
            }
        });
        gameObject.AddOrGet <StandardCropPlant>();
        DiseaseDropper.Def def = gameObject.AddOrGetDef <DiseaseDropper.Def>();
        def.diseaseIdx         = Db.Get().Diseases.GetIndex(Db.Get().Diseases.PollenGerms.id);
        def.singleEmitQuantity = 1000000;
        IlluminationVulnerable illuminationVulnerable = gameObject.AddOrGet <IlluminationVulnerable>();

        illuminationVulnerable.SetPrefersDarkness(false);
        template = gameObject;
        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Harvest;
        initialAnim = "PrickleFlowerSeed";
        desc        = STRINGS.CREATURES.SPECIES.SEEDS.PRICKLEFLOWER.NAME;
        name        = STRINGS.CREATURES.SPECIES.SEEDS.PRICKLEFLOWER.DESC;
        anim        = Assets.GetAnim("seed_bristleblossom_kanim");
        int        numberOfSeeds = 0;
        List <Tag> list          = new List <Tag>();

        list.Add(GameTags.CropSeed);
        list = list;
        id   = STRINGS.CREATURES.SPECIES.PRICKLEFLOWER.DOMESTICATEDDESC;
        GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(template, productionType, initialAnim, desc, name, anim, "object", numberOfSeeds, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 2, id, EntityTemplates.CollisionShape.CIRCLE, 0.25f, 0.25f, null, string.Empty, false);

        EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "PrickleFlower_preview", Assets.GetAnim("bristleblossom_kanim"), "place", 1, 2);
        SoundEventVolumeCache.instance.AddVolume("bristleblossom_kanim", "PrickleFlower_harvest", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("bristleblossom_kanim", "PrickleFlower_grow", NOISE_POLLUTION.CREATURES.TIER3);
        return(gameObject);
    }
Esempio n. 20
0
    public GameObject CreatePrefab()
    {
        string         text        = STRINGS.CREATURES.SPECIES.GLOM.NAME;
        string         id          = "Glom";
        string         name        = text;
        string         desc        = STRINGS.CREATURES.SPECIES.GLOM.DESC;
        float          mass        = 25f;
        KAnimFile      anim        = Assets.GetAnim("glom_kanim");
        string         initialAnim = "idle_loop";
        EffectorValues tIER        = DECOR.BONUS.TIER0;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, 293f);
        Trait          trait       = Db.Get().CreateTrait("GlomBaseTrait", text, text, null, false, null, true, true);

        trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, text, false, false, true));
        KPrefabID component = gameObject.GetComponent <KPrefabID>();

        component.AddTag(GameTags.Creatures.Walker, false);
        component.prefabInitFn += delegate(GameObject inst)
        {
            inst.GetAttributes().Add(Db.Get().Attributes.MaxUnderwaterTravelCost);
        };
        EntityTemplates.ExtendEntityToBasicCreature(gameObject, FactionManager.FactionID.Pest, "GlomBaseTrait", "WalkerNavGrid1x1", NavType.Floor, 32, 2f, string.Empty, 0, true, true, 293.15f, 393.15f, 273.15f, 423.15f);
        gameObject.AddWeapon(1f, 1f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f);
        gameObject.AddOrGet <Trappable>();
        gameObject.AddOrGetDef <ThreatMonitor.Def>();
        gameObject.AddOrGetDef <CreatureFallMonitor.Def>();
        ElementDropperMonitor.Def def = gameObject.AddOrGetDef <ElementDropperMonitor.Def>();
        def.dirtyEmitElement        = SimHashes.ContaminatedOxygen;
        def.dirtyProbabilityPercent = 25f;
        def.dirtyCellToTargetMass   = 1f;
        def.dirtyMassPerDirty       = 0.2f;
        def.dirtyMassReleaseOnDeath = 3f;
        def.emitDiseaseIdx          = Db.Get().Diseases.GetIndex("SlimeLung");
        def.emitDiseasePerKg        = 1000f;
        OvercrowdingMonitor.Def def2 = gameObject.AddOrGetDef <OvercrowdingMonitor.Def>();
        def2.spaceRequiredPerCreature = 0;
        gameObject.AddOrGet <LoopingSounds>();
        LoopingSounds component2 = gameObject.GetComponent <LoopingSounds>();

        component2.updatePosition = true;
        DiseaseSourceVisualizer diseaseSourceVisualizer = gameObject.AddOrGet <DiseaseSourceVisualizer>();

        diseaseSourceVisualizer.alwaysShowDisease = "SlimeLung";
        SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_movement_short", NOISE_POLLUTION.CREATURES.TIER2);
        SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_jump", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_land", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_expel", NOISE_POLLUTION.CREATURES.TIER4);
        EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, true, false, false);
        ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new TrappedStates.Def(), true).Add(new BaggedStates.Def(), true)
                                         .Add(new FallStates.Def(), true)
                                         .Add(new StunnedStates.Def(), true)
                                         .Add(new DrowningStates.Def(), true)
                                         .Add(new DebugGoToStates.Def(), true)
                                         .Add(new FleeStates.Def(), true)
                                         .Add(new DropElementStates.Def(), true)
                                         .Add(new IdleStates.Def(), true);
        EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.GlomSpecies, null);
        return(gameObject);
    }
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     overrideAnims = new KAnimFile[1]
     {
         Assets.GetAnim("anim_use_machine_kanim")
     };
 }
Esempio n. 22
0
 internal WorkCheckpointReactable(WorkCheckpoint <T> checkpoint) : base(checkpoint.
                                                                        gameObject, "WorkCheckpointReactable", Db.Get().ChoreTypes.
                                                                        Checkpoint, 1, 1)
 {
     this.checkpoint          = checkpoint ?? throw new ArgumentNullException("checkpoint");
     distractedAnim           = Assets.GetAnim("anim_idle_distracted_kanim");
     preventChoreInterruption = false;
 }
Esempio n. 23
0
 public void AddOverride(string point_name, KAnimFile build_override, string symbol_name)
 {
     overrideMap[point_name] = new OverrideEntry
     {
         buildFile  = build_override,
         symbolName = symbol_name
     };
 }
Esempio n. 24
0
    public bool AddAnimFile(GroupFile gf, AnimCommandFile akf, KAnimFile file)
    {
        Debug.Assert(gf != null);
        Debug.Assert((UnityEngine.Object)file != (UnityEngine.Object)null, gf.groupID);
        Debug.Assert(akf != null, gf.groupID);
        int groupIndex = AddGroup(akf, gf, file);

        return(AddFile(groupIndex, file));
    }
Esempio n. 25
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     showProgressBar = false;
     overrideAnims   = new KAnimFile[1]
     {
         Assets.GetAnim("anim_break_kanim")
     };
     SetWorkTime(float.PositiveInfinity);
 }
Esempio n. 26
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     workerStatusItem = Db.Get().DuplicantStatusItems.Equipping;
     overrideAnims    = new KAnimFile[1]
     {
         Assets.GetAnim("anim_equip_clothing_kanim")
     };
     synchronizeAnims = false;
 }
    private Chore CreateWorkChore()
    {
        ChoreType astronaut = Db.Get().ChoreTypes.Astronaut;
        KAnimFile anim      = Assets.GetAnim("anim_hat_kanim");
        WorkChore <CommandModuleWorkable> workChore = new WorkChore <CommandModuleWorkable>(astronaut, this, null, true, null, null, null, false, null, false, true, anim, false, true, false, PriorityScreen.PriorityClass.personalNeeds, 5, false, true);

        workChore.AddPrecondition(ChorePreconditions.instance.HasSkillPerk, Db.Get().SkillPerks.CanUseRockets);
        workChore.AddPrecondition(ChorePreconditions.instance.IsAssignedtoMe, assignable);
        return(workChore);
    }
Esempio n. 28
0
    public GameObject CreatePrefab()
    {
        string         id             = "ForestTree";
        string         name           = STRINGS.CREATURES.SPECIES.WOOD_TREE.NAME;
        string         desc           = STRINGS.CREATURES.SPECIES.WOOD_TREE.DESC;
        float          mass           = 2f;
        KAnimFile      anim           = Assets.GetAnim("tree_kanim");
        string         initialAnim    = "idle_empty";
        EffectorValues tIER           = DECOR.BONUS.TIER1;
        List <Tag>     additionalTags = new List <Tag>();
        GameObject     gameObject     = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Building, 1, 2, tIER, default(EffectorValues), SimHashes.Creature, additionalTags, 298.15f);

        EntityTemplates.ExtendEntityToBasicPlant(gameObject, 258.15f, 288.15f, 313.15f, 448.15f, null, true, 0f, 0.15f, "WoodLog", true, true, true, false, 2400f);
        gameObject.AddOrGet <BuddingTrunk>();
        gameObject.UpdateComponentRequirement <Harvestable>(false);
        Tag tag = ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag;

        EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = tag,
                massConsumptionRate = 0.116666667f
            }
        });
        EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = GameTags.Dirt,
                massConsumptionRate = 0.0166666675f
            }
        });
        gameObject.AddComponent <StandardCropPlant>();
        UprootedMonitor component = gameObject.GetComponent <UprootedMonitor>();

        component.monitorCell = new CellOffset(0, -1);
        BuddingTrunk buddingTrunk = gameObject.AddOrGet <BuddingTrunk>();

        buddingTrunk.budPrefabID = "ForestTreeBranch";
        GameObject plant = gameObject;

        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Hidden;
        initialAnim    = "ForestTreeSeed";
        desc           = STRINGS.CREATURES.SPECIES.SEEDS.WOOD_TREE.NAME;
        name           = STRINGS.CREATURES.SPECIES.SEEDS.WOOD_TREE.DESC;
        anim           = Assets.GetAnim("seed_tree_kanim");
        additionalTags = new List <Tag>();
        additionalTags.Add(GameTags.CropSeed);
        additionalTags = additionalTags;
        GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, additionalTags, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 4, STRINGS.CREATURES.SPECIES.WOOD_TREE.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.3f, 0.3f, null, string.Empty, false);

        EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "ForestTree_preview", Assets.GetAnim("tree_kanim"), "place", 3, 3);
        return(gameObject);
    }
    public KAnimFileData Load(KAnimFile anim_file)
    {
        KAnimFileData value      = null;
        int           instanceID = anim_file.GetInstanceID();

        if (!files.TryGetValue(instanceID, out value))
        {
            value = GetFile(anim_file);
        }
        return(value);
    }
    public GameObject CreatePrefab()
    {
        string         id          = "ColdWheat";
        string         name        = STRINGS.CREATURES.SPECIES.COLDWHEAT.NAME;
        string         desc        = STRINGS.CREATURES.SPECIES.COLDWHEAT.DESC;
        float          mass        = 1f;
        KAnimFile      anim        = Assets.GetAnim("coldwheat_kanim");
        string         initialAnim = "idle_empty";
        EffectorValues tIER        = DECOR.BONUS.TIER1;
        GameObject     gameObject  = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.BuildingFront, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, 255f);

        EntityTemplates.ExtendEntityToBasicPlant(gameObject, 118.149994f, 218.15f, 278.15f, 358.15f, new SimHashes[3]
        {
            SimHashes.Oxygen,
            SimHashes.ContaminatedOxygen,
            SimHashes.CarbonDioxide
        }, true, 0f, 0.15f, "ColdWheatSeed", true, true, true, true, 2400f);
        EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = GameTags.Dirt,
                massConsumptionRate = 0.008333334f
            }
        });
        EntityTemplates.ExtendPlantToIrrigated(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = GameTags.Water,
                massConsumptionRate = 0.0333333351f
            }
        });
        gameObject.AddOrGet <StandardCropPlant>();
        GameObject plant = gameObject;

        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.DigOnly;
        initialAnim = "ColdWheatSeed";
        desc        = STRINGS.CREATURES.SPECIES.SEEDS.COLDWHEAT.NAME;
        name        = STRINGS.CREATURES.SPECIES.SEEDS.COLDWHEAT.DESC;
        anim        = Assets.GetAnim("seed_coldwheat_kanim");
        List <Tag> list = new List <Tag>();

        list.Add(GameTags.CropSeed);
        list = list;
        id   = STRINGS.CREATURES.SPECIES.COLDWHEAT.DOMESTICATEDDESC;
        GameObject gameObject2 = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, initialAnim, desc, name, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 2, id, EntityTemplates.CollisionShape.CIRCLE, 0.2f, 0.2f, null, string.Empty, true);

        EntityTemplates.ExtendEntityToFood(gameObject2, FOOD.FOOD_TYPES.COLD_WHEAT_SEED);
        EntityTemplates.CreateAndRegisterPreviewForPlant(gameObject2, "ColdWheat_preview", Assets.GetAnim("coldwheat_kanim"), "place", 1, 1);
        SoundEventVolumeCache.instance.AddVolume("coldwheat_kanim", "ColdWheat_grow", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("coldwheat_kanim", "ColdWheat_harvest", NOISE_POLLUTION.CREATURES.TIER3);
        return(gameObject);
    }