Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Jailbreak.JBCameraArena


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
// ============================================================================
// JBCameraArena
// Copyright 2002 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: JBCameraArena.uc,v 1.8 2007-02-16 19:40:39 wormbo Exp $
//
// Arena follower camera which tracks the arena opponent. Destroys itself when
// the trailed player dies or is respawned or when the last viewer is gone.
// ============================================================================


class JBCameraArena extends JBCamera
  notplaceable;


// ============================================================================
// Replication
// ============================================================================

replication
{
  reliable if (Role == ROLE_Authority)
    Arena,
    TagPlayerFollowed,
    TagPlayerOpponent;
}


// ============================================================================
// Variables
// ============================================================================

var JBInfoArena Arena;              // attached arena

var JBTagPlayer TagPlayerFollowed;  // player followed by this camera
var JBTagPlayer TagPlayerOpponent;  // opponent tracked by this camera


// ============================================================================
// IsViewerAllowed
//
// Checks and returns whether the given player is a spectator or in the same
// team as the followed player.
// ============================================================================

function bool IsViewerAllowed(Controller Controller)
{
  if (JBCamControllerArena(CamController) == None)
    return Super.IsViewerAllowed(Controller);
  
  if (TagPlayerFollowed                == None ||
      Controller.PlayerReplicationInfo == None)
    return False;
  
  if (Controller.PlayerReplicationInfo.Team == None ||
      Controller.PlayerReplicationInfo.Team == TagPlayerFollowed.GetTeam())
    return Super.IsViewerAllowed(Controller);
    
  return False;
}


// ============================================================================
// state Active
//
// Camera is active. When the last viewer leaves this camera, auto-destructs.
// ============================================================================

auto state Active
{
  // ================================================================
  // Tick
  //
  // Checks whether the followed player has left the arena. If so,
  // enters state Finished which will wait a bit and then destroy
  // the camera.
  // ================================================================
  
  simulated event Tick(float TimeDelta)
  {
    Global.Tick(TimeDelta);

    if (Role == ROLE_Authority &&
        (TagPlayerFollowed == None || !TagPlayerFollowed.IsInArena()) &&
        (TagPlayerOpponent == None || !TagPlayerOpponent.IsInArena()))
      GotoState('Finished');
  }


  // ================================================================
  // DeactivateFor
  //
  // Goes to state Deactivate when the last viewer is gone.
  // ================================================================
  
  function DeactivateFor(Controller Controller)
  {
    Global.DeactivateFor(Controller);
    
    if (!HasViewers())
      GotoState('Deactivate');
  }

} // state Active;


// ============================================================================
// state Finished
//
// Waits for three seconds before destroying itself.
// ============================================================================

state Finished
{
  ignores IsViewerAllowed;  // no viewers accepted in this state


  // ================================================================
  // State Code
  // ================================================================

  Begin:
    Sleep(3.0);
    GotoState('Deactivate');

}  // state Finished


// ============================================================================
// state Deactivate
//
// Waits for a short while before destroying the camera.
// ============================================================================

state Deactivate
{
  ignores IsViewerAllowed;  // no viewers accepted in this state
  ignores Tick;             // implicit deactivation by DeactivateFor fails


  // ================================================================
  // State Code
  //
  // Deactivates the camera for all viewers, waits for a short while
  // and destroys the camera.
  // ================================================================

  Begin:
    DeactivateForAll();
    Sleep(3.0);
    Destroy();

} // state Deactivate


// ============================================================================
// Defaults
// ============================================================================

defaultproperties
{
  ClassCamController = Class'JBCamControllerArena';

  Caption   = (Text="Arena Live Feed",Position=0.9);
  Switching = (bAllowAuto=False,bAllowManual=False,bAllowTimed=False,bAllowTriggered=False);

  bNoDelete = False;
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 16.2.2007 21:40:40.000 - Creation time: Do 14.8.2014 09:58:41.899 - Created with UnCodeX