[REQUEST] Suggestions for Changes to Enhance Functionality and Expandability

WeiYiHua

Member
TPC 3.0.14

1. Allow external access to the current IImpactDamageData in ProjectileBase.
This would enable certain scripts on Projectiles to display visual effects based on the IImpactDamageData.

Opsive\UltimateCharacterController\Scripts\Objects\ProjectileBase.cs
Code:
public ImpactDamageData DefaultImpactDamageData { get { return m_DefaultImpactDamageData; } set { m_DefaultImpactDamage
public bool InternalImpact { get { return m_InternalImpact; } set { m_InternalImpact = value; } }
public ImpactActionGroup ImpactActionGroup { get { return m_ImpactActionGroup; } set { m_ImpactActionGroup = value; } }
public IImpactDamageData CurrentImpactDamageData { get { return m_ImpactDamageData; } }

protected uint m_ID;
protected IProjectileOwner m_ProjectileOwner;
protected IImpactDamageData m_ImpactDamageData;

2. Initialize m_ImpactActionGroup in the Awake method of ProjectileBase.
This change would allow StateObjectBinding to be used on Projectiles.

Code:
/// <summary>
/// Initialize the defualt values.
/// </summary>
protected override void Awake()
{
    base.Awake();

    m_CachedImpactCallbackContext = new ImpactCallbackContext();
    m_CachedImpactCollisionData = new ImpactCollisionData();
    m_ImpactActionGroup.Initialize(gameObject, null);

    m_TrailRenderer = GetComponent<TrailRenderer>();
    if (m_TrailRenderer != null) {
        m_TrailRenderer.enabled = false;
    }
    m_ParticleSystem = GetComponent<ParticleSystem>();
    if (m_ParticleSystem != null) {
        m_ParticleSystem.Stop();
    }

3. Include m_UseCountSinceAbilityStart in TriggerData.
This could open up numerous possibilities, such as calculating recoil based on UseCountSinceAbilityStart or altering the number of magic projectiles fired, and more.

Opsive\UltimateCharacterController\Scripts\Items\Actions\Modules\TriggerModule.cs
Code:
/// <summary>
/// The trigger data contains information about how the action was triggered.
/// </summary>
public class TriggerData
{
    protected float m_Force;
    protected int m_Index;
    protected bool m_FireInLookSourceDirection;
    protected int m_UseCountSinceAbilityStart;

    public float Force { get => m_Force; set => m_Force=value; }
    public int Index { get => m_Index; set => m_Index=value; }
    public int UseCountSinceAbilityStart { get => m_UseCountSinceAbilityStart; set => m_UseCountSinceAbilityStart = value; }
}
Opsive\UltimateCharacterController\Scripts\Items\Actions\UsableAction.cs
Code:
/// <summary>
/// Trigger the item action to be used.
/// </summary>
/// <param name="triggerData">The trigger data.</param>
public virtual void TriggerItemAction(TriggerData triggerData)
{
    TriggeredUseItemAction();
    triggerData.UseCountSinceAbilityStart = m_UseCountSinceAbilityStart;
    TriggeredUseItemActionComplete();
}
Other subclasses of UsableAction also need to be added.

4. Store all spawnd Projectiles in ShootableFireData.
This modification would enable shotguns to retrieve all fired projectiles within OnFire, allowing for more control over these projectiles.

Opsive\UltimateCharacterController\Scripts\Items\Actions\Modules\Shootable\ShooterModule.cs
Code:
/// <summary>
/// The fire data contains information about how the shooter should fire the projectile.
/// </summary>
public class ShootableFireData
{
    protected Vector3 m_FirePoint;
    protected Vector3 m_FireDirection;
    protected List<Projectile> m_SpawnedProjectiles = new List<Projectile>();

    public Vector3 FirePoint { get => m_FirePoint; set => m_FirePoint = value; }
    public Vector3 FireDirection { get => m_FireDirection; set => m_FireDirection = value; }
    public List<Projectile> SpawnedProjectiles { get => m_SpawnedProjectiles; set => m_SpawnedProjectiles = value; }
}
Opsive\UltimateCharacterController\Scripts\Items\Actions\Modules\Shootable\ProjectileShooter.cs
Code:
/// <summary>
/// Get the fire preview data, to give information about the next fire.
/// </summary>
/// <returns>The preview data.</returns>
public override ShootableFireData GetFirePreviewData()
{
    var dataStream = ShootableAction.ShootableUseDataStream;
    m_ShootableFireData.FirePoint = GetFirePoint(dataStream);
    m_ShootableFireData.FireDirection = GetFireDirection(m_ShootableFireData.FirePoint, dataStream);
    m_ShootableFireData.SpawnedProjectiles.Clear();

    return m_ShootableFireData;
}

...

 CharacterItemAction.DebugLogger.DrawRay(this, firePoint, fireDirection * 10, Color.red, 1);
 CharacterItemAction.DebugLogger.DrawRay(this, firePoint, projectileVelocity, Color.blue, 1);
 
 projectile.Initialize(0, projectileVelocity, Vector3.zero, this, null);
 m_ShootableFireData.SpawnedProjectiles.Add(projectile);

5. Add a CharacterItem parameter to the SetItemIKTargets method in CharacterIKBase.
This enhancement would grant IK scripts that inherit from CharacterIKBase more detailed control over IK related to CharacterItems.

Opsive\UltimateCharacterController\Scripts\Character\CharacterIKBase.cs
Code:
/// <summary>
/// Specifies the location of the left or right hand IK target and IK hint target.
/// </summary>
/// <param name="characterItem">The character item.</param>
/// <param name="itemTransform">The transform of the item.</param>
/// <param name="itemHand">The hand that the item is parented to.</param>
/// <param name="nonDominantHandTarget">The target of the left or right hand. Can be null.</param>
/// <param name="nonDominantHandElbowTarget">The target of the left or right elbow. Can be null.</param>
public abstract void SetItemIKTargets(CharacterItem characterItem, Transform itemTransform, Transform itemHand, Transform nonDominantHandTarget, Transform nonDominantHandElbowTarget);
 
I'm following along with your threads but haven't been able to look into it deeper yet.

6. Restore the deleted LateUpdate methods in CameraController and ViewType to ensure the correct Input is read in ViewType.
This isn't necessary. For any custom input you can register for an ActiveInputEvent. Take a look at the RPG view type as an example.
 
I have made the changes except for the CharacterIK change. I am going to wait on that one until version 3.1.
 
Thank you for listening to my suggestions, I will continue to study the source code to find bugs or improve the code.
 
Top