Example #1
0
        public void Sim1000ms(float dt)
        {
            InitalizeEffectors();

            if (RoomTypes_AllModded.IsInTheRoom(this, RoomTypeAquariumData.RoomId))
            {
                provider.SetValues(bonusEffector);
            }
            else
            {
                provider.SetValues(initialEffector);
            }
        }
        public GameObject CreatePrefab()
        {
            GameObject gameObject = CreateOilFloater(ID, PHO_STRINGS.VARIANT_OWO.NAME, PHO_STRINGS.VARIANT_OWO.DESC, base_kanim_id, false);

            DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>();

            decorProvider.SetValues(TUNING.DECOR.BONUS.TIER5);


            EffectArea owoEffect = gameObject.AddComponent <EffectArea>();

            owoEffect.EffectName = "OwO_effect";
            owoEffect.Area       = 5;


            EntityTemplates.ExtendEntityToFertileCreature(gameObject,
                                                          EGG_ID,
                                                          PHO_STRINGS.VARIANT_OWO.EGG_NAME,
                                                          PHO_STRINGS.VARIANT_OWO.DESC,
                                                          egg_kanim_id,
                                                          OilFloaterTuning.EGG_MASS,
                                                          ID + "Baby",
                                                          60.0000038f, 20f,
                                                          EGG_CHANCES_OWO,
                                                          EGG_SORT_ORDER,
                                                          true, false, true, 1f);
            return(gameObject);
        }
Example #3
0
    public static GameObject CreateArtifact(string id, string name, string desc, string initial_anim, string ui_anim, ArtifactTier artifact_tier, PostInitFn postInitFn = null, SimHashes element = SimHashes.Creature)
    {
        GameObject gameObject = EntityTemplates.CreateLooseEntity("artifact_" + id.ToLower(), name, desc, 25f, true, Assets.GetAnim("artifacts_kanim"), initial_anim, Grid.SceneLayer.Ore, EntityTemplates.CollisionShape.RECTANGLE, 1f, 1f, true, SORTORDER.BUILDINGELEMENTS, element, new List <Tag>
        {
            GameTags.MiscPickupable
        });
        OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>();

        occupyArea.OccupiedCellsOffsets = EntityTemplates.GenerateOffsets(1, 1);
        DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>();

        decorProvider.SetValues(artifact_tier.decorValues);
        decorProvider.overrideName = gameObject.name;
        SpaceArtifact spaceArtifact = gameObject.AddOrGet <SpaceArtifact>();

        spaceArtifact.SetUIAnim(ui_anim);
        spaceArtifact.SetArtifactTier(artifact_tier);
        gameObject.AddOrGet <KSelectable>();
        gameObject.GetComponent <KBatchedAnimController>().initialMode = KAnim.PlayMode.Loop;
        postInitFn?.Invoke(gameObject);
        KPrefabID component = gameObject.GetComponent <KPrefabID>();

        component.AddTag(GameTags.PedestalDisplayable, false);
        component.AddTag(GameTags.Artifact, false);
        return(gameObject);
    }
Example #4
0
    private static GameObject ConfigPlacedEntity(GameObject template, string id, string name, string desc, float mass, KAnimFile anim, string initialAnim, Grid.SceneLayer sceneLayer, int width, int height, EffectorValues decor, EffectorValues noise = default(EffectorValues), SimHashes element = SimHashes.Creature, List <Tag> additionalTags = null, float defaultTemperature = 293f)
    {
        if ((Object)anim == (Object)null)
        {
            Debug.LogErrorFormat("Cant create [{0}] entity without an anim", name);
        }
        ConfigBasicEntity(template, id, name, desc, mass, true, anim, initialAnim, sceneLayer, element, additionalTags, defaultTemperature);
        KBoxCollider2D kBoxCollider2D = template.AddOrGet <KBoxCollider2D>();

        kBoxCollider2D.size = new Vector2f(width, height);
        float num = 0.5f * (float)((width + 1) % 2);

        kBoxCollider2D.offset = new Vector2f(num, (float)height / 2f);
        KBatchedAnimController component = template.GetComponent <KBatchedAnimController>();

        component.Offset = new Vector3(num, 0f, 0f);
        OccupyArea occupyArea = template.AddOrGet <OccupyArea>();

        occupyArea.OccupiedCellsOffsets = GenerateOffsets(width, height);
        DecorProvider decorProvider = template.AddOrGet <DecorProvider>();

        decorProvider.SetValues(decor);
        decorProvider.overrideName = name;
        return(template);
    }
Example #5
0
    public static GameObject CreatePacu(string id, string name, string desc, string anim_file, bool is_baby)
    {
        GameObject prefab = BasePacuConfig.CreatePrefab(id, "PacuTropicalBaseTrait", name, desc, anim_file, is_baby, "trp_", 303.15f, 353.15f);

        prefab = EntityTemplates.ExtendEntityToWildCreature(prefab, PacuTuning.PEN_SIZE_PER_CREATURE, 25f);
        DecorProvider decorProvider = prefab.AddOrGet <DecorProvider>();

        decorProvider.SetValues(DECOR);
        return(prefab);
    }
Example #6
0
    public static GameObject CreateOilFloater(string id, string name, string desc, string anim_file, bool is_baby)
    {
        GameObject    gameObject    = BaseOilFloaterConfig.BaseOilFloater(id, name, desc, anim_file, "OilfloaterDecorBaseTrait", 283.15f, 343.15f, is_baby, "oxy_");
        DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>();

        decorProvider.SetValues(DECOR.BONUS.TIER6);
        EntityTemplates.ExtendEntityToWildCreature(gameObject, OilFloaterTuning.PEN_SIZE_PER_CREATURE, 150f);
        Trait trait = Db.Get().CreateTrait("OilfloaterDecorBaseTrait", name, name, null, false, null, true, true);

        trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, OilFloaterTuning.STANDARD_STOMACH_SIZE, name, false, false, true));
        trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, (0f - OilFloaterTuning.STANDARD_CALORIES_PER_CYCLE) / 600f, name, false, false, true));
        trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, name, false, false, true));
        trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 150f, name, false, false, true));
        return(BaseOilFloaterConfig.SetupDiet(gameObject, SimHashes.Oxygen.CreateTag(), Tag.Invalid, CALORIES_PER_KG_OF_ORE, 0f, null, 0f, 0f));
    }
Example #7
0
 public void RemoveMonumentPiece()
 {
     if (IsMonumentCompleted())
     {
         List <GameObject> attachedNetwork = AttachableBuilding.GetAttachedNetwork(GetComponent <AttachableBuilding>());
         foreach (GameObject item in attachedNetwork)
         {
             if ((Object)item.GetComponent <MonumentPart>() != (Object)this)
             {
                 DecorProvider component = item.GetComponent <DecorProvider>();
                 component.SetValues(BUILDINGS.DECOR.BONUS.MONUMENT.INCOMPLETE);
             }
         }
     }
 }
Example #8
0
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreateLooseEntity(ID, ITEMS.FOOD.ROTPILE.NAME, ITEMS.FOOD.ROTPILE.DESC, 1f, false, Assets.GetAnim("rotfood_kanim"), "object", Grid.SceneLayer.Front, EntityTemplates.CollisionShape.RECTANGLE, 0.8f, 0.4f, true, 0, SimHashes.Creature, null);
        KPrefabID  component  = gameObject.GetComponent <KPrefabID>();

        component.AddTag(GameTags.Organics, false);
        component.AddTag(GameTags.Compostable, false);
        gameObject.AddOrGet <EntitySplitter>();
        gameObject.AddOrGet <OccupyArea>();
        gameObject.AddOrGet <Modifiers>();
        gameObject.AddOrGet <RotPile>();
        DecorProvider decorProvider = gameObject.AddComponent <DecorProvider>();

        decorProvider.SetValues(DECOR.PENALTY.TIER2);
        return(gameObject);
    }
Example #9
0
    public void UpdateMonumentDecor()
    {
        GameObject monumentPart = GetMonumentPart(Part.Middle);

        if (IsMonumentCompleted())
        {
            DecorProvider component = monumentPart.GetComponent <DecorProvider>();
            component.SetValues(BUILDINGS.DECOR.BONUS.MONUMENT.COMPLETE);
            List <GameObject> attachedNetwork = AttachableBuilding.GetAttachedNetwork(GetComponent <AttachableBuilding>());
            foreach (GameObject item in attachedNetwork)
            {
                if ((Object)item != (Object)monumentPart)
                {
                    DecorProvider component2 = item.GetComponent <DecorProvider>();
                    component2.SetValues(BUILDINGS.DECOR.NONE);
                }
            }
        }
    }
    /// Modifies critters as they are loaded
    /// missing parameters: is_baby, override_prefix, lifespan, diet_list
    /// babyId: only reveals material, actually object is defined in egg
    public static void PatchCritters(KPrefabID prefab, GameObject critter)
    {
        CritterContainer setting = CustomizeCritterState.StateManager.State.critter_settings.Find(s => s.id == critter.name);

        if (setting == null)
        {
            return;
        }

        Debug.Log("DEBUG HELLO 1");

        if (setting.name != null)
        {
            prefab.PrefabTag = TagManager.Create(setting.id, setting.name);
            critter.GetComponent <KSelectable>()?.SetName(setting.name);
            critter.AddOrGet <DecorProvider>().overrideName = setting.name;
        }

        Debug.Log("DEBUG HELLO 2");

        if (setting.desc != null)
        {
            critter.AddOrGet <InfoDescription>().description = setting.desc;
        }

        Debug.Log("DEBUG HELLO 3");

        if (setting.anim_file != null)
        {
            KBatchedAnimController kbatchedAnimController = critter.AddOrGet <KBatchedAnimController>();
            kbatchedAnimController.AnimFiles = new KAnimFile[] { Assets.GetAnim(setting.anim_file) };
            //kbatchedAnimController.sceneLayer = sceneLayer;
            //kbatchedAnimController.initialAnim = initialAnim;
        }

        Debug.Log("DEBUG HELLO 4");

        if (setting.is_baby != null)
        {
            Debug.Log(setting.id + ".is_baby: This cannot be changed on existing critters.");
        }

        Debug.Log("DEBUG HELLO 5");

        if (setting.traitId != null)
        {
            Modifiers modifiers = critter.AddOrGet <Modifiers>();
            if (setting.traitId != "")
            {
                modifiers.initialTraits = new string[] { setting.traitId }
            }
            ;
            else
            {
                modifiers.initialTraits = null;
            }
            //modifiers.initialAmounts.Add(Db.Get().Amounts.HitPoints.Id);
        }

        Debug.Log("DEBUG HELLO 6");

        if (setting.override_prefix != null)
        {
            Debug.Log(setting.id + ".override_prefix: This cannot be changed on existing critters.");
        }

        Debug.Log("DEBUG HELLO 7");

        if (setting.space_requirement != null)
        {
            critter.AddOrGetDef <OvercrowdingMonitor.Def>().spaceRequiredPerCreature = setting.space_requirement.Value;
        }

        Debug.Log("DEBUG HELLO 8");

        if (setting.lifespan != null)
        {
            Debug.Log(setting.id + ".lifespan: This value is not read from the game. It exists only as artifact. Use traits instead!");
            //trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 150f, name, false, false, true));
        }

        Debug.Log("DEBUG HELLO 9");

        if (setting.mass != null)
        {
            critter.AddOrGet <PrimaryElement>().Mass = setting.mass.Value;
        }

        Debug.Log("DEBUG HELLO 10");

        if (setting.width != null || setting.height != null)
        {
            float          width          = setting.width ?? 1f;
            float          height         = setting.height ?? 1f;
            KBoxCollider2D kboxCollider2D = critter.AddOrGet <KBoxCollider2D>();
            kboxCollider2D.size = new Vector2f(width, height);
            float num = 0.5f * (float)((width + 1) % 2);
            kboxCollider2D.offset = new Vector2f(num, (float)height / 2f);
            critter.GetComponent <KBatchedAnimController>().Offset = new Vector3(num, 0f, 0f);
            critter.AddOrGet <OccupyArea>().OccupiedCellsOffsets   = EntityTemplates.GenerateOffsets((int)Math.Round(width, 0), (int)Math.Round(height, 0));
        }

        Debug.Log("DEBUG HELLO 11");

        if (setting.decor != null)
        {
            DecorProvider decorProvider = critter.AddOrGet <DecorProvider>();
            decorProvider.SetValues(setting.decor.Value);
        }

        Debug.Log("DEBUG HELLO 12");

        if (setting.navGridName != null)
        {
            critter.AddOrGet <Navigator>().NavGridName = setting.navGridName;
        }

        Debug.Log("DEBUG HELLO 13");

        if (setting.navi != null)
        {
            critter.AddOrGet <Navigator>().CurrentNavType = setting.navi.Value;
        }

        Debug.Log("DEBUG HELLO 14");

        if (setting.moveSpeed != null)
        {
            critter.AddOrGet <Navigator>().defaultSpeed = setting.moveSpeed.Value;
        }

        Debug.Log("DEBUG HELLO 15");

        if (setting.dropOnDeath != null)
        {
            critter.AddOrGet <Butcherable>().SetDrops(setting.dropOnDeath);
        }

        Debug.Log("DEBUG HELLO 16");

        if (setting.canDrown != null)
        {
            if (setting.canDrown.Value)
            {
                critter.AddOrGet <DrowningMonitor>();
            }
            else
            {
                critter.RemoveComponents <DrowningMonitor>();
            }
        }

        Debug.Log("DEBUG HELLO 17");

        if (setting.canCrushed != null)
        {
            if (setting.canCrushed.Value)
            {
                critter.AddOrGet <EntombVulnerable>();
            }
            else
            {
                critter.RemoveComponents <EntombVulnerable>();
            }
        }

        Debug.Log("DEBUG HELLO 18");

        if (setting.tempLowDeath != null)
        {
            critter.AddOrGet <TemperatureVulnerable>().internalTemperatureLethal_Low = setting.tempLowDeath.Value;
        }

        Debug.Log("DEBUG HELLO 19");

        if (setting.tempLowWarning != null)
        {
            critter.AddOrGet <TemperatureVulnerable>().internalTemperatureWarning_Low = setting.tempLowWarning.Value;
        }

        Debug.Log("DEBUG HELLO 20");

        if (setting.tempHighWarning != null)
        {
            critter.AddOrGet <TemperatureVulnerable>().internalTemperatureWarning_High = setting.tempHighWarning.Value;
        }

        Debug.Log("DEBUG HELLO 21");

        if (setting.tempHighDeath != null)
        {
            critter.AddOrGet <TemperatureVulnerable>().internalTemperatureLethal_High = setting.tempHighDeath.Value;
        }

        Debug.Log("DEBUG HELLO 22");

        if (setting.tempBorn != null)
        {
            critter.AddOrGet <PrimaryElement>().Temperature = setting.tempBorn.Value;
        }

        Debug.Log("DEBUG HELLO 23");

        if (setting.pickup_only_from_top != null)
        {
            critter.AddOrGet <Baggable>().mustStandOntopOfTrapForPickup = setting.pickup_only_from_top.Value;
        }

        Debug.Log("DEBUG HELLO 24");

        if (setting.pickup_allow_mark != null)
        {
            critter.AddOrGet <Capturable>().allowCapture = setting.pickup_allow_mark.Value;
        }

        Debug.Log("DEBUG HELLO 25");

        if (setting.pickup_use_gun != null)
        {
            critter.AddOrGet <Baggable>().useGunForPickup = setting.pickup_use_gun.Value;
        }

        Debug.Log("DEBUG HELLO 26");

        if (setting.tags != null)
        {
            prefab.ProcessTags(setting.tags);
        }

        Debug.Log("DEBUG HELLO 27");

        if (setting.species != null)
        {
            critter.AddOrGet <CreatureBrain>().species = setting.species;
        }

        Debug.Log("DEBUG HELLO 28");

        if (setting.attackValue != null)
        {
            if (setting.attackValue.Value > 0f)
            {
                critter.AddWeapon(setting.attackValue.Value, setting.attackValue.Value, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f);
            }
            else
            {
                critter.RemoveComponents <Weapon>();
            }
        }

        Debug.Log("DEBUG HELLO 29");

        if (setting.chore_table != null)
        {
            ChoreConsumer chore_consumer = critter.AddOrGet <ChoreConsumer>();
            chore_consumer.choreTable = setting.chore_table.CreateTable();
            // prefab.instantiateFn += delegate(GameObject go) { go.GetComponent<ChoreConsumer>().choreTable = chore_consumer.choreTable; };
        }

        Debug.Log("DEBUG HELLO 30");

        if (setting.adultId != null)
        {
            critter.AddOrGetDef <BabyMonitor.Def>().adultPrefab = setting.adultId;
        }

        Debug.Log("DEBUG HELLO 31");

        if (setting.dropOnMature != null)
        {
            critter.AddOrGetDef <BabyMonitor.Def>().onGrowDropID = setting.dropOnMature;
        }

        Debug.Log("DEBUG HELLO 32");

        if (setting.fertility_cycles != null)
        {
            critter.AddOrGetDef <FertilityMonitor.Def>().baseFertileCycles = setting.fertility_cycles.Value;
        }

        Debug.Log("DEBUG HELLO 33");

        if (setting.egg_chances != null)
        {
            critter.AddOrGetDef <FertilityMonitor.Def>().initialBreedingWeights = setting.egg_chances;
        }

        Debug.Log("DEBUG HELLO 34");

        if (setting.is_ranchable != null)
        {
            if (setting.is_ranchable.Value)
            {
                critter.AddOrGetDef <RanchableMonitor.Def>();
            }
            else
            {
                critter.RemoveDef <RanchableMonitor.Def>();
            }
        }

        Debug.Log("DEBUG HELLO 35");

        if (setting.calories_per_KG != null)
        {
            critter.AddOrGetDef <CreatureCalorieMonitor.Def>();
        }

        Debug.Log("DEBUG HELLO 36");

        if (setting.min_poop_KG != null)
        {
            critter.AddOrGetDef <CreatureCalorieMonitor.Def>().minPoopSizeInCalories = setting.min_poop_KG.Value * setting.calories_per_KG ?? 1f;
        }

        Debug.Log("DEBUG HELLO 37");

        if (setting.diet_list != null)
        {
            //Diet diet = new Diet(setting.diet_list.ToArray());
            //critter.AddOrGetDef<CreatureCalorieMonitor.Def>().diet = diet;
            //critter.AddOrGetDef<SolidConsumerMonitor.Def>().diet = diet;
        }

        Debug.Log("DEBUG HELLO 38");

        if (setting.eggId != null)
        {
            critter.AddOrGetDef <FertilityMonitor.Def>().eggPrefab = setting.eggId;
            prefab.prefabSpawnFn += delegate(GameObject inst)
            {
                WorldInventory.Instance.Discover(setting.eggId.ToTag(), WorldInventory.GetCategoryForTags(egg_tags));
            };
        }

        Debug.Log("DEBUG HELLO 39");

        if (setting.babyId != null)
        {
            prefab.prefabSpawnFn += delegate(GameObject inst)
            {
                WorldInventory.Instance.Discover(setting.babyId.ToTag(), WorldInventory.GetCategoryForTags(prefab.Tags));
            };
        }

        Debug.Log("DEBUG HELLO 40");

        if (setting.light != null)
        {
            if (setting.light.color != Color.black)
            {
                Light2D light2D = critter.AddOrGet <Light2D>();
                if (setting.light.color != null)
                {
                    light2D.Color = setting.light.color.Value;
                }
                light2D.overlayColour = TUNING.LIGHT2D.LIGHTBUG_OVERLAYCOLOR;
                if (setting.light.range != null)
                {
                    light2D.Range = setting.light.range.Value;
                }
                light2D.Angle       = 0f;
                light2D.Direction   = TUNING.LIGHT2D.LIGHTBUG_DIRECTION;
                light2D.Offset      = TUNING.LIGHT2D.LIGHTBUG_OFFSET;
                light2D.shape       = LightShape.Circle;
                light2D.drawOverlay = true;
                if (setting.light.lux != null)
                {
                    light2D.Lux = setting.light.lux.Value;
                }
                critter.AddOrGet <LightSymbolTracker>().targetSymbol = "snapTo_light_locator";
                critter.AddOrGetDef <CreatureLightToggleController.Def>();
            }
            else
            {
                critter.RemoveComponents <Light2D>();
                critter.RemoveComponents <LightSymbolTracker>();
                critter.RemoveDef <CreatureLightToggleController.Def>();
            }
        }

        Debug.Log("DEBUG HELLO 41");

        if (setting.expulsion != null)  //works also with gasses/liquids/solids
        {
            ElementDropperMonitor.Def def_morb = critter.AddOrGetDef <ElementDropperMonitor.Def>();
            if (setting.expulsion.element != null)
            {
                def_morb.dirtyEmitElement = setting.expulsion.element.ToSimHash();
            }
            if (setting.expulsion.probability != null)
            {
                def_morb.dirtyProbabilityPercent = setting.expulsion.probability.Value;
            }
            if (setting.expulsion.cellTargetMass != null)
            {
                def_morb.dirtyCellToTargetMass = setting.expulsion.cellTargetMass.Value;
            }
            if (setting.expulsion.massPerDirt != null)
            {
                def_morb.dirtyMassPerDirty = setting.expulsion.massPerDirt.Value;
            }
            if (setting.expulsion.onDeath != null)
            {
                def_morb.dirtyMassReleaseOnDeath = setting.expulsion.onDeath.Value;
            }
            if (setting.expulsion.diseaseId != null)
            {
                def_morb.emitDiseaseIdx = Db.Get().Diseases.GetIndex(setting.expulsion.diseaseId);
            }
            if (setting.expulsion.diseaseAmount != null)
            {
                def_morb.emitDiseasePerKg = setting.expulsion.diseaseAmount.Value;
            }
        }

        Debug.Log("DEBUG HELLO 42");

        if (setting.scales != null)
        {
            ScaleGrowthMonitor.Def def_scale = critter.AddOrGetDef <ScaleGrowthMonitor.Def>();
            if (setting.scales.growthRate != null)
            {
                def_scale.defaultGrowthRate = setting.scales.growthRate.Value;
            }
            if (setting.scales.mass != null)
            {
                def_scale.dropMass = setting.scales.mass.Value;
            }
            if (setting.scales.drop != null)
            {
                def_scale.itemDroppedOnShear = setting.scales.drop;
            }
            if (setting.scales.levelCount != null)
            {
                def_scale.levelCount = setting.scales.levelCount.Value;
            }
            if (setting.scales.atmosphere != null)
            {
                def_scale.targetAtmosphere = setting.scales.atmosphere.ToSimHash();
            }
        }

        Debug.Log("DEBUG HELLO 43");
    }