Exemplo n.º 1
0
    public static GameObject CreatePrefab(string id, string base_trait_id, string name, string description, string anim_file, bool is_baby, string symbol_prefix, float warnLowTemp, float warnHighTemp)
    {
        float          mass               = 200f;
        KAnimFile      anim               = Assets.GetAnim(anim_file);
        string         initialAnim        = "idle_loop";
        EffectorValues tIER               = DECOR.BONUS.TIER0;
        float          defaultTemperature = (warnLowTemp + warnHighTemp) / 2f;
        GameObject     gameObject         = EntityTemplates.CreatePlacedEntity(id, name, description, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, defaultTemperature);
        KPrefabID      component          = gameObject.GetComponent <KPrefabID>();

        component.AddTag(GameTags.SwimmingCreature, false);
        component.AddTag(GameTags.Creatures.Swimmer, false);
        Trait trait = Db.Get().CreateTrait(base_trait_id, name, name, null, false, null, true, true);

        trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, PacuTuning.STANDARD_STOMACH_SIZE, name, false, false, true));
        trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, (0f - PacuTuning.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, 25f, name, false, false, true));
        EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, false, false, true);
        EntityTemplates.ExtendEntityToBasicCreature(gameObject, FactionManager.FactionID.Prey, base_trait_id, "SwimmerNavGrid", NavType.Swim, 32, 2f, "FishMeat", 1, false, false, warnLowTemp, warnHighTemp, warnLowTemp - 20f, warnHighTemp + 20f);
        if (is_baby)
        {
            KBatchedAnimController component2 = gameObject.GetComponent <KBatchedAnimController>();
            component2.animWidth  = 0.5f;
            component2.animHeight = 0.5f;
        }
        ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new AnimInterruptStates.Def(), true).Add(new GrowUpStates.Def(), true)
                                         .Add(new TrappedStates.Def(), true)
                                         .Add(new IncubatingStates.Def(), true)
                                         .Add(new BaggedStates.Def(), true)
                                         .Add(new FallStates.Def
        {
            getLandAnim = new Func <FallStates.Instance, string>(GetLandAnim)
        }, true)
                                         .Add(new DebugGoToStates.Def(), true)
                                         .Add(new FlopStates.Def(), true)
                                         .PushInterruptGroup()
                                         .Add(new FixedCaptureStates.Def(), true)
                                         .Add(new LayEggStates.Def(), true)
                                         .Add(new EatStates.Def(), true)
                                         .Add(new PlayAnimsStates.Def(GameTags.Creatures.Poop, false, "lay_egg_pre", STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.NAME, STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.TOOLTIP), true)
                                         .Add(new MoveToLureStates.Def(), true)
                                         .PopInterruptGroup()
                                         .Add(new IdleStates.Def(), true);
        CreatureFallMonitor.Def def = gameObject.AddOrGetDef <CreatureFallMonitor.Def>();
        def.canSwim = true;
        gameObject.AddOrGetDef <FlopMonitor.Def>();
        gameObject.AddOrGetDef <FishOvercrowdingMonitor.Def>();
        gameObject.AddOrGet <Trappable>();
        gameObject.AddOrGet <LoopingSounds>();
        EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.PacuSpecies, symbol_prefix);
        HashSet <Tag> hashSet = new HashSet <Tag>();

        hashSet.Add(SimHashes.Algae.CreateTag());
        Diet.Info[] infos = new Diet.Info[1]
        {
            new Diet.Info(hashSet, SimHashes.ToxicSand.CreateTag(), CALORIES_PER_KG_OF_ORE, TUNING.CREATURES.CONVERSION_EFFICIENCY.NORMAL, null, 0f, false, false)
        };
        Diet diet = new Diet(infos);

        CreatureCalorieMonitor.Def def2 = gameObject.AddOrGetDef <CreatureCalorieMonitor.Def>();
        def2.diet = diet;
        def2.minPoopSizeInCalories = CALORIES_PER_KG_OF_ORE * MIN_POOP_SIZE_IN_KG;
        SolidConsumerMonitor.Def def3 = gameObject.AddOrGetDef <SolidConsumerMonitor.Def>();
        def3.diet = diet;
        LureableMonitor.Def def4 = gameObject.AddOrGetDef <LureableMonitor.Def>();
        def4.lures = new Tag[1]
        {
            GameTags.Creatures.FishTrapLure
        };
        if (!string.IsNullOrEmpty(symbol_prefix))
        {
            gameObject.AddOrGet <SymbolOverrideController>().ApplySymbolOverridesByAffix(Assets.GetAnim("pacu_kanim"), symbol_prefix, null, 0);
        }
        return(gameObject);
    }
    public static GameObject BaseOilFloater(string id, string name, string desc, string anim_file, string traitId, float warnLowTemp, float warnHighTemp, bool is_baby, string symbolOverridePrefix = null)
    {
        float          mass               = 50f;
        KAnimFile      anim               = Assets.GetAnim(anim_file);
        string         initialAnim        = "idle_loop";
        EffectorValues tIER               = DECOR.BONUS.TIER1;
        float          defaultTemperature = (warnLowTemp + warnHighTemp) / 2f;
        GameObject     gameObject         = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, defaultTemperature);

        gameObject.GetComponent <KPrefabID>().AddTag(GameTags.Creatures.Hoverer, false);
        GameObject template = gameObject;

        FactionManager.FactionID faction = FactionManager.FactionID.Pest;
        string  navGridName      = "FloaterNavGrid";
        NavType navType          = NavType.Hover;
        string  onDeathDropID    = "Meat";
        int     onDeathDropCount = 2;

        EntityTemplates.ExtendEntityToBasicCreature(template, faction, traitId, navGridName, navType, 32, 2f, onDeathDropID, onDeathDropCount, true, false, warnLowTemp, warnHighTemp, warnLowTemp - 15f, warnHighTemp + 20f);
        if (!string.IsNullOrEmpty(symbolOverridePrefix))
        {
            gameObject.AddOrGet <SymbolOverrideController>().ApplySymbolOverridesByAffix(Assets.GetAnim(anim_file), symbolOverridePrefix, null, 0);
        }
        gameObject.AddOrGet <Trappable>();
        gameObject.AddOrGet <LoopingSounds>();
        gameObject.AddOrGetDef <ThreatMonitor.Def>();
        gameObject.AddOrGetDef <SubmergedMonitor.Def>();
        CreatureFallMonitor.Def def = gameObject.AddOrGetDef <CreatureFallMonitor.Def>();
        def.canSwim = true;
        gameObject.AddWeapon(1f, 1f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f);
        EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, true, false, false);
        string inhaleSound = "OilFloater_intake_air";

        if (is_baby)
        {
            inhaleSound = "OilFloaterBaby_intake_air";
        }
        ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new AnimInterruptStates.Def(), true).Add(new GrowUpStates.Def(), true)
                                         .Add(new TrappedStates.Def(), true)
                                         .Add(new IncubatingStates.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)
                                         .PushInterruptGroup()
                                         .Add(new CreatureSleepStates.Def(), true)
                                         .Add(new FixedCaptureStates.Def(), true)
                                         .Add(new RanchedStates.Def(), true)
                                         .Add(new LayEggStates.Def(), true)
                                         .Add(new InhaleStates.Def
        {
            inhaleSound = inhaleSound
        }, true)
                                         .Add(new SameSpotPoopStates.Def(), true)
                                         .Add(new CallAdultStates.Def(), true)
                                         .PopInterruptGroup()
                                         .Add(new IdleStates.Def(), true);
        EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.OilFloaterSpecies, symbolOverridePrefix);
        string sound = "OilFloater_move_LP";

        if (is_baby)
        {
            sound = "OilFloaterBaby_move_LP";
        }
        gameObject.AddOrGet <OilFloaterMovementSound>().sound = sound;
        return(gameObject);
    }