Exemplo n.º 1
0
        public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            int  data   = TerrainData.ExtractData(worldItem.Value);
            bool isLaid = EggBlock.GetIsLaid(data);

            if (!EggBlock.GetIsCooked(data) && ((this.m_subsystemGameInfo.WorldInfo.GameMode == GameMode.Creative) || (this.m_random.UniformFloat(0f, 1f) <= (isLaid ? 0.2f : 1f))))
            {
                EggBlock.EggType eggType = this.m_eggBlock.GetEggType(data);
                Entity           entity  = this.m_subsystemEntityFactory.CreateEntity(eggType.TemplateName, true);
                entity.FindComponent <ComponentBody>(true).Position       = worldItem.Position;
                entity.FindComponent <ComponentBody>(true).Rotation       = Quaternion.CreateFromAxisAngle(Vector3.UnitY, this.m_random.UniformFloat(0f, 6.283185f));
                entity.FindComponent <ComponentSpawn>(true).SpawnDuration = 0.25f;
                base.Project.AddEntity(entity);
            }
            return(true);
        }
        public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            int  data     = Terrain.ExtractData(worldItem.Value);
            bool isCooked = EggBlock.GetIsCooked(data);
            bool isLaid   = EggBlock.GetIsLaid(data);

            if (!isCooked && (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative || m_random.Float(0f, 1f) <= (isLaid ? 0.15f : 1f)))
            {
                if (m_subsystemCreatureSpawn.Creatures.Count < 35)
                {
                    EggBlock.EggType eggType = m_eggBlock.GetEggType(data);
                    Entity           entity  = DatabaseManager.CreateEntity(base.Project, eggType.TemplateName, throwIfNotFound: true);
                    entity.FindComponent <ComponentBody>(throwOnError: true).Position       = worldItem.Position;
                    entity.FindComponent <ComponentBody>(throwOnError: true).Rotation       = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.Float(0f, (float)Math.PI * 2f));
                    entity.FindComponent <ComponentSpawn>(throwOnError: true).SpawnDuration = 0.25f;
                    base.Project.AddEntity(entity);
                }
                else
                {
                    ((worldItem as Projectile)?.Owner as ComponentPlayer)?.ComponentGui.DisplaySmallMessage("Too many creatures", Color.White, blinking: true, playNotificationSound: false);
                }
            }
            return(true);
        }