- add: database for genitals

This commit is contained in:
2024-02-16 21:21:19 +03:00
parent 52628d0393
commit c3e8e64fb8
14 changed files with 3907 additions and 14 deletions

View File

@@ -65,6 +65,14 @@ public sealed partial class GenitalController : Control
}; };
} }
public void SetColor(Color? color)
{
if (color is null)
CheckBox.Pressed = true;
else
Color.Color = color.Value;
}
private void OnColorChanged(Color obj) private void OnColorChanged(Color obj)
{ {
if(!CheckBox.Pressed) if(!CheckBox.Pressed)

View File

@@ -21,17 +21,22 @@ public sealed partial class HumanoidProfileEditor
_genitals.Clear(); _genitals.Clear();
GenitalBoxView.ClearChilds(); GenitalBoxView.ClearChilds();
Logger.Debug(Profile.Appearance.Genitals.Count + "<<"); var genitalsList = Profile.Appearance.Genitals.ToList();
foreach (var prototype in _prototypeManager.EnumeratePrototypes<GenitalsGroupPrototype>()) foreach (var prototype in _prototypeManager.EnumeratePrototypes<GenitalsGroupPrototype>())
{ {
var controller = new GenitalController();
var selected = 0; var selected = 0;
foreach (var genital in Profile.Appearance.Genitals.Where(genital => prototype.Prototypes.Contains(genital.GenitalId))) foreach (var genital in genitalsList)
{ {
selected = prototype.Prototypes.IndexOf(genital.GenitalId); if (!prototype.Prototypes.Contains(genital.GenitalId))
continue;
selected = prototype.Prototypes.IndexOf(genital.GenitalId) + 1;
controller.SetColor(genital.Color);
} }
var controller = new GenitalController();
controller.GenitalsCollectionPrototype = prototype; controller.GenitalsCollectionPrototype = prototype;
controller.InChange += ControllerOnInChange; controller.InChange += ControllerOnInChange;
controller.SelectedId = selected; controller.SelectedId = selected;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Content.Server.Database.Migrations.Postgres
{
/// <inheritdoc />
public partial class Genital : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "genital",
columns: table => new
{
genital_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
profile_id = table.Column<int>(type: "integer", nullable: false),
genital_prototype = table.Column<string>(type: "text", nullable: false),
color = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_genital", x => x.genital_id);
table.ForeignKey(
name: "FK_genital_profile_profile_id",
column: x => x.profile_id,
principalTable: "profile",
principalColumn: "profile_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_genital_profile_id_genital_prototype",
table: "genital",
columns: new[] { "profile_id", "genital_prototype" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "genital");
}
}
}

View File

@@ -564,6 +564,38 @@ namespace Content.Server.Database.Migrations.Postgres
}); });
}); });
modelBuilder.Entity("Content.Server.Database.Genital", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("genital_id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Color")
.IsRequired()
.HasColumnType("text")
.HasColumnName("color");
b.Property<string>("GenitalPrototype")
.IsRequired()
.HasColumnType("text")
.HasColumnName("genital_prototype");
b.Property<int>("ProfileId")
.HasColumnType("integer")
.HasColumnName("profile_id");
b.HasKey("Id")
.HasName("PK_genital");
b.HasIndex("ProfileId", "GenitalPrototype")
.IsUnique();
b.ToTable("genital", (string)null);
});
modelBuilder.Entity("Content.Server.Database.Job", b => modelBuilder.Entity("Content.Server.Database.Job", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1545,6 +1577,18 @@ namespace Content.Server.Database.Migrations.Postgres
b.Navigation("Server"); b.Navigation("Server");
}); });
modelBuilder.Entity("Content.Server.Database.Genital", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Genitals")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("FK_genital_profile_profile_id");
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.Job", b => modelBuilder.Entity("Content.Server.Database.Job", b =>
{ {
b.HasOne("Content.Server.Database.Profile", "Profile") b.HasOne("Content.Server.Database.Profile", "Profile")
@@ -1779,6 +1823,8 @@ namespace Content.Server.Database.Migrations.Postgres
{ {
b.Navigation("Antags"); b.Navigation("Antags");
b.Navigation("Genitals");
b.Navigation("Jobs"); b.Navigation("Jobs");
b.Navigation("Traits"); b.Navigation("Traits");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Content.Server.Database.Migrations.Sqlite
{
/// <inheritdoc />
public partial class Genital : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "genital",
columns: table => new
{
genital_id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
profile_id = table.Column<int>(type: "INTEGER", nullable: false),
genital_prototype = table.Column<string>(type: "TEXT", nullable: false),
color = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_genital", x => x.genital_id);
table.ForeignKey(
name: "FK_genital_profile_profile_id",
column: x => x.profile_id,
principalTable: "profile",
principalColumn: "profile_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_genital_profile_id_genital_prototype",
table: "genital",
columns: new[] { "profile_id", "genital_prototype" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "genital");
}
}
}

View File

@@ -530,6 +530,36 @@ namespace Content.Server.Database.Migrations.Sqlite
b.ToTable("connection_log", (string)null); b.ToTable("connection_log", (string)null);
}); });
modelBuilder.Entity("Content.Server.Database.Genital", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("genital_id");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("color");
b.Property<string>("GenitalPrototype")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("genital_prototype");
b.Property<int>("ProfileId")
.HasColumnType("INTEGER")
.HasColumnName("profile_id");
b.HasKey("Id")
.HasName("PK_genital");
b.HasIndex("ProfileId", "GenitalPrototype")
.IsUnique();
b.ToTable("genital", (string)null);
});
modelBuilder.Entity("Content.Server.Database.Job", b => modelBuilder.Entity("Content.Server.Database.Job", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1474,6 +1504,18 @@ namespace Content.Server.Database.Migrations.Sqlite
b.Navigation("Server"); b.Navigation("Server");
}); });
modelBuilder.Entity("Content.Server.Database.Genital", b =>
{
b.HasOne("Content.Server.Database.Profile", "Profile")
.WithMany("Genitals")
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("FK_genital_profile_profile_id");
b.Navigation("Profile");
});
modelBuilder.Entity("Content.Server.Database.Job", b => modelBuilder.Entity("Content.Server.Database.Job", b =>
{ {
b.HasOne("Content.Server.Database.Profile", "Profile") b.HasOne("Content.Server.Database.Profile", "Profile")
@@ -1708,6 +1750,8 @@ namespace Content.Server.Database.Migrations.Sqlite
{ {
b.Navigation("Antags"); b.Navigation("Antags");
b.Navigation("Genitals");
b.Navigation("Jobs"); b.Navigation("Jobs");
b.Navigation("Traits"); b.Navigation("Traits");

View File

@@ -60,6 +60,10 @@ namespace Content.Server.Database
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.TraitName}) .HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.TraitName})
.IsUnique(); .IsUnique();
modelBuilder.Entity<Genital>()
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.GenitalPrototype })
.IsUnique();
modelBuilder.Entity<Job>() modelBuilder.Entity<Job>()
.HasIndex(j => j.ProfileId); .HasIndex(j => j.ProfileId);
@@ -314,6 +318,18 @@ namespace Content.Server.Database
public float Reputation { get; set; } public float Reputation { get; set; }
} }
// WD end // WD end
// Amour start
public class Genital
{
public int Id { get; set; }
public Profile Profile { get; set; } = null!;
public int ProfileId { get; set; }
public string GenitalPrototype { get; set; } = null!;
public string Color { get; set; } = null!;
}
// Amour end
public class Preference public class Preference
{ {
@@ -360,6 +376,7 @@ namespace Content.Server.Database
public List<Job> Jobs { get; } = new(); public List<Job> Jobs { get; } = new();
public List<Antag> Antags { get; } = new(); public List<Antag> Antags { get; } = new();
public List<Trait> Traits { get; } = new(); public List<Trait> Traits { get; } = new();
public List<Genital> Genitals { get; } = new();
[Column("pref_unavailable")] public DbPreferenceUnavailableMode PreferenceUnavailable { get; set; } [Column("pref_unavailable")] public DbPreferenceUnavailableMode PreferenceUnavailable { get; set; }

View File

@@ -41,6 +41,7 @@ namespace Content.Server.Database
.Include(p => p.Profiles).ThenInclude(h => h.Jobs) .Include(p => p.Profiles).ThenInclude(h => h.Jobs)
.Include(p => p.Profiles).ThenInclude(h => h.Antags) .Include(p => p.Profiles).ThenInclude(h => h.Antags)
.Include(p => p.Profiles).ThenInclude(h => h.Traits) .Include(p => p.Profiles).ThenInclude(h => h.Traits)
.Include(p => p.Profiles).ThenInclude(h => h.Genitals)
.AsSingleQuery() .AsSingleQuery()
.SingleOrDefaultAsync(p => p.UserId == userId.UserId); .SingleOrDefaultAsync(p => p.UserId == userId.UserId);
@@ -89,6 +90,7 @@ namespace Content.Server.Database
.Include(p => p.Jobs) .Include(p => p.Jobs)
.Include(p => p.Antags) .Include(p => p.Antags)
.Include(p => p.Traits) .Include(p => p.Traits)
.Include(p => p.Genitals)
.AsSplitQuery() .AsSplitQuery()
.SingleOrDefault(h => h.Slot == slot); .SingleOrDefault(h => h.Slot == slot);
@@ -214,6 +216,11 @@ namespace Content.Server.Database
} }
} }
Console.WriteLine(profile.Genitals.Count + "<><>");
var genitals = profile.Genitals.Select(genital =>
new Shared._Amour.Hole.Genital(genital.GenitalPrototype,
string.IsNullOrEmpty(genital.Color) ? null : Color.FromHex(genital.Color)));
return new HumanoidCharacterProfile( return new HumanoidCharacterProfile(
profile.CharacterName, profile.CharacterName,
profile.ClownName, profile.ClownName,
@@ -233,7 +240,7 @@ namespace Content.Server.Database
Color.FromHex(profile.FacialHairColor), Color.FromHex(profile.FacialHairColor),
Color.FromHex(profile.EyeColor), Color.FromHex(profile.EyeColor),
Color.FromHex(profile.SkinColor), Color.FromHex(profile.SkinColor),
markings, new List<Genital>() //TEMP markings, genitals.ToList() // Amour edit
), ),
clothing, clothing,
backpack, backpack,
@@ -297,6 +304,17 @@ namespace Content.Server.Database
.Select(t => new Trait {TraitName = t}) .Select(t => new Trait {TraitName = t})
); );
profile.Genitals.Clear();
profile.Genitals.AddRange(
appearance.Genitals.Select(t => new Genital()
{
GenitalPrototype = t.GenitalId,
Color = t.Color?.ToHex() ?? ""
}));
Console.WriteLine(profile.Genitals);
Console.WriteLine(profile.Antags);
return profile; return profile;
} }
#endregion #endregion

View File

@@ -55,6 +55,12 @@ public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceS
SetSkinColor(uid, profile.Appearance.SkinColor, false); SetSkinColor(uid, profile.Appearance.SkinColor, false);
//AMOUR
foreach (var genitals in profile.Appearance.Genitals)
{
_holeSystem.AddHole(uid,genitals.GenitalId,genitals.Color);
}
humanoid.MarkingSet.Clear(); humanoid.MarkingSet.Clear();
// Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it. // Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it.
@@ -118,13 +124,6 @@ public sealed partial class HumanoidAppearanceSystem : SharedHumanoidAppearanceS
humanoid.Age = profile.Age; humanoid.Age = profile.Age;
//AMOUR
foreach (var genitals in profile.Appearance.Genitals)
{
Log.Debug("CHLEN! " + genitals.GenitalId);
_holeSystem.AddHole(uid,genitals.GenitalId,genitals.Color);
}
Dirty(humanoid); Dirty(humanoid);
} }

View File

@@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using Content.Shared._Amour.Hole;
using Content.Shared.Decals; using Content.Shared.Decals;
using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes; using Content.Shared.Humanoid.Prototypes;
@@ -23,6 +24,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
[Dependency] private readonly INetManager _netManager = default!; [Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!; [Dependency] private readonly MarkingManager _markingManager = default!;
[Dependency] private readonly SharedHoleSystem _holeSystem = default!;
[ValidatePrototypeId<SpeciesPrototype>] [ValidatePrototypeId<SpeciesPrototype>]
public const string DefaultSpecies = "Human"; public const string DefaultSpecies = "Human";
@@ -274,6 +276,12 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
SetSkinColor(uid, profile.Appearance.SkinColor, false); SetSkinColor(uid, profile.Appearance.SkinColor, false);
//AMOUR
foreach (var genitals in profile.Appearance.Genitals)
{
_holeSystem.AddHole(uid,genitals.GenitalId,genitals.Color);
}
humanoid.MarkingSet.Clear(); humanoid.MarkingSet.Clear();
// Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it. // Add markings that doesn't need coloring. We store them until we add all other markings that doesn't need it.

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Prototypes;
namespace Content.Shared._Amour.Hole; namespace Content.Shared._Amour.Hole;
[RegisterComponent] [RegisterComponent,NetworkedComponent]
public sealed partial class HoleContainerComponent : Component public sealed partial class HoleContainerComponent : Component
{ {
public const string SlotName = "Funny"; public const string SlotName = "Funny";

View File

@@ -38,9 +38,9 @@ public abstract partial class SharedHoleSystem
return; return;
} }
Log.Debug("ADDED " + protoId);
component.Layers[0].Color = color; component.Layers[0].Color = color;
_containerSystem.Insert(spawned, entity.Comp.Slot); _containerSystem.Insert(spawned, entity.Comp.Slot);
Dirty(entity);
} }
} }