Skip to content

Commit

Permalink
Remove X2Effect_MindControl code for #194, as per LW1.5. Is now handled
Browse files Browse the repository at this point in the history
by XComGameState_Unit as per issue #286
  • Loading branch information
MalucoMarinero committed Aug 31, 2017
1 parent 170eb34 commit 1d3a290
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions X2CommunityHighlander/Src/XComGame/Classes/X2Effect_MindControl.uc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class X2Effect_MindControl extends X2Effect_Persistent
native(Core); // This is only native to expose it for IsMindControlled on the unit state

// Issue #194 : Modified to fix bug where ticking effects on mind-controlled units when reverted would tick on wrong playerstate

var int iNumTurnsForAI;

simulated protected function OnEffectAdded(const out EffectAppliedData ApplyEffectParameters, XComGameState_BaseObject kNewTargetState, XComGameState NewGameState, XComGameState_Effect NewEffectState)
Expand Down Expand Up @@ -81,7 +79,6 @@ simulated function OnEffectRemoved(const out EffectAppliedData ApplyEffectParame
local XComGameState_Effect OriginalEffectState;
local XComGameState_Unit UnitState;
local StateObjectReference OriginalControllingPlayer;
local StateObjectReference MindControllingPlayer; // Issue #194 : Added for ticking effect listener updates
local int i;

super.OnEffectRemoved(ApplyEffectParameters, NewGameState, bCleansed, RemovedEffectState);
Expand All @@ -95,7 +92,6 @@ simulated function OnEffectRemoved(const out EffectAppliedData ApplyEffectParame

// now put them back on that team
UnitState = XComGameState_Unit(NewGameState.CreateStateObject(class'XComGameState_Unit', ApplyEffectParameters.TargetStateObjectRef.ObjectID));
MindControllingPlayer = UnitState.ControllingPlayer; // Issue #194 : save off the mind controlling player for ticking effect updates
UnitState.SetControllingPlayer(OriginalControllingPlayer);

// and update other stuff that needs to be reset when they stop being mind controlled
Expand All @@ -120,69 +116,7 @@ simulated function OnEffectRemoved(const out EffectAppliedData ApplyEffectParame
}
NewGameState.AddStateObject(UnitState);
UpdateAIData(NewGameState, UnitState);

// For Issue #194
UpdateTickingEffectListeners(UnitState, MindControllingPlayer, OriginalControllingPlayer);
}

// Start Issue #194
//PI : New helper function to re-register listeners for ticking effects
simulated function UpdateTickingEffectListeners(XComGameState_Unit UnitState, StateObjectReference StartPlayerRef, StateObjectReference EndPlayerRef )
{
local XComGameStateHistory History;
local X2EventManager EventMgr;
local XComGameState_Player StartPlayer, EndPlayer;
local XComGameState_Effect EffectState;
local X2Effect_Persistent EffectTemplate;
local Object ThisObj;

History = `XCOMHISTORY;
EventMgr = `XEVENTMGR;

StartPlayer = XComGameState_Player(History.GetGameStateForObjectID(StartPlayerRef.ObjectID));
// if there's no listeners on this event for the mind-controlling player, opt out early
if (!EventMgr.AnyListenersForEvent('PlayerTurnBegin', StartPlayer) && !EventMgr.AnyListenersForEvent('PlayerTurnEnded', StartPlayer))
{
return;
}
EndPlayer = XComGameState_Player(History.GetGameStateForObjectID(EndPlayerRef.ObjectID));
foreach History.IterateByClassType(class'XComGameState_Effect', EffectState)
{
// skip if the effect target isn't the mind-controlled unit
if (EffectState.ApplyEffectParameters.TargetStateObjectRef.ObjectID != UnitState.ObjectID)
{
continue;
}
EffectTemplate = EffectState.GetX2Effect();
// skip if effect isn't persistent or if it is the mind control effect
if (EffectTemplate == none || EffectTemplate == self)
{
continue;
}
// skip if effect is infinite or ticks every player turn start
if (EffectTemplate.bInfiniteDuration || EffectTemplate.bIgnorePlayerCheckOnTick)
{
continue;
}
// skip if it ticks every action -- basically this is for rulers
if (EffectTemplate.IsTickEveryAction(UnitState))
{
continue;
}
ThisObj = EffectState;
if ( EffectTemplate.WatchRule == eGameRule_PlayerTurnBegin )
{
EventMgr.UnRegisterFromEvent(ThisObj, 'PlayerTurnBegun');
EventMgr.RegisterForEvent( ThisObj, 'PlayerTurnBegun', EffectState.OnPlayerTurnTicked, ELD_OnStateSubmitted,, EndPlayer );
}
else if( EffectTemplate.WatchRule == eGameRule_PlayerTurnEnd )
{
EventMgr.UnRegisterFromEvent(ThisObj, 'PlayerTurnEnded');
EventMgr.RegisterForEvent( ThisObj, 'PlayerTurnEnded', EffectState.OnPlayerTurnTicked, ELD_OnStateSubmitted,, EndPlayer );
}
}
}
// End Issue #194

simulated function AddX2ActionsForVisualization(XComGameState VisualizeGameState, out VisualizationTrack BuildTrack, name EffectApplyResult)
{
Expand Down

0 comments on commit 1d3a290

Please sign in to comment.