예제 #1
0
 public GPHairRenderData(HairSettings settings, ComputeBuffer bodiesBuffer)
 {
     this.settings     = settings;
     this.bodiesBuffer = bodiesBuffer;
     barycentric       = new GPBarycentricBuilder();
     bodiesDataBuilder = new GPHairBodyDataBuilder(settings);
 }
예제 #2
0
        public Color GetColor(HairSettings settings, int x, int y, int sizeY)
        {
            var colors = settings.StandsSettings.Provider.GetColors();
            var i      = x * sizeY + y;

            return(colors[i]);
        }
예제 #3
0
        public GPHairPhysicsData(HairSettings settings)
        {
            this.settings = settings;

            stands    = new GPHairStandsBuilder(settings);
            kinematic = new GPKinematicBuilder(settings);
            wind      = new WindReceiver();
        }
예제 #4
0
        public GPHairStandsBuilder(HairSettings settings)
        {
            this.settings = settings;
            provider      = settings.StandsSettings.Provider;

            UpdateBodies();
            CreatePointJoints();
            CreateDistanceJoints();
        }
예제 #5
0
        private void OnEnable()
        {
            settings = target as HairSettings;

            processor.Add(new HairStandsEditor(settings));

            processor.Add(new HairStandsInspector(settings));
            processor.Add(new HairPhysicsInspector(settings));
            processor.Add(new HairRenderInspector(settings));
            processor.Add(new HairShadowInspector(settings));
            processor.Add(new HairLODInspector(settings));
            processor.Add(new HairStatisticsInspector(settings));
        }
예제 #6
0
        public GPHairJointsBuilder(HairSettings settings)
        {
            this.settings = settings;

            var joints   = new List <GPPointJoint>();
            var vertices = settings.StandsSettings.Provider.GetVertices();
            var matrices = settings.StandsSettings.Provider.GetTransforms();

            foreach (var jointArea in settings.PhysicsSettings.JointAreas)
            {
                joints.AddRange(ProcessJointArea(jointArea, vertices, matrices[0]));
            }

            Joints = joints.ToArray();
        }
예제 #7
0
        private GameObject BuildHair(HairSettings settings)
        {
            obj = new GameObject("Render");

            var physicsData = new GPHairPhysicsData(settings);

            physics = obj.AddComponent <GPHairPhysics>();
            physics.Initialize(physicsData);

            var renderDara = new GPHairRenderData(settings, physics.GetBodiesBuffer());

            render = obj.AddComponent <HairRender>();
            render.Initialize(renderDara);

            return(obj);
        }
예제 #8
0
        public static AlienRace InitializeAlienRace(ThingDef_AlienRace raceDef, Pawn p)
        {
            ThingDef_AlienRace.AlienSettings race = raceDef.alienRace;
            GeneralSettings    generalSettings    = race?.generalSettings;
            AlienPartGenerator alienPartGenerator = generalSettings?.alienPartGenerator;

            if (alienPartGenerator == null)
            {
                return(null);
            }

            List <GraphicPaths> graphicsPaths = race.graphicPaths;

            if (graphicsPaths == null)
            {
                return(null);
            }

            // We have enough to start putting together the result object, so we instantiate it now.
            AlienRace result = new AlienRace();

            // Get the list of body types.
            List <BodyTypeDef> alienbodytypes = alienPartGenerator.alienbodytypes;

            if (alienbodytypes == null)
            {
                return(null);
            }

            List <BodyTypeDef> bodyTypes = new List <BodyTypeDef>();

            if (alienbodytypes.Count > 0)
            {
                foreach (BodyTypeDef o in alienbodytypes)
                {
                    bodyTypes.Add(o);
                }
            }

            result.BodyTypes = bodyTypes;

            // Determine if the alien races uses gender-specific heads.
            result.GenderSpecificHeads = alienPartGenerator.useGenderedHeads;

            result.CrownTypes = alienPartGenerator.aliencrowntypes;

            // Go through the graphics paths and find the heads path.
            string graphicsPathForHeads = null;

            foreach (GraphicPaths graphicsPath in graphicsPaths)
            {
                ICollection lifeStageCollection = GetFieldValueAsCollection(raceDef, graphicsPath, "lifeStageDefs");
                if (lifeStageCollection == null || lifeStageCollection.Count == 0)
                {
                    string path = GetFieldValueAsString(raceDef, graphicsPath, "head");
                    if (path != null)
                    {
                        graphicsPathForHeads = path;
                        break;
                    }
                }
            }

            result.GraphicsPathForHeads = graphicsPathForHeads;

            // Figure out colors.
            ColorGenerator primaryGenerator = alienPartGenerator.alienskincolorgen;

            result.UseMelaninLevels = true;
            if (primaryGenerator != null)
            {
                result.UseMelaninLevels = false;
                result.PrimaryColors    = primaryGenerator.GetColorList();
            }
            else
            {
                result.PrimaryColors = new List <Color>();
            }

            ColorGenerator secondaryGenerator = alienPartGenerator.alienskinsecondcolorgen;

            result.HasSecondaryColor = false;
            if (secondaryGenerator != null)
            {
                result.HasSecondaryColor = true;
                result.SecondaryColors   = secondaryGenerator.GetColorList();
            }
            else
            {
                result.SecondaryColors = new List <Color>();
            }

            // Hair properties.
            HairSettings hairSettings = race.hairSettings;

            result.HasHair = false;
            if (hairSettings != null)
            {
                result.HasHair = hairSettings.hasHair;

                if (hairSettings.hairTags.NullOrEmpty())
                {
                    result.HairTags = p.kindDef.defaultFactionType.hairTags;
                }
                else
                {
                    result.HairTags = hairSettings.hairTags;
                }
            }

            ColorGenerator hairColorGenerator = alienPartGenerator.alienhaircolorgen;

            if (hairColorGenerator != null)
            {
                result.HairColors = primaryGenerator.GetColorList();
            }
            else
            {
                result.HairColors = null;
            }

            return(result);
        }
 public HairPhysicsInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #10
0
 public HairShadowInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #11
0
 public HairLODInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #12
0
        //private Vector3 cachedHeadCenter;

        public HairStandsEditor(HairSettings settings)
        {
            this.settings = settings;
        }
예제 #13
0
 public Color GetColor(HairSettings settings, int x, int y, int sizeY)
 {
     return(GetStandColor((float)y / sizeY));
 }
예제 #14
0
        public GPHairBuilder(HairSettings settings)
        {
            var hairObj = BuildHair(settings);

            hairObj.transform.SetParent(settings.transform.parent, false);
        }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     myHair = GetComponent <HairSettings>();
 }
예제 #16
0
 public HairRenderInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #17
0
 public HairStandsInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #18
0
 public HairStatisticsInspector(HairSettings settings)
 {
     this.settings = settings;
 }
예제 #19
0
 public GPKinematicBuilder(HairSettings settings)
 {
     this.settings = settings;
     UpdateBodies(settings.PhysicsSettings.Colliders);
 }
예제 #20
0
 public GPHairBodyDataBuilder(HairSettings settings)
 {
     this.settings = settings;
     provider      = settings.StandsSettings.Provider;
 }
예제 #21
0
        protected override void Initialize()
        {
            AlienComp ac = base.Pawn.TryGetComp <AlienComp>();

            if (ac == null || !(base.Pawn.def is ThingDef_AlienRace ar))
            {
                Log.Error("Failed to get alien race for " + base.Pawn.Name.ToStringShort);
                return;
            }
            AlienSettings   raceSettings    = ar.alienRace;
            GeneralSettings generalSettings = raceSettings?.generalSettings;

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserAlienSkinColor))
            {
#if ALIEN_DEBUG
                Log.Warning("AlienDresserDTO.initialize - start");
#endif
                if (raceSettings != null)
                {
                    HairSettings hairSettings = raceSettings.hairSettings;
                    var          c            = ac.GetChannel("skin");
                    if (c != null)
                    {
                        base.AlienSkinColorPrimary = new SelectionColorWidgetDTO(c.first);
                        base.AlienSkinColorPrimary.SelectionChangeListener += this.PrimarySkinColorChange;

                        base.AlienSkinColorSecondary = new SelectionColorWidgetDTO(c.second);
                        base.AlienSkinColorPrimary.SelectionChangeListener += this.SecondarySkinColorChange;
                    }

                    if (hairSettings?.hasHair == true)
                    {
                        base.HairColorSelectionDto = new HairColorSelectionDTO(this.Pawn.story.hairColor, IOUtil.LoadColorPresets(ColorPresetType.Hair));
                        base.HairColorSelectionDto.SelectionChangeListener += this.PrimaryHairColorChange;

                        ColorPresetsDTO hairColorPresets = IOUtil.LoadColorPresets(ColorPresetType.Hair);
                        if (GradientHairColorUtil.IsGradientHairAvailable)
                        {
                            if (!GradientHairColorUtil.GetGradientHair(this.Pawn, out bool enabled, out Color color))
                            {
                                enabled = false;
                                color   = Color.white;
                            }
                            base.GradientHairColorSelectionDto = new HairColorSelectionDTO(color, hairColorPresets, enabled);
                            base.GradientHairColorSelectionDto.SelectionChangeListener += this.GradientHairColorChange;
                        }
                    }
                }
            }

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserHair))
            {
                if (raceSettings != null)
                {
                    HairSettings hairSettings = raceSettings.hairSettings;
                    base.HasHair = hairSettings?.hasHair == true;
#if ALIEN_DEBUG
                    Log.Warning("initialize - got hair settings: HasHair = " + base.HasHair);
#endif
                    if (base.HasHair)
                    {
                        List <string> hairTags = hairSettings.hairTags;
                        if (hairTags != null)
                        {
                            IEnumerable <HairDef> hairDefs = from hair in DefDatabase <HairDef> .AllDefs
                                                             where hair.hairTags.SharesElementWith(hairTags)
                                                             select hair;
#if ALIEN_DEBUG
                            System.Text.StringBuilder sb = new System.Text.StringBuilder("Hair Defs: ");
                            foreach (HairDef d in hairDefs)
                            {
                                sb.Append(d.defName);
                                sb.Append(", ");
                            }
                            Log.Warning("initialize - " + sb.ToString());
#endif

                            /*if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserHair))
                             * {
                             *  if (hairSettings != null)
                             *  {
                             *      List<string> filter = (List<string>)hairSettings.GetType().GetField("hairTags")?.GetValue(hairSettings);
                             *      base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, filter);
                             *  }
                             * }*/
                            base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, hairDefs);
                        }
                        else
                        {
                            base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender);
                        }
                    }
                    else
                    {
#if ALIEN_DEBUG
                        Log.Warning("initialize - remove hair editors");
#endif
                        base.EditorTypeSelectionDto.Remove(CurrentEditorEnum.ChangeDresserHair);//, CurrentEditorEnum.ChangeDresserAlienHairColor);
#if ALIEN_DEBUG
                        Log.Warning("initialize - hair editors removed");
#endif
                    }
                }
            }

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserBody))
            {
                var apg = generalSettings?.alienPartGenerator;
                if (apg != null)
                {
                    List <string> crownTypes = apg.aliencrowntypes;
                    if (ac.crownType != null && ac.crownType != "" &&
                        crownTypes?.Count > 1)
                    {
                        this.HeadTypeSelectionDto = new HeadTypeSelectionDTO(ac.crownType, this.Pawn.gender, crownTypes);
                    }

                    List <BodyTypeDef> alienbodytypes = apg.alienbodytypes;
                    if (alienbodytypes != null && alienbodytypes.Count > 1)
                    {
                        this.BodyTypeSelectionDto = new BodyTypeSelectionDTO(this.Pawn.story.bodyType, this.Pawn.gender, alienbodytypes);
                    }
                    else
                    {
                        Log.Warning("No alien body types found. Defaulting to human.");
                        this.BodyTypeSelectionDto = new BodyTypeSelectionDTO(this.Pawn.story.bodyType, this.Pawn.gender);
                    }
                }

                if (generalSettings.maleGenderProbability > 0f && generalSettings.maleGenderProbability < 1f)
                {
                    base.GenderSelectionDto = new GenderSelectionDTO(base.Pawn.gender);
                    base.GenderSelectionDto.SelectionChangeListener += GenderChange;
                }
#if ALIEN_DEBUG
                Log.Warning("initialize - done");
#endif
            }
        }