public static GameObject BaseHatch(string id, string name, string desc, string anim_file, string traitId, bool is_baby, string symbolOverridePrefix = null)
    {
        float          mass        = 100f;
        KAnimFile      anim        = Assets.GetAnim(anim_file);
        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);
        string         navGridName = "WalkerNavGrid1x1";

        if (is_baby)
        {
            navGridName = "WalkerBabyNavGrid";
        }
        EntityTemplates.ExtendEntityToBasicCreature(gameObject, FactionManager.FactionID.Pest, traitId, navGridName, NavType.Floor, 32, 2f, "Meat", 2, true, false, 283.15f, 293.15f, 243.15f, 343.15f);
        if (symbolOverridePrefix != null)
        {
            gameObject.AddOrGet <SymbolOverrideController>().ApplySymbolOverridesByAffix(Assets.GetAnim(anim_file), symbolOverridePrefix, null, 0);
        }
        gameObject.AddOrGet <Trappable>();
        gameObject.AddOrGetDef <CreatureFallMonitor.Def>();
        gameObject.AddOrGetDef <BurrowMonitor.Def>();
        WorldSpawnableMonitor.Def def = gameObject.AddOrGetDef <WorldSpawnableMonitor.Def>();
        def.adjustSpawnLocationCb = AdjustSpawnLocationCB;
        ThreatMonitor.Def def2 = gameObject.AddOrGetDef <ThreatMonitor.Def>();
        def2.fleethresholdState = Health.HealthState.Dead;
        gameObject.AddWeapon(1f, 1f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_voice_idle", NOISE_POLLUTION.CREATURES.TIER2);
        SoundEventVolumeCache.instance.AddVolume("FloorSoundEvent", "Hatch_footstep", NOISE_POLLUTION.CREATURES.TIER1);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_land", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_chew", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_voice_hurt", NOISE_POLLUTION.CREATURES.TIER5);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_voice_die", NOISE_POLLUTION.CREATURES.TIER5);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_drill_emerge", NOISE_POLLUTION.CREATURES.TIER6);
        SoundEventVolumeCache.instance.AddVolume("hatch_kanim", "Hatch_drill_hide", NOISE_POLLUTION.CREATURES.TIER6);
        EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, true, true, false);
        KPrefabID component = gameObject.GetComponent <KPrefabID>();

        component.AddTag(GameTags.Creatures.Walker, false);
        component.prefabInitFn += delegate(GameObject inst)
        {
            inst.GetAttributes().Add(Db.Get().Attributes.MaxUnderwaterTravelCost);
        };
        bool condition = !is_baby;

        ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new AnimInterruptStates.Def(), true).Add(new ExitBurrowStates.Def(), condition)
                                         .Add(new PlayAnimsStates.Def(GameTags.Creatures.Burrowed, true, "idle_mound", STRINGS.CREATURES.STATUSITEMS.BURROWED.NAME, STRINGS.CREATURES.STATUSITEMS.BURROWED.TOOLTIP), condition)
                                         .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)
                                         .Add(new FleeStates.Def(), true)
                                         .Add(new AttackStates.Def(), condition)
                                         .PushInterruptGroup()
                                         .Add(new CreatureSleepStates.Def(), true)
                                         .Add(new FixedCaptureStates.Def(), true)
                                         .Add(new RanchedStates.Def(), true)
                                         .Add(new PlayAnimsStates.Def(GameTags.Creatures.WantsToEnterBurrow, false, "hide", STRINGS.CREATURES.STATUSITEMS.BURROWING.NAME, STRINGS.CREATURES.STATUSITEMS.BURROWING.TOOLTIP), condition)
                                         .Add(new LayEggStates.Def(), true)
                                         .Add(new EatStates.Def(), true)
                                         .Add(new PlayAnimsStates.Def(GameTags.Creatures.Poop, false, "poop", STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.NAME, STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.TOOLTIP), true)
                                         .Add(new CallAdultStates.Def(), true)
                                         .PopInterruptGroup()
                                         .Add(new IdleStates.Def(), true);
        EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.HatchSpecies, symbolOverridePrefix);
        return(gameObject);
    }
示例#2
0
        private static GameObject GeneratePlacedEntity()
        {
            GameObject placedEntity = EntityTemplates.CreatePlacedEntity(
                id: Id,
                name: Name,
                desc: Description,
                mass: Mass,
                anim: Assets.GetAnim("living_crystal"),
                initialAnim: "idle_loop",
                sceneLayer: Grid.SceneLayer.Creatures,
                width: 1,
                height: 2,
                decor: TUNING.DECOR.BONUS.TIER3,
                noise: new EffectorValues(),
                element: SimHashes.Creature,
                additionalTags: null,
                defaultTemperature: DefaultTemperature);

            EntityTemplates.ExtendEntityToBasicCreature(
                template: placedEntity,
                faction: FactionManager.FactionID.Prey,
                initialTraitID: BaseTraitId,
                NavGridName: NavGridId,
                navType: NavType.Floor,
                max_probing_radius: 32,
                moveSpeed: 2f,
                onDeathDropID: Elements.AluminumSaltElement.Id,
                onDeathDropCount: 300,
                drownVulnerable: false,
                entombVulnerable: true,
                warningLowTemperature: WarningLowTemperature,
                warningHighTemperature: WarningHighTemperature,
                lethalLowTemperature: LethalLowTemperature,
                lethalHighTemperature: LethalHighTemperature);
            placedEntity.AddOrGet <Trappable>();
            placedEntity.AddOrGetDef <CreatureFallMonitor.Def>();
            WorldSpawnableMonitor.Def def = placedEntity.AddOrGetDef <WorldSpawnableMonitor.Def>();
            placedEntity.AddOrGetDef <ThreatMonitor.Def>().fleethresholdState = Health.HealthState.Scuffed;
            placedEntity.AddOrGetDef <RanchableMonitor.Def>();
            EntityTemplates.CreateAndRegisterBaggedCreature(placedEntity, true, true, false);
            KPrefabID component = placedEntity.GetComponent <KPrefabID>();

            component.AddTag(GameTags.Creatures.Walker, false);
            ChoreTable.Builder chore_table = new ChoreTable.Builder()
                                             .Add(new DeathStates.Def(), true)
                                             .Add(new AnimInterruptStates.Def(), true)
                                             .Add(new TrappedStates.Def(), true)
                                             .Add(new BaggedStates.Def(), true)
                                             .Add(new FallStates.Def(), true)
                                             .Add(new StunnedStates.Def(), true)
                                             .Add(new DebugGoToStates.Def(), true)
                                             .Add(new FleeStates.Def(), true)
                                             .Add(new CreatureSleepStates.Def(), true).PushInterruptGroup()
                                             .Add(new FixedCaptureStates.Def(), true)
                                             .Add(new RanchedStates.Def(), true)
                                             .Add(new LayEggStates.Def(), true)
                                             .Add(new InhaleStates.Def(), true)
                                             .Add(new SameSpotPoopStates.Def(), true)
                                             .Add(new CallAdultStates.Def(), true).PopInterruptGroup()
                                             .Add(new IdleStates.Def(), true);
            EntityTemplates.AddCreatureBrain(placedEntity, chore_table, Id.ToTag(), null);
            return(placedEntity);
        }