Character weapons implemented

This commit is contained in:
xeon 2024-02-12 03:23:27 +03:00
parent ac6b50fa6a
commit 5b927b99a8
8 changed files with 3478 additions and 2 deletions

View file

@ -1,5 +1,6 @@
namespace Core.Config; namespace Core.Config;
public enum ConfigType public enum ConfigType
{ {
RoleInfo RoleInfo,
Weapon
} }

View file

@ -0,0 +1,7 @@
namespace Core.Config.Types;
public class PropConfig
{
public int Id { get; set; }
public float Value { get; set; }
public bool IsRatio { get; set; }
}

View file

@ -0,0 +1,47 @@
using Core.Config.Attributes;
using Core.Config.Types;
namespace Core.Config;
[ConfigCollection("weapon/weaponconf.json")]
public class WeaponConfig : IConfig
{
public ConfigType Type => ConfigType.Weapon;
public int Identifier => ItemId;
public int ItemId { get; set; }
public string WeaponName { get; set; } = string.Empty;
public int QualityId { get; set; }
public int WeaponType { get; set; }
public int ModelId { get; set; }
public int TransformId { get; set; }
public List<int> Models { get; set; } = [];
public int ResonLevelLimit { get; set; }
public PropConfig? FirstPropId { get; set; }
public int FirstCurve { get; set; }
public PropConfig? SecondPropId { get; set; }
public int SecondCurve { get; set; }
public int ResonId { get; set; }
public int LevelId { get; set; }
public int BreachId { get; set; }
public string Desc { get; set; } = string.Empty;
public string TypeDescription { get; set; } = string.Empty;
public string AttributesDescription { get; set; } = string.Empty;
public string BgDescription { get; set; } = string.Empty;
public string Icon { get; set; } = string.Empty;
public string IconMiddle { get; set; } = string.Empty;
public string IconSmall { get; set; } = string.Empty;
public string Mesh { get; set; } = string.Empty;
public int MaxCapcity { get; set; }
public List<object> ItemAccess { get; set; } = [];
public int ObtainedShow { get; set; }
public string ObtainedShowDescription { get; set; } = string.Empty;
public int NumLimit { get; set; }
public bool ShowInBag { get; set; }
public int SortIndex { get; set; }
public string ResonanceIcon { get; set; } = string.Empty;
public int HiddenTime { get; set; }
public bool Destructible { get; set; }
public int RedDotDisableRule { get; set; }
}

View file

@ -12,6 +12,10 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="data\config\weapon\weaponconf.json" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
</ItemGroup> </ItemGroup>

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
using System.Security.Principal; using System.Security.Principal;
using Core.Config;
using GameServer.Controllers.Attributes; using GameServer.Controllers.Attributes;
using GameServer.Models; using GameServer.Models;
using GameServer.Network; using GameServer.Network;
@ -14,12 +15,14 @@ internal class CreatureController : Controller
private readonly EntitySystem _entitySystem; private readonly EntitySystem _entitySystem;
private readonly EntityFactory _entityFactory; private readonly EntityFactory _entityFactory;
private readonly ModelManager _modelManager; private readonly ModelManager _modelManager;
private readonly ConfigManager _configManager;
public CreatureController(PlayerSession session, EntitySystem entitySystem, EntityFactory entityFactory, ModelManager modelManager) : base(session) public CreatureController(PlayerSession session, EntitySystem entitySystem, EntityFactory entityFactory, ModelManager modelManager, ConfigManager configManager) : base(session)
{ {
_entitySystem = entitySystem; _entitySystem = entitySystem;
_entityFactory = entityFactory; _entityFactory = entityFactory;
_modelManager = modelManager; _modelManager = modelManager;
_configManager = configManager;
} }
public async Task JoinScene(int instanceId) public async Task JoinScene(int instanceId)
@ -234,6 +237,11 @@ internal class CreatureController : Controller
_entitySystem.Create(entity); _entitySystem.Create(entity);
// Give weapon to entity
RoleInfoConfig roleConfig = _configManager.GetConfig<RoleInfoConfig>(entity.ConfigId)!;
WeaponConfig weaponConfig = _configManager.GetCollection<WeaponConfig>().Enumerate<WeaponConfig>().First(weapon => weapon.WeaponType == roleConfig.WeaponType);
entity.WeaponId = weaponConfig.ItemId;
if (i == 0) _modelManager.Creature.PlayerEntityId = entity.Id; if (i == 0) _modelManager.Creature.PlayerEntityId = entity.Id;
} }
} }

View file

@ -0,0 +1,22 @@
using Protocol;
namespace GameServer.Systems.Entity.Component;
internal class EntityEquipComponent : EntityComponentBase
{
public int WeaponId { get; set; }
public EntityEquipComponent()
{
// EntityEquipComponent.
}
public override EntityComponentType Type => EntityComponentType.Equip;
public override EntityComponentPb Pb => new()
{
EquipComponent = new EquipComponentPb
{
WeaponId = WeaponId
}
};
}

View file

@ -15,6 +15,12 @@ internal class PlayerEntity : EntityBase
public bool IsCurrentRole { get; set; } public bool IsCurrentRole { get; set; }
public int WeaponId
{
get => ComponentSystem.Get<EntityEquipComponent>().WeaponId;
set => ComponentSystem.Get<EntityEquipComponent>().WeaponId = value;
}
public override void OnCreate() public override void OnCreate()
{ {
base.OnCreate(); base.OnCreate();
@ -25,6 +31,8 @@ internal class PlayerEntity : EntityBase
EntityVisionSkillComponent visionSkillComponent = ComponentSystem.Create<EntityVisionSkillComponent>(); EntityVisionSkillComponent visionSkillComponent = ComponentSystem.Create<EntityVisionSkillComponent>();
visionSkillComponent.SetExploreTool(1001); visionSkillComponent.SetExploreTool(1001);
_ = ComponentSystem.Create<EntityEquipComponent>();
} }
public override void Activate() public override void Activate()