public override IActivity Tick( Actor self ) { if (IsCanceled) return NextActivity; if (!Target.IsValid) return NextActivity; var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range; if( inRange ) return this; var ret = new Move( Target, Range ); ret.Queue( this ); return ret; }
protected override MovePart OnComplete( Actor self, Mobile mobile, Move parent ) { self.CenterLocation = Util.CenterOfCell( mobile.toCell ); mobile.fromCell = mobile.toCell; return null; }
protected abstract MovePart OnComplete( Actor self, Mobile mobile, Move parent );
public void TickMove( Actor self, Mobile mobile, Move parent ) { moveFraction += (int)Util.GetEffectiveSpeed(self); if( moveFraction >= moveFractionTotal ) moveFraction = moveFractionTotal; UpdateCenterLocation( self, mobile ); if( moveFraction >= moveFractionTotal ) { parent.move = OnComplete( self, mobile, parent ); if( parent.move == null ) UpdateCenterLocation( self, mobile ); } }
protected override MovePart OnComplete( Actor self, Mobile mobile, Move parent ) { var unit = self.traits.Get<Unit>(); var nextCell = parent.PopPath( self, mobile ); if( nextCell != null ) { if( ( nextCell - mobile.toCell ) != ( mobile.toCell - mobile.fromCell ) ) { var ret = new MoveFirstHalf( Util.BetweenCells( mobile.fromCell, mobile.toCell ), Util.BetweenCells( mobile.toCell, nextCell.Value ), unit.Facing, Util.GetNearestFacing( unit.Facing, Util.GetFacing( nextCell.Value - mobile.toCell, unit.Facing ) ), moveFraction - moveFractionTotal ); mobile.fromCell = mobile.toCell; mobile.toCell = nextCell.Value; return ret; } else parent.path.Add( nextCell.Value ); } var ret2 = new MoveSecondHalf( Util.BetweenCells( mobile.fromCell, mobile.toCell ), Util.CenterOfCell( mobile.toCell ), unit.Facing, unit.Facing, moveFraction - moveFractionTotal ); mobile.fromCell = mobile.toCell; return ret2; }
public void TickMove( Actor self, Mobile mobile, Move parent ) { moveFraction += (int)mobile.MovementSpeedForCell(self, mobile.toCell); if( moveFraction >= moveFractionTotal ) moveFraction = moveFractionTotal; UpdateCenterLocation( self, mobile ); if( moveFraction >= moveFractionTotal ) { parent.move = OnComplete( self, mobile, parent ); if( parent.move == null ) UpdateCenterLocation( self, mobile ); } }