diff --git a/GameServer/Controllers/CreatureController.cs b/GameServer/Controllers/CreatureController.cs index bde2f2d..1c2ed54 100644 --- a/GameServer/Controllers/CreatureController.cs +++ b/GameServer/Controllers/CreatureController.cs @@ -249,6 +249,8 @@ internal class CreatureController : Controller _entitySystem.Create(entity); entity.InitProps(_configManager.GetConfig(entity.ConfigId)!); + CreateConcomitants(entity); + // Give weapon to entity RoleInfoConfig roleConfig = _configManager.GetConfig(entity.ConfigId)!; WeaponConfig weaponConfig = _configManager.GetConfig(roleConfig.InitWeaponItemId)!; @@ -258,6 +260,32 @@ internal class CreatureController : Controller } } + private void CreateConcomitants(PlayerEntity entity) + { + (int roleId, int summonConfigId) = entity.ConfigId switch + { + 1302 => (5002, 10070301), + _ => (-1, -1) + }; + + if (roleId != -1) + { + PlayerEntity concomitant = _entityFactory.CreatePlayer(roleId, 0); + _entitySystem.Create(concomitant); + + EntityConcomitantsComponent concomitants = entity.ComponentSystem.Get(); + concomitants.CustomEntityIds.Clear(); + concomitants.CustomEntityIds.Add(concomitant.Id); + + EntitySummonerComponent summoner = concomitant.ComponentSystem.Create(); + summoner.SummonerId = entity.Id; + summoner.SummonConfigId = summonConfigId; + summoner.SummonType = ESummonType.ConcomitantCustom; + summoner.PlayerId = _modelManager.Player.Id; + concomitant.InitProps(_configManager.GetConfig(roleId)!); + } + } + private void CreateWorldEntities() { Vector playerPos = _modelManager.Player.Position; diff --git a/GameServer/Systems/Entity/Component/EntitySummonerComponent.cs b/GameServer/Systems/Entity/Component/EntitySummonerComponent.cs new file mode 100644 index 0000000..7402cfe --- /dev/null +++ b/GameServer/Systems/Entity/Component/EntitySummonerComponent.cs @@ -0,0 +1,25 @@ +using Protocol; + +namespace GameServer.Systems.Entity.Component; +internal class EntitySummonerComponent : EntityComponentBase +{ + public int SummonConfigId { get; set; } + public ESummonType SummonType { get; set; } + public long SummonerId { get; set; } + public int PlayerId { get; set; } + public int SummonSkillId { get; set; } + + public override EntityComponentType Type => EntityComponentType.Summoner; + + public override EntityComponentPb Pb => new() + { + SummonerComponent = new() + { + SummonCfgId = SummonConfigId, + Type = (int)SummonType, + SummonerId = SummonerId, + PlayerId = PlayerId, + SummonSkillId = SummonSkillId + } + }; +}