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

IGEffectsSystem.EffectsSystem


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
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
class EffectsSystem extends Engine.IGEffectsSystemBase
    native
    config(EffectsSystem);

import enum EMaterialVisualType from Material;

var private config array< class<EffectsSubsystem> > EffectsSubsystem;       //named in the singular for clarity of configuration file
var private array<EffectsSubsystem> AllEffectsSubsystems;  // effects subsystems that were created in Init()

//This is a list of classes that need to be preloaded for effects purposes.
//Classes normally do not need to be preloaded.
//A class should be preloaded by the Effects System iff
//  1) effects may be played on instance(s) of the class, and
//  2) the class would otherwise not be loaded until PostBeginPlay(), ie. by a DynamicLoadObject().
//Note that if a class is dynamically loaded in PreBeginPlay(), then it does not need to be preloaded.
//Also, there is no harm in "Preloading" a class that would be loaded early enough anyway.
var private config array< String > PreloadActorClass;                 //named in the singular for clarity of configuration file

// switch on trigger logging in an .ini
var config bool LogEffectEvents;

var array<name> TemporaryContexts;
var array<name> PersistentContexts;

//Queued Events
//  (FYI, We're using multiple arrays because
//  - dynamic arrays of structs don't work in UnrealScript, and
//  - using an array of objects would leak those objects since objects aren't garbage collected)
var private bool            QueueingEvents;                 //is the system currently queueing events
var private array<Actor>    QueuedSource;
var private array<name>     QueuedEffectEvent;
var private array<Actor>    QueuedTarget;
var private array<Material> QueuedTargetMaterial;
var private array<vector>   QueuedOverrideWorldLocation;
var private array<rotator>  QueuedOverrideWorldRotation;
var private array<byte>     QueuedUnTriggered;

// DebugEffectEvent support:
//   The EffectsSystem will log details of a TriggerEffectEvent() call if the name of the EffectEvent triggered is in this list.
//   To make this work, you will need to add an exec function like the following to somewhere appropriate:
//     function DebugEffectEvent(name EffectEvent)
//     {
//         EffectsSystem(Level.EffectsSystem).DebugEffectEvent[EffectsSystem(Level.EffectsSystem).DebugEffectEvent.length] = EffectEvent;
//     }
var config array<name> DebugEffectEvent;    

simulated native function Init(Actor Owner);

simulated function EffectsSubsystem GetSubsystem(name inSubsystem)
{
    local int i;

    //find subsystem
    for (i=0; i<AllEffectsSubsystems.length; ++i)
        if (AllEffectsSubsystems[i].tag == inSubsystem)
            return AllEffectsSubsystems[i];

    //not found
    return None;
}

simulated function AddContextForNextEffectEvent(name Context)
{
    TemporaryContexts[TemporaryContexts.length] = Context;
}

//it is not an error to add a persistent context that is already a persistent context
simulated function AddPersistentContext(name Context)
{
    local int i;

    //don't add duplicate contexts to persistent list
    for (i=0; i<PersistentContexts.length; ++i)
        if (PersistentContexts[i] == Context)
            return;     //already in that context

    PersistentContexts[PersistentContexts.length] = Context;
}

//it is not an error to remove a persistent context that is not a current persistent context
simulated function RemovePersistentContext(name Context)
{
    local int i;

    for (i=0; i<PersistentContexts.length; ++i)
    {
        if (PersistentContexts[i] == Context)
        {
            PersistentContexts.Remove(i, 1);

            //it is guaranteed to be unique by AddPersistentContext(), so we're done.
            return;
        }
    }
}

simulated function ClearPersistentContexts()
{
    PersistentContexts.Remove(0, PersistentContexts.length);
}

//starts queueing events.  Effect Events will be queued until
//  FlushQueuedEvents() is called.
//It is not an error to call QueueEvents() when already queueing.
simulated function QueueEvents()
{
    QueueingEvents = true;
}

simulated event FlushQueuedEvents()
{
    local int i;

    QueueingEvents = false;

    for (i=0; i<QueuedSource.length; ++i)
    {	
		// rowan: check for cleaned up actors (=none) in the queued source array
		if (QueuedSource[i] != None)
		{
			EffectEventTriggered(
				QueuedSource[i],
				QueuedEffectEvent[i],
				QueuedTarget[i],
				QueuedTargetMaterial[i],
				QueuedOverrideWorldLocation[i],
				QueuedOverrideWorldRotation[i],
				(QueuedUnTriggered[i]!=0));                //convert byte to bool
		}
    }
    //empty the queueing arrays... thanks to Ryan for the tip
    QueuedSource.Remove(0, QueuedSource.length);
    QueuedEffectEvent.Remove(0, QueuedEffectEvent.length);
    QueuedTarget.Remove(0, QueuedTarget.length);
    QueuedTargetMaterial.Remove(0, QueuedTargetMaterial.length);
    QueuedOverrideWorldLocation.Remove(0, QueuedOverrideWorldLocation.length);
    QueuedOverrideWorldRotation.Remove(0, QueuedOverrideWorldRotation.length);
    QueuedUnTriggered.Remove(0, QueuedUnTriggered.length);
}

// Most parameters are documentated in Actor.uc TriggerEffectEvent()
simulated function bool EffectEventTriggered(
    Actor Source,
    name EffectEvent,
    optional Actor Target,
    optional Material TargetMaterial,
    optional vector overrideWorldLocation, 
    optional rotator overrideWorldRotation,
    optional bool unTriggered,
    optional bool PlayOnTarget,
    optional bool QueryOnly,
    optional IEffectObserver Observer,
    optional name Tag)
{
    local int i;
    local bool AnySubsystemFoundMatch;
	local String DebugString;
	local bool ThisSubsystemFoundMatch;

    if (QueueingEvents)
    {
        //array sizes should always be equal
        i = QueuedSource.length;
        assert( QueuedEffectEvent.length == i
            &&  QueuedTarget.length == i
            &&  QueuedTargetMaterial.length == i
            &&  QueuedOverrideWorldLocation.length == i
            &&  QueuedOverrideWorldRotation.length == i
            &&  QueuedUnTriggered.length == i);

        QueuedSource[i] = Source;
        QueuedEffectEvent[i] = EffectEvent;
        QueuedTarget[i] = Target;
        QueuedTargetMaterial[i] = targetMaterial;
        QueuedOverrideWorldLocation[i] = overrideWorldLocation;
        QueuedOverrideWorldRotation[i] = overrideWorldRotation;
        QueuedUnTriggered[i] = byte(unTriggered);   //convert bool to byte
    }
    else //dispatch to subsystems
    {
        if ( AllEffectsSubsystems.Length == 0 )
            return false;

        for (i=0; i<AllEffectsSubsystems.length; ++i)
		{
            if (AnySubsystemFoundMatch && QueryOnly)
			{
                return AnySubsystemFoundMatch;
			}
            else
			{
				ThisSubsystemFoundMatch = 
				AllEffectsSubsystems[i].EffectEventTriggered(
						Source, EffectEvent, Target, TargetMaterial, overrideWorldLocation, 
                        overrideWorldRotation, unTriggered, PlayOnTarget, QueryOnly, Observer, Tag
                    );
				AnySubsystemFoundMatch = ThisSubsystemFoundMatch ||  AnySubsystemFoundMatch;
			}
		}
	}
	
	// DebugEffectEvent support
    for (i=0; i<DebugEffectEvent.length; ++i)
	{
        if (DebugEffectEvent[i] == EffectEvent)
		{
			DebugString = "EffectsSystem::EffectEventTriggered() ";

            DebugString = DebugString$" EffectEvent="$EffectEvent$": ";

            DebugString = DebugString$"AnythingMatched="$AnySubsystemFoundMatch;

			if (Source!=None)
				DebugString = DebugString$", Source.Class="$Source.Class.name;
			else
					DebugString = DebugString$", Source.Class=None";			


			if (Target!=None) 
				DebugString = DebugString$", Target="$Target.class.name;
			else
				DebugString = DebugString$", Target=None";

			if (TargetMaterial!=None) 
			{
				DebugString = DebugString
					$", TargetMaterial.MaterialSoundType="$TargetMaterial.MaterialSoundType
					$", TargetMaterial.MaterialVisualType="$GetEnum(EMaterialVisualType, TargetMaterial.MaterialVisualType)$" ("$TargetMaterial.MaterialVisualType$")";
			}
			else
			{
				DebugString = DebugString
					$", TargetMaterial.MaterialSoundType=Unknown, TargetMaterial.MaterialVisualType=Unknown";
			}

			DebugString = DebugString
				$", UnTriggered="$UnTriggered
				$", PlayOnTarget="$PlayOnTarget
				$", QueryOnly="$QueryOnly
				$", Observer="$Observer
                $", Tag="$Tag;
            
            DebugString = DebugString$" ZoneContexts=[";
            for (i = 0; i < Source.Region.Zone.EffectsContexts.Length; i++)
                DebugString = DebugString$" "$Source.Region.Zone.EffectsContexts[i];
            DebugString = DebugString$" ]";

            DebugString = DebugString$" PersistentContexts=[";
            for (i = 0; i < PersistentContexts.Length; i++)
                DebugString = DebugString$" "$PersistentContexts[i];
            DebugString = DebugString$" ]";

            //tcohen 6/22/2004 Note that the TemporaryContexts report will be wrong if anything
            //  matches for the 'Spawned' or 'Alive' events on an effect, because the
            //  TemporaryContexts list will have already been cleared by now.
            DebugString = DebugString$" TemporaryContexts=[";
            for (i = 0; i < TemporaryContexts.Length; i++)
                DebugString = DebugString$" "$TemporaryContexts[i];
            DebugString = DebugString$" ]";

			log (DebugString);
		}
	}

    //clear contexts after every EffectEventTriggered()
    TemporaryContexts.Remove(0, TemporaryContexts.length);

    return AnySubsystemFoundMatch;
}

// Dump the state of an EffectsSubsystem to the log
//
// SubsystemName should be one of "VISUAL" or "SOUND",
// since only IGSoundEffectsSubsystem and IGVisualEffectSubsytem 
// are currently supported
exec function DumpEffects(Name SubsystemName)
{
    local EffectsSubsystem SubSys;
    local Name ClassName;
        
    if (SubsystemName == 'SOUND')
    {
        ClassName = 'SoundEffectsSubsystem';
    }
    else if (SubsystemName == 'VISUAL')
    {
        ClassName = 'VisualEffectsSubsystem';
    }

    Subsys = GetSubsystem(ClassName);
    if (Subsys == None)
    {
        Warn("WARNING: Cannot dump effects; subsystem not found: "$ClassName);
        return;
    }
    Subsys.LogState();
}

defaultproperties
{
    //the system initially queues events, until it is initialized
    QueueingEvents=true
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:02:12.000 - Creation time: st 23.5.2018 00:10:43.216 - Created with UnCodeX