Ejemplo n.º 1
0
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            Fashion      fash = Prefab.GetComponent <Fashion>();
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Image front = Prefab.transform.Find("Icon Pivot/ShopIconUI/Image").GetComponent <Image>();
            Image back  = Prefab.transform.Find("Icon Pivot/ShopIconUI/Image Back").GetComponent <Image>();

            // Setup Components
            fash.slot         = Slot;
            fash.attachPrefab = AttachPrefab ? AttachPrefab : fash.attachPrefab;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            front.sprite = Icon;
            back.sprite  = Icon;
        }
Ejemplo n.º 2
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("waxLump_ld");

            child.transform.localScale = ModelScale;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            MeshFilter   filter = child.GetComponent <MeshFilter>();
            MeshRenderer render = child.GetComponent <MeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;
        }
Ejemplo n.º 3
0
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Image front = Prefab.transform.Find("Icon Pivot/Animation Pivot/ShopIconUI/Image").GetComponent <Image>();
            Image back  = Prefab.transform.Find("Icon Pivot/Animation Pivot/ShopIconUI/Image Back").GetComponent <Image>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            front.sprite = Icon;
            back.sprite  = Icon;

            if (DigitalEffect)
            {
                return;
            }

            front.material = null;
            Object.Destroy(back.gameObject);
        }
Ejemplo n.º 4
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            MeshFilter       filter = Prefab.GetComponent <MeshFilter>();
            MeshRenderer     render = Prefab.GetComponent <MeshRenderer>();
            Rigidbody        body   = Prefab.GetComponent <Rigidbody>();
            Vacuumable       vac    = Prefab.GetComponent <Vacuumable>();
            Identifiable     iden   = Prefab.GetComponent <Identifiable>();
            PlortInstability inst   = Prefab.GetComponent <PlortInstability>();

            // Setup Components
            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;
            body.mass             = Mass;
            vac.size           = Size;
            iden.id            = ID;
            inst.lifetimeHours = LifetimeHours;
        }
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            // Load Components
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            // Setup Components
            spawn.id                  = ID;
            spawn.ObjectsToSpawn      = GameContext.Instance.LookupDirector.GetPrefabs(ToSpawn);
            spawn.BonusObjectsToSpawn = BonusToSpawn != null?GameContext.Instance.LookupDirector.GetPrefabs(BonusToSpawn) : new GameObject[0];

            spawn.MaxObjectsSpawned         = MaxObjectsSpawned;
            spawn.MinObjectsSpawned         = MinObjectsSpawned;
            spawn.MinNutrientObjectsSpawned = MinNutrientObjectsSpawned == -1 ? MaxObjectsSpawned : MinNutrientObjectsSpawned;
            spawn.MinSpawnIntervalGameHours = MinSpawnIntervalGameHours;
            spawn.MaxSpawnIntervalGameHours = MaxSpawnIntervalGameHours;
            spawn.BonusChance        = BonusChance;
            spawn.minBonusSelections = MinBonusSelections;

            // Builds the Spawn Points
            BuildSpawnPoints(spawn);
        }
Ejemplo n.º 6
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            MeshFilter   filter = Prefab.GetComponent <MeshFilter>();
            MeshRenderer render = Prefab.GetComponent <MeshRenderer>();
            Rigidbody    body   = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac    = Prefab.GetComponent <Vacuumable>();
            Identifiable iden   = Prefab.GetComponent <Identifiable>();

            BreakOnImpact imp = Prefab.GetComponent <BreakOnImpact>();

            // Setup Components
            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;
            body.mass             = Mass;
            vac.size = Size;
            iden.id  = ID;

            imp.minSpawns    = MinSpawn;
            imp.maxSpawns    = MaxSpawn;
            imp.spawnOptions = SpawnOptions;
        }
Ejemplo n.º 7
0
        // Methods
        protected override void Build()
        {
            // Create Prefab
            Prefab = PrefabUtils.CopyPrefab(BaseItem);

            // Fix Components
            Object.Destroy(Prefab.GetComponent <EmptyPlotUI>());
            Prefab.AddComponent(UIType);
        }
Ejemplo n.º 8
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("model_pogofruit");

            child.transform.localScale = ModelScale;

            Object.Destroy(Prefab.GetComponent <BoxCollider>());

            // Load Components
            SphereCollider col    = Prefab.AddComponent <SphereCollider>();
            MeshFilter     filter = Prefab.GetComponent <MeshFilter>();
            Rigidbody      body   = Prefab.GetComponent <Rigidbody>();
            Vacuumable     vac    = Prefab.GetComponent <Vacuumable>();
            Identifiable   iden   = Prefab.GetComponent <Identifiable>();

            ResourceCycle cycle = IsPlantable ? Prefab.GetComponent <ResourceCycle>() : null;

            MeshFilter   model  = child.GetComponent <MeshFilter>();
            MeshRenderer render = child.GetComponent <MeshRenderer>();

            // Setup Components
            col.radius        = ModelScale.x;
            filter.sharedMesh = Mesh;
            body.mass         = Mass;
            vac.size          = Size;
            iden.id           = ID;

            if (IsPlantable)
            {
                if (cycle != null)
                {
                    cycle.unripeGameHours    = UnripeGameHours;
                    cycle.ripeGameHours      = RipeGameHours;
                    cycle.edibleGameHours    = EdibleGameHours;
                    cycle.rottenGameHours    = RottenGameHours;
                    cycle.rottenMat          = RottenMat ? RottenMat : cycle.rottenMat;
                    cycle.vacuumableWhenRipe = VacuumableWhenRipe;
                }
            }
            else
            {
                Object.Destroy(Prefab.GetComponent <ResourceCycle>());
            }

            model.sharedMesh      = Mesh;
            render.sharedMaterial = ModelMat;
        }
Ejemplo n.º 9
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Load Material
            TreeMat   = CreateTreeMat();
            LeavesMat = CreateLeavesMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            GameObject tree = Prefab.FindChild("tree_pogo");

            tree.transform.localScale = TreeScale;

            GameObject leaves = tree.FindChild("leaves_pogo");

            leaves.transform.localScale = LeavesScale;

            // Load Components
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            MeshFilter   tMesh   = tree.GetComponent <MeshFilter>();
            MeshRenderer tRender = tree.GetComponent <MeshRenderer>();
            MeshCollider tCol    = tree.GetComponent <MeshCollider>();

            MeshFilter   lMesh   = leaves.GetComponent <MeshFilter>();
            MeshRenderer lRender = leaves.GetComponent <MeshRenderer>();
            MeshCollider lCol    = tree.GetComponent <MeshCollider>();

            // Setup Components
            spawn.id                  = ID;
            spawn.ObjectsToSpawn      = GameContext.Instance.LookupDirector.GetPrefabs(ToSpawn);
            spawn.BonusObjectsToSpawn = BonusToSpawn != null?GameContext.Instance.LookupDirector.GetPrefabs(BonusToSpawn) : new GameObject[0];

            spawn.MaxObjectsSpawned         = MaxObjectsSpawned;
            spawn.MinObjectsSpawned         = MinObjectsSpawned;
            spawn.MinNutrientObjectsSpawned = MinNutrientObjectsSpawned == -1 ? MaxObjectsSpawned : MinNutrientObjectsSpawned;
            spawn.MinSpawnIntervalGameHours = MinSpawnIntervalGameHours;
            spawn.MaxSpawnIntervalGameHours = MaxSpawnIntervalGameHours;
            spawn.BonusChance        = BonusChance;
            spawn.minBonusSelections = MinBonusSelections;

            tMesh.sharedMesh       = TreeMesh ?? tMesh.sharedMesh;
            tRender.sharedMaterial = TreeMat ?? tRender.sharedMaterial;
            tCol.sharedMesh        = TreeMesh ?? tCol.sharedMesh;

            lMesh.sharedMesh       = LeavesMesh ?? lMesh.sharedMesh;
            lRender.sharedMaterial = LeavesMat ?? lRender.sharedMaterial;
            lCol.sharedMesh        = LeavesMesh ?? lCol.sharedMesh;

            // Builds the Spawn Points
            BuildSpawnPoints(spawn);
        }
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BasePrefab);
            Prefab.name = NamePrefix + Name;

            // Load Components
            Gadget gadget = Prefab.AddComponent <Gadget>();

            // Setup Components
            gadget.id = ID;
        }
Ejemplo n.º 11
0
        // Static Constructors to load the base objects
        static SRObjects()
        {
            MissingIcon = Get <Sprite>("unknownSmall");
            MissingImg  = Get <Sprite>("unknownLarge");

            BaseLargo = PrefabUtils.CopyPrefab(Get <GameObject>("slimePinkTabby"));

            Object.Destroy(BaseLargo.GetComponent <PinkSlimeFoodTypeTracker>());
            Object.Destroy(BaseLargo.GetComponent <StalkConsumable>());
            Object.Destroy(BaseLargo.GetComponent <GatherIdentifiableItems>());
            Object.Destroy(BaseLargo.GetComponent <AttackPlayer>());
        }
Ejemplo n.º 12
0
 static IdHandlerUtils()
 {
     SRCallbacks.PreSaveGameLoad += (s) =>
     {
         foreach (IdHandler handler in UnityEngine.Object.FindObjectsOfType <IdHandler>())
         {
             if (!idHandlerPrefabs.ContainsKey(handler.GetType()))
             {
                 idHandlerPrefabs[handler.GetType()] = PrefabUtils.CopyPrefab(handler.gameObject);
             }
         }
     };
 }
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            // Load Components
            Gadget     gadget = Prefab.GetComponent <Gadget>();
            FashionPod pod    = Prefab.GetComponent <FashionPod>();

            // Setup Components
            gadget.id     = ID;
            pod.fashionId = FashionID;
        }
Ejemplo n.º 14
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("Sphere");

            child.transform.localScale = ModelScale;

            GameObject cPart = child.FindChild("FX Water Glops");

            // Load Components
            Rigidbody         body = Prefab.GetComponent <Rigidbody>();
            Vacuumable        vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable      iden = Prefab.GetComponent <Identifiable>();
            DestroyOnTouching dest = Prefab.GetComponent <DestroyOnTouching>();

            MeshFilter   filter = child.GetComponent <MeshFilter>();
            MeshRenderer render = child.GetComponent <MeshRenderer>();

            ParticleSystemRenderer part = cPart.GetComponent <ParticleSystemRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            dest.liquidType = ID;
            dest.destroyFX  = PrefabUtils.CopyPrefab(dest.destroyFX);

            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;

            part.mesh           = Mesh;
            part.sharedMaterial = ModelMat;

            // Setup After effect
            GameObject cPart2 = dest.destroyFX.FindChild("Water Glops");

            ParticleSystemRenderer part2 = cPart2.GetComponent <ParticleSystemRenderer>();

            part2.mesh           = Mesh;
            part2.sharedMaterial = ModelMat;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets a fixed prefab for an ID
        /// </summary>
        /// <param name="id">ID to search for</param>
        /// <param name="fix">Fix to apply if not present</param>
        public static GameObject GetFixedPrefab(Identifiable.Id id, Action <GameObject> fix)
        {
            if (fixes.ContainsKey(id))
            {
                return(fixes[id]);
            }

            GameObject obj = PrefabUtils.CopyPrefab(GameContext.Instance.LookupDirector.GetPrefab(id));

            fix.Invoke(obj);

            fixes.Add(id, obj);

            return(fixes[id]);
        }
Ejemplo n.º 16
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("Body");

            child.transform.localScale = ModelScale;

            GameObject child2 = Prefab.transform.Find("Chickadoo/mesh_body1").gameObject;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            EggActivator       egg   = Prefab.GetComponent <EggActivator>();
            TransformAfterTime trans = Prefab.GetComponent <TransformAfterTime>();

            MeshFilter          model   = child.GetComponent <MeshFilter>();
            SkinnedMeshRenderer mRender = child2.GetComponent <SkinnedMeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            trans.delayGameHours = DelayGameHours;
            trans.options        = Options;

            egg.eggPeriod = EggPeriod;

            model.sharedMesh       = Mesh;
            mRender.sharedMaterial = ModelMat;

            foreach (MeshRenderer render in Prefab.transform.Find("Chickadoo/root").GetComponentsInChildren <MeshRenderer>())
            {
                if (render.sharedMaterial.name.Equals("Chickadoo"))
                {
                    render.sharedMaterial = ModelMat;
                }
            }
        }
Ejemplo n.º 17
0
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            GameObject uiAct = Prefab.transform.Find("techActivator/triggerActivate").gameObject;

            // Load Components
            LandPlot    plot      = Prefab.GetComponent <LandPlot>();
            UIActivator activator = uiAct.GetComponent <UIActivator>();

            // Setup Components
            plot.typeId        = ID;
            activator.uiPrefab = UIPrefab ?? activator.uiPrefab;
        }
Ejemplo n.º 18
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.transform.Find("Full size/slime_gordo").gameObject;

            // Load Components
            GordoEat     eat = Prefab.GetComponent <GordoEat>();
            GordoRewards rew = Prefab.GetComponent <GordoRewards>();

            GordoDisplayOnMap disp = Prefab.GetComponent <GordoDisplayOnMap>();
            GordoIdentifiable iden = Prefab.GetComponent <GordoIdentifiable>();

            MeshFilter filter = Prefab.FindChild("Full size").GetComponent <MeshFilter>();

            SkinnedMeshRenderer render = child.GetComponent <SkinnedMeshRenderer>();

            // Setup Components
            filter.sharedMesh   = Mesh;
            eat.slimeDefinition = Definition;
            eat.targetCount     = TargetCount;

            List <GameObject> rews = new List <GameObject>();

            if (Rewards != null)
            {
                foreach (Identifiable.Id id in Rewards)
                {
                    rews.Add(GameContext.Instance.LookupDirector.GetPrefab(id));
                }
            }

            rew.rewardPrefabs = rews.ToArray();

            iden.id          = ID;
            iden.nativeZones = NativeZones;

            disp.markerPrefab = MarkerPrefab ? MarkerPrefab : disp.markerPrefab;

            render.sharedMaterial = ModelMat;
        }
Ejemplo n.º 19
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Load Material
            ModelMat = SRObjects.GetInst <Material>("EchoBlue");
            ModelMat.SetColor(TINT_COLOR, ColorUtils.FromHex("22222222"));
            ModelMat.SetFloat(BRIGHTNESS, 0.1f);
            ModelMat.SetFloat(ANIMATION_SPEED, 0f);

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("model");

            child.transform.localScale = ModelScale;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            MeshFilter   filter = child.GetComponent <MeshFilter>();
            MeshRenderer render = child.GetComponent <MeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;

            // Setup Proximity
            Prefab.AddComponent <EffyProximity>();

            // Add Particles
            GameObject part = Object.Instantiate(EffyParticles, Prefab.transform, true);

            part.name = "EffyPart";
            part.transform.localScale = Vector3.one;
        }
Ejemplo n.º 20
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("model");

            child.transform.localScale = ModelScale;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            MeshFilter   filter = child.GetComponent <MeshFilter>();
            MeshRenderer render = child.GetComponent <MeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;

            // Echo Note
            if (IsNote)
            {
                EchoNote note = Prefab.FindChild("echo_note").GetComponent <EchoNote>();
                note.clip = Clip;
            }
            else
            {
                Object.Destroy(Prefab.FindChild("echo_note"));
            }
        }
Ejemplo n.º 21
0
        protected override void Build()
        {
            // Get GameObjects
            Prefab = CustomBase != null?PrefabUtils.CopyPrefab(CustomBase) : PrefabUtils.CopyPrefab(BaseItem);

            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale * Definition.PrefabScale;

            // Load Components
            SlimeAppearanceApplicator app = Prefab.GetComponent <SlimeAppearanceApplicator>();
            SlimeVarietyModules       mod = Prefab.GetComponent <SlimeVarietyModules>();
            SlimeEat    eat = Prefab.GetComponent <SlimeEat>();
            SlimeHealth hp  = Prefab.GetComponent <SlimeHealth>();

            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            // Setup Components
            app.SlimeDefinition = Definition;
            app.Appearance      = Definition.AppearancesDefault[0];
            mod.baseModule      = Definition.BaseModule;
            mod.slimeModules    = Definition.SlimeModules;

            eat.slimeDefinition    = Definition;
            eat.minDriveToEat      = MinDriveToEat;
            eat.drivePerEat        = DrivePerEat;
            eat.agitationPerEat    = AgitationPerEat;
            eat.agitationPerFavEat = AgitationPerFavEat;

            hp.maxHealth = Health;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            // Get rid of unneeded components
            Object.Destroy(Prefab.GetComponent <PinkSlimeFoodTypeTracker>());
        }
        protected override void Build()
        {
            // Pre Build Manipulation

            // Build Control
            base.Build();

            // Post Build Manipulation
            Fashion fash  = Prefab.GetComponent <Fashion>();
            Fashion other = SRObjects.Get <GameObject>("fashionHandlebar").GetComponent <Fashion>();

            fash.attachPrefab = PrefabUtils.CopyPrefab(other.attachPrefab);
            Material mat = SRObjects.GetInst <Material>("FashionPod1");

            for (int i = 0; i < 8; i++)
            {
                mat.SetColor("_Color" + i + "0", ColorUtils.FromHex("eeeeee"));
                mat.SetColor("_Color" + i + "1", ColorUtils.FromHex("aaaaaa"));
            }

            fash.attachPrefab.FindChild("model_fp_handlebars").GetComponent <MeshRenderer>().sharedMaterial = mat;
        }
Ejemplo n.º 23
0
 // OBTAIN CHILD
 public static GameObject GetChildCopy(this GameObject obj, string name) => PrefabUtils.CopyPrefab(obj.FindChild(name));
Ejemplo n.º 24
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("Body");

            child.transform.localScale = ModelScale;

            GameObject child2 = Prefab.transform.Find("Hen Hen/mesh_body1").gameObject;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Reproduce rep = Prefab.GetComponent <Reproduce>();
            TransformChanceOnReproduce trans = Prefab.GetComponent <TransformChanceOnReproduce>();

            MeshFilter          model   = child.GetComponent <MeshFilter>();
            SkinnedMeshRenderer mRender = child2.GetComponent <SkinnedMeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            if (IsFemale)
            {
                rep.nearMateId = GameContext.Instance.LookupDirector.GetPrefab(MateID).GetComponent <Identifiable>();

                List <Identifiable> ids = new List <Identifiable>()
                {
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.PAINTED_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.BRIAR_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.STONY_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.ELDER_HEN).GetComponent <Identifiable>()
                };

                if (DensityIDs != null)
                {
                    foreach (Identifiable.Id id in DensityIDs)
                    {
                        Identifiable toAdd = GameContext.Instance.LookupDirector.GetPrefab(id).GetComponent <Identifiable>();
                        if (!ids.Contains(toAdd))
                        {
                            ids.Add(toAdd);
                        }
                    }
                }

                rep.densityIds            = ids.ToArray();
                rep.childPrefab           = GameContext.Instance.LookupDirector.GetPrefab(ChildID);
                rep.minReproduceGameHours = MinReproduceGameHours;
                rep.maxReproduceGameHours = MaxReproduceGameHours;
            }
            else
            {
                Object.Destroy(rep);
            }

            if (!IsElder)
            {
                trans.transformChance = ElderChance;
                trans.targetPrefab    = GameContext.Instance.LookupDirector.GetPrefab(ElderID);
            }
            else
            {
                Object.Destroy(trans);
            }

            model.sharedMesh       = Mesh;
            mRender.sharedMaterial = ModelMat;

            foreach (MeshRenderer render in Prefab.transform.Find("Hen Hen/root").GetComponentsInChildren <MeshRenderer>())
            {
                if (render.sharedMaterial.name.Equals("HenHen"))
                {
                    render.sharedMaterial = ModelMat;
                }
            }
        }
Ejemplo n.º 25
0
        // Called before GameContext.Start
        // Used for registering things that require a loaded gamecontext
        public override void Load()
        {
            SlimeDefinition mapleDefinition = PrefabUtils.DeepCopyObject(SRSingleton<GameContext>.Instance.SlimeDefinitions.GetSlimeByIdentifiableId(Identifiable.Id.PINK_SLIME)) as SlimeDefinition;
            mapleDefinition.AppearancesDefault = new SlimeAppearance[1];
            mapleDefinition.Diet.Produces = new Identifiable.Id[]
            {
                ModdedIds.MAPLE_PLORT
            };
            mapleDefinition.Diet.MajorFoodGroups = new SlimeEat.FoodGroup[]
            {
                SlimeEat.FoodGroup.FRUIT
            };
            mapleDefinition.Diet.AdditionalFoods = new Identifiable.Id[0];
            mapleDefinition.Diet.Favorites = new Identifiable.Id[]
            {
                Identifiable.Id.POGO_FRUIT
            };
            List<SlimeDiet.EatMapEntry> eatMap = mapleDefinition.Diet.EatMap;
            if (eatMap != null)
            {
                eatMap.Clear();
            }
            mapleDefinition.CanLargofy = false;
            mapleDefinition.FavoriteToys = new Identifiable.Id[0];
            mapleDefinition.Name = "Maple";
            mapleDefinition.IdentifiableId = ModdedIds.MAPLE_SLIME;
            SlimeDefinition pinkSlimeDefinition = SRSingleton<GameContext>.Instance.SlimeDefinitions.GetSlimeByIdentifiableId(Identifiable.Id.PINK_SLIME);
            GameObject mapleGameObject = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_SLIME));
            mapleGameObject.name = "mapleSlime";
            mapleGameObject.GetComponent<PlayWithToys>().slimeDefinition = mapleDefinition;
            mapleGameObject.GetComponent<SlimeAppearanceApplicator>().SlimeDefinition = mapleDefinition;
            mapleGameObject.GetComponent<SlimeEat>().slimeDefinition = mapleDefinition;
            SlimeAppearance mapleAppearance = PrefabUtils.DeepCopyObject(pinkSlimeDefinition.AppearancesDefault[0]) as SlimeAppearance;
            foreach (SlimeAppearanceStructure slimeAppearanceStructure in mapleAppearance.Structures)
            {
                Material[] defaultMaterials = slimeAppearanceStructure.DefaultMaterials;
                bool flag = ((defaultMaterials != null) ? defaultMaterials.Length : 0) == 0;
                if (!flag)
                {
                    Material material = UnityEngine.Object.Instantiate<Material>(slimeAppearanceStructure.DefaultMaterials[0]);
                    material.SetColor(topColorNameId, new Color(87.0f / 255.0f, 32.0f / 255.0f, 0.0f / 255.0f)); // new Color(216.0f / 255.0f, 120.0f / 255.0f , 63.0f / 255.0f)
                    material.SetColor(middleColorNameId, new Color(164.0f / 255.0f, 75.0f / 255.0f, 23.0f / 255.0f)); // new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f)
                    material.SetColor(bottomColorNameId, new Color(226.0f / 255.0f, 123.0f / 255.0f, 63.0f / 255.0f)); // new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f)
                    material.SetColor("_SpecColor", Color.red);
                    material.SetFloat("_Shininess", 5f);
                    material.SetFloat("_Gloss", 5f);
                    slimeAppearanceStructure.DefaultMaterials[0] = material;
                }
            }
            foreach(SlimeExpressionFace slimeExpressionFace in mapleAppearance.Face.ExpressionFaces)
            {
                bool flag2 = slimeExpressionFace.Mouth;
                if (flag2)
                { 
                    slimeExpressionFace.Mouth.SetColor("_MouthBot", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                    slimeExpressionFace.Mouth.SetColor("_MouthMid", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                    slimeExpressionFace.Mouth.SetColor("_MouthTop", new Color(145.0f / 255.0f, 17.0f / 255.0f, 17.0f / 255.0f));
                }

                bool flag3 = slimeExpressionFace.Eyes;
                if (flag3)
                {
                    slimeExpressionFace.Eyes.SetColor("_EyeBlue", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_EyeGreen", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_EyeRed", Color.black);
                    slimeExpressionFace.Eyes.SetColor("_GlowColor", Color.black);
                }
            }
            mapleAppearance.Face.OnEnable();
            mapleAppearance.ColorPalette = new SlimeAppearance.Palette
            {
                Bottom = new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f),
                Middle = new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f),
                Top = new Color(216.0f / 255.0f, 120.0f / 255.0f, 63.0f / 255.0f),
                Ammo = new Color(194.0f / 255.0f, 99.0f / 255.0f, 44.0f / 255.0f)
            };
            Sprite mapleSlimeSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.MapleSlime.png");
            mapleAppearance.Icon = mapleSlimeSprite;
            mapleDefinition.AppearancesDefault = new SlimeAppearance[]
            {
                mapleAppearance
            };
            mapleGameObject.GetComponent<Identifiable>().id = ModdedIds.MAPLE_SLIME;
            LookupRegistry.RegisterIdentifiablePrefab(mapleGameObject);
            SlimeRegistry.RegisterSlimeDefinition(mapleDefinition);
            Material maplePlortMaterial = SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_PLORT).GetComponentInChildren<MeshRenderer>().material;
            GameObject maplePlortObject = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.PINK_PLORT));
            maplePlortObject.GetComponent<Identifiable>().id = ModdedIds.MAPLE_PLORT;
            maplePlortObject.name = "maplePlort";
            maplePlortMaterial = UnityEngine.Object.Instantiate<Material>(maplePlortMaterial);
            maplePlortMaterial.SetColor(topColorNameId, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f));
            maplePlortMaterial.SetColor(middleColorNameId, new Color(87.0f / 255.0f, 32.0f / 255.0f, 0.0f / 255.0f));
            maplePlortMaterial.SetColor(bottomColorNameId, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f));
            maplePlortObject.GetComponentInChildren<MeshRenderer>().material = maplePlortMaterial;
            LookupRegistry.RegisterIdentifiablePrefab(maplePlortObject);
            Sprite maplePlortSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.MaplePlort.png");
            LookupRegistry.RegisterVacEntry(ModdedIds.MAPLE_PLORT, new Color(182.0f / 255.0f, 86.0f / 255.0f, 33.0f / 255.0f), maplePlortSprite);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, maplePlortObject);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, mapleGameObject);
            PediaRegistry.RegisterIdEntry(ModdedIds.MAPLE_SLIMES, mapleSlimeSprite);
            PlortRegistry.AddEconomyEntry(ModdedIds.MAPLE_PLORT, 35f, 50f);
            DroneRegistry.RegisterBasicTarget(ModdedIds.MAPLE_PLORT);

            Mesh pogoMesh = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.POGO_FRUIT)).GetComponent<Mesh>();
            MeshRenderer[] pogoMeshRenderers = PrefabUtils.CopyPrefab(SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(Identifiable.Id.POGO_FRUIT)).GetComponentsInChildren<MeshRenderer>();
            IEnumerable<Material> pogoMaterials = new List<Material>();
            foreach(MeshRenderer renderer in pogoMeshRenderers)
            {
                foreach(Material material in renderer.materials)
                {
                    pogoMaterials = pogoMaterials.Append(material);
                }
            }
            SRML.Console.Console.Log("pogoMaterials.Count(): " + pogoMaterials.Count().ToString());
            SRML.Console.Console.Log("pogoMaterials.ToArray().Length: " + pogoMaterials.ToArray().Length.ToString());
            TestingUtils.DumpChildComponents(Identifiable.Id.POGO_FRUIT);
            FoodTemplate caramelAppleTemplate = new FoodTemplate("caramelApple", ModdedIds.CARAMEL_APPLE_FRUIT, ModdedIds.CARAMEL_APPLES, FoodTemplate.Type.FRUIT, pogoMesh, pogoMaterials.ToArray());
            caramelAppleTemplate = caramelAppleTemplate.SetTranslation("Caramel Apple");
            GameObject caramelAppleObject = caramelAppleTemplate.Create().ToPrefab();
            caramelAppleObject.GetComponent<Identifiable>().id = ModdedIds.CARAMEL_APPLE_FRUIT;
            caramelAppleObject.GetComponent<Vacuumable>().size = Vacuumable.Size.NORMAL;
            caramelAppleObject.name = "caramelApple";
            LookupRegistry.RegisterIdentifiablePrefab(caramelAppleObject);
            Sprite caramelAppleSprite = IMG2Sprite.LoadNewSprite("SDTestModNew.CaramelApple.png");
            LookupRegistry.RegisterVacEntry(ModdedIds.CARAMEL_APPLE_FRUIT, Color.green, caramelAppleSprite);
            AmmoRegistry.RegisterAmmoPrefab(PlayerState.AmmoMode.DEFAULT, caramelAppleObject);
            PediaRegistry.RegisterIdEntry(ModdedIds.CARAMEL_APPLES, caramelAppleSprite);
            DroneRegistry.RegisterBasicTarget(ModdedIds.CARAMEL_APPLE_FRUIT);
            TestingUtils.DumpChildComponents(ModdedIds.CARAMEL_APPLE_FRUIT);

            CrateTemplate testCrateTemplate = new CrateTemplate("testCrate", ModdedIds.TEST_CRATE_01);
            testCrateTemplate = testCrateTemplate.SetSpawnInfo(3, 5);
            List<BreakOnImpact.SpawnOption> testCrateSpawnOptions = new List<BreakOnImpact.SpawnOption>();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.MANGO_FRUIT, 1.5f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.POGO_FRUIT, 3.0f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.CARROT_VEGGIE, 3.0f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.OCAOCA_VEGGIE, 1.5f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.PEAR_FRUIT, 0.25f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.PARSNIP_VEGGIE, 0.25f)).ToList();
            testCrateSpawnOptions = testCrateSpawnOptions.Append(SpawnOptionByID(Identifiable.Id.GINGER_VEGGIE, 0.0001f)).ToList();
            testCrateTemplate.SetSpawnOptions(testCrateSpawnOptions);
            GameObject testCrateObject = testCrateTemplate.Create().ToPrefab();
            LookupRegistry.RegisterIdentifiablePrefab(testCrateObject);
        }
Ejemplo n.º 26
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            //foreach (Identifiable.Id slime in Identifiable.SLIME_CLASS)
            //{
            // Make new Definition
            SlimeDefinition other  = SlimeUtils.GetDefinitionByID(Identifiable.Id.PINK_SLIME);
            SlimeDefinition newDef = Definition.CombineForLargo(other);

            // Translation
            DefTranslation.Add(newDef.IdentifiableId, Regex.Replace(Definition.Name, "(\\B[A-Z])", " $1") + " " + Regex.Replace(other.Name, "(\\B[A-Z])", " $1") + " Largo");

            //if (newDef == null)
            //	continue;

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Definition.Name + other.Name;
            Prefab.transform.localScale = Scale * newDef.PrefabScale;

            // PRIMARY SETUP
            // Load Components
            SlimeAppearanceApplicator app = Prefab.GetComponent <SlimeAppearanceApplicator>();
            SlimeVarietyModules       mod = Prefab.GetComponent <SlimeVarietyModules>();

            // Setup Components
            app.SlimeDefinition = newDef;
            mod.baseModule      = newDef.BaseModule;
            mod.slimeModules    = newDef.SlimeModules;

            mod.Assemble();

            // SECONDARY SETUP
            // Load Components
            SlimeEat    eat = Prefab.GetComponent <SlimeEat>();
            SlimeHealth hp  = Prefab.GetComponent <SlimeHealth>();

            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            // Setup Components
            eat.slimeDefinition    = newDef;
            eat.minDriveToEat      = MinDriveToEat;
            eat.drivePerEat        = DrivePerEat;
            eat.agitationPerEat    = AgitationPerEat;
            eat.agitationPerFavEat = AgitationPerFavEat;

            hp.maxHealth = Health;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = newDef.IdentifiableId;

            // TERTIARY SETUP
            // Load Components
            SlimeEmotions emot  = Prefab.GetComponent <SlimeEmotions>();
            SlimeEmotions emot2 = BaseItem.GetComponent <SlimeEmotions>();

            emot.initAgitation = emot2.initAgitation;
            emot.initFear      = emot2.initFear;
            emot.initHunger    = emot2.initHunger;

            // Add to Largo List
            Prefabs.Add(newDef.IdentifiableId, Prefab);
            //}
        }