Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carrying - Handle simultaneously carry action #99

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//------------------------------------------------------------------------------------------------
modded class SCR_CharacterControllerComponent : CharacterControllerComponent
{
[RplProp()]
protected bool m_bACE_Carrying_IsCarrier = false;
[RplProp()]
protected bool m_bACE_Carrying_IsCarried = false;

//------------------------------------------------------------------------------------------------
void ACE_Carrying_SetIsCarrier(bool isCarrier)
{
m_bACE_Carrying_IsCarrier = isCarrier;
Replication.BumpMe();
}

//------------------------------------------------------------------------------------------------
bool ACE_Carrying_IsCarrier()
{
return m_bACE_Carrying_IsCarrier;
}

//------------------------------------------------------------------------------------------------
void ACE_Carrying_SetIsCarried(bool isCarried)
{
m_bACE_Carrying_IsCarried = isCarried;
Replication.BumpMe();
}

//------------------------------------------------------------------------------------------------
bool ACE_Carrying_IsCarried()
{
return m_bACE_Carrying_IsCarried;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class ACE_Carrying_HelperCompartment : GenericEntity
if (!carrierController)
return;

carrierController.ACE_Carrying_SetIsCarrier(true);
carrierController.m_OnLifeStateChanged.Insert(OnCarrierLifeStateChanged);

SCR_CharacterControllerComponent carriedController = SCR_CharacterControllerComponent.Cast(carried.FindComponent(SCR_CharacterControllerComponent));
if (!carriedController)
return;

carriedController.ACE_Carrying_SetIsCarried(true);
carriedController.m_OnLifeStateChanged.Insert(OnCarriedLifeStateChanged);

RplComponent carriedRpl = RplComponent.Cast(carried.FindComponent(RplComponent));
Expand Down Expand Up @@ -126,6 +128,7 @@ class ACE_Carrying_HelperCompartment : GenericEntity
if (!carrierController)
return;

carrierController.ACE_Carrying_SetIsCarrier(false);
carrierController.m_OnLifeStateChanged.Remove(OnCarrierLifeStateChanged);
}

Expand All @@ -136,7 +139,8 @@ class ACE_Carrying_HelperCompartment : GenericEntity
SCR_CharacterControllerComponent carriedController = SCR_CharacterControllerComponent.Cast(m_pCarried.FindComponent(SCR_CharacterControllerComponent));
if (!carriedController)
return;


carriedController.ACE_Carrying_SetIsCarried(false);
carriedController.m_OnLifeStateChanged.Remove(OnCarriedLifeStateChanged);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ class ACE_Carrying_Tools
if (!carrier)
return false;

return GetHelperCompartmentFromCarrier(carrier);
SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(carrier.FindComponent(SCR_CharacterControllerComponent));
if (!controller)
return false;

return controller.ACE_Carrying_IsCarrier();
}

//------------------------------------------------------------------------------------------------
Expand All @@ -55,7 +59,11 @@ class ACE_Carrying_Tools
if (!carried)
return false;

return GetHelperCompartmentFromCarried(carried);
SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(carried.FindComponent(SCR_CharacterControllerComponent));
if (!controller)
return false;

return controller.ACE_Carrying_IsCarried();
}

//------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ class ACE_Carrying_CarryUserAction : ScriptedUserAction
//------------------------------------------------------------------------------------------------
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
// Check on server if they are in faction not yet carried
if (ACE_Carrying_Tools.IsCarried(pOwnerEntity))
return;

ACE_Carrying_Tools.Carry(pUserEntity, pOwnerEntity);
}

//------------------------------------------------------------------------------------------------
//! Methods are executed on the local player
//! Only run PerformAction on server
override bool CanBroadcastScript() { return false; };
}