Add door interaction system with requirements and HUD integration
This commit is contained in:
@@ -7,6 +7,7 @@ using GameCore.Combat;
|
||||
using GameCore.Combat.Interfaces;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Input;
|
||||
using GameCore.Interaction;
|
||||
using GameCore.Inventory;
|
||||
using GameCore.Movement;
|
||||
using GameCore.Physics;
|
||||
@@ -19,10 +20,12 @@ public class ComponentFactory
|
||||
{
|
||||
private readonly Dictionary<Type, Func<Resource, IComponent>> _factories = new();
|
||||
private readonly EffectFactory _effectFactory;
|
||||
private readonly InteractionRequirementFactory _requirementFactory;
|
||||
|
||||
public ComponentFactory(EffectFactory effectFactory)
|
||||
public ComponentFactory(EffectFactory effectFactory, InteractionRequirementFactory requirementFactory)
|
||||
{
|
||||
_effectFactory = effectFactory;
|
||||
_requirementFactory = requirementFactory;
|
||||
|
||||
Register<AttributeComponentResource>(CreateAttributeComponent);
|
||||
Register<WeaponComponentResource>(CreateWeaponComponent);
|
||||
@@ -36,6 +39,7 @@ public class ComponentFactory
|
||||
Register<InventoryComponentResource>(_ => new InventoryComponent());
|
||||
Register<PickupComponentResource>(CreatePickupComponent);
|
||||
Register<EquipmentComponentResource>(_ => new EquipmentComponent());
|
||||
Register<DoorComponentResource>(CreateDoorComponent);
|
||||
}
|
||||
|
||||
public IComponent Create(Resource resource)
|
||||
@@ -104,4 +108,25 @@ public class ComponentFactory
|
||||
OnAcquireEffects = onAcquireEffects,
|
||||
};
|
||||
}
|
||||
|
||||
private DoorComponent CreateDoorComponent(DoorComponentResource resource)
|
||||
{
|
||||
var component = new DoorComponent
|
||||
{
|
||||
CurrentState = resource.InitialState,
|
||||
IsOneTimeUnlock = resource.IsOneTimeUnlock,
|
||||
OpenSpeed = resource.OpenSpeed,
|
||||
};
|
||||
|
||||
foreach (var reqResource in resource.Requirements)
|
||||
{
|
||||
var requirement = _requirementFactory.Create(reqResource);
|
||||
if (requirement != null)
|
||||
{
|
||||
component.Requirements.Add(requirement);
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user