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

IGEffectsSystem.EffectsSubsystem


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
class EffectsSubsystem extends Engine.Actor
    native
    abstract;

var EffectsSystem EffectsSystem;                                //note: assigned after Spawn() returns, so not available in *BeginPlay()

var private config array<Name> EventResponse;            		//named in the singular for clarity of configuration file

var class EffectSpecificationSubClass;

var private bool debugSlow;                                     //if true, does some error checking that takes extra time

//native noexport variables (must come last)

var private native noexport const int EventResponses[5];        //Declared as a TMultiMap<FName, UEventResponse*> in AEffectsSystem.h
var private native noexport const int EffectSpecifications[5];  //Declared as a TMap<FName, UEffectSpecification*> in AEffectsSystem.h

simulated function PreBeginPlay()
{
    local EventResponse newEventResponse;
    local int i;

    Super.PreBeginPlay();

    for (i=0; i<EventResponse.length; ++i)
    {
        //instantiate event responses
        newEventResponse = new(self, string(EventResponse[i]), 0) class'EventResponse';

        //the special EventReseponse SourceClassName 'Level' means that all
        //  specifications referenced by the Response should automatically
        //  be instantiated for the Level specified by Event.
        if (newEventResponse.SourceClassName == 'Level')
        {
            if (Level.Label == newEventResponse.Event)
                InitializeResponseSpecifications(newEventResponse);
            
            //note that newEventResponse is not added to the EventResponses hash, since
            //  the EventResponse is not meant to ever match an EffectEvent.
        }
        else
        {
        //hook-up source & target classes.
        //
        //they're specified by names in the config files so that they will not be loaded
        //  just because they're the subject of events.  Thus we do a DynamicFindObject()
        //  and hook-up the classes only if they're already loaded for another purpose.

        newEventResponse.SourceClass =
            class<Actor>(
                    DynamicFindObject(
                        String(newEventResponse.SourceClassName),
                        class'Class'));

        //if the SourceClass is in this map, then this event could happen,
        //  so add it to the collection of EventResponses.
        if (newEventResponse.SourceClass != None)
        {
            //the hash key for EventResponses is ClassName+EventName, since these are the mandatory data members
            AddEventResponse(
                name(String(newEventResponse.SourceClassName)$String(newEventResponse.Event)), newEventResponse);

                newEventResponse.Init();
                InitializeResponseSpecifications(newEventResponse);
            }
        }
    }

	if (debugSlow)
	{
		log(name$" Initialized.  Statistics:");
//		log(name$" EventResponses -"); EventResponses.Profile();
//		log(name$" EffectSpecifications -"); EffectSpecifications.Profile();
	}
}

native function AddEventResponse(name EventResponseName, EventResponse EventResponse);

function InitializeResponseSpecifications(EventResponse EventResponse)
{
    local EffectSpecification newEffectSpecification;
    local int i;

    //instantiate the specifications referenced by this response,
    //  and add them to the collection of specifications.
    //(if the specification has already been instantiated, then just
    //  reference that instance.)
    for (i=0; i<EventResponse.Specification.length; ++i)
    {
        //a 'None' specification is valid, ie. there's a chance of doing nothing in response to the event
        if (EventResponse.Specification[i].SpecificationType != 'None')
        {
            //lookup to see if the specification has already been instantiated
            newEffectSpecification = FindEffectSpecification(EventResponse.Specification[i].SpecificationType);

            if (newEffectSpecification == None)     //not yet instantiated, so instantiate it
            {
#if IG_TRIBES3  //tcohen: Tribes prefers error messages in the log.
                // validate the class... warfare crashes out big time if its not valid
                if (class<EffectSpecification>(EventResponse.Specification[i].SpecificationClass) == None)
                {
                    Log("ERROR! EventResponse ["$EventResponse.Event$"] hooked up to invalid specification ["$EventResponse.Specification[i].SpecificationType$"]");
                    continue;
                }
#else     // TMC I prefer AssertWithDescription()s.
                AssertWithDescription(class<EffectSpecification>(EventResponse.Specification[i].SpecificationClass) != None,
                    "[tcohen] EffectsSubsystem::InitializeResponseSpecifications() The EventResponse "$EventResponse.name
                    $" lists specification #"$i
                    $" (base zero) as "$EventResponse.Specification[i].SpecificationType
                    $", but that's not a valid class of EffectSpecification.");
#endif

                newEffectSpecification = EffectSpecification(
                        new(self, string(EventResponse.Specification[i].SpecificationType), 0) EventResponse.Specification[i].SpecificationClass); 
                assert(newEffectSpecification!=None);
                newEffectSpecification.Init(self);

                //the hash key for EffectSpecifications is the EffectSpecification's name
                AddEffectSpecification(newEffectSpecification.name, newEffectSpecification);
            }

            EventResponse.SpecificationReference[i] = newEffectSpecification;
        }
    }
}

native function EffectSpecification FindEffectSpecification(name EffectSpecificationName);

native function AddEffectSpecification(name EffectSpecificationName, EffectSpecification EffectSpecification);

// See parameter documentation in Actor.uc TriggerEffectEvent()
native function bool EffectEventTriggered(
        Actor Source,
        name EffectEvent,
        optional Actor Target,
        optional Material TargetMaterial,
        optional vector overrideWorldLocation,
        optional rotator overrideWorldRotation,
        optional bool unTriggered, //only one EffectSpecification should be specified for EffectEvents that may be UnTriggered
        optional bool PlayOnTarget,
        optional bool QueryOnly,
        optional IEffectObserver Observer,
        optional name Tag);

simulated function EffectSpecification GetSpecificationByString(string Specification)
{
    return FindEffectSpecification(name(Specification));
}

// Should print the current state of the subsystem to the log (via Log()) in a
// human-readable form that is suitable for debugging.
simulated function LogState() 
{
    Log("LogState not implemented for subsystem: "$self);
}

simulated event Actor PlayEffectSpecification(
        EffectSpecification EffectSpec,
        Actor Source,
        optional Actor Target,
        optional Material TargetMaterial,
        optional vector overrideWorldLocation,
        optional rotator overrideWorldRotation,
        optional IEffectObserver Observer)
{ assert(false); return None; }  // must implement in subclass!!!

simulated event StopEffectSpecification(
        EffectSpecification EffectSpec,
        Actor Source);

simulated event OnEffectSpawned(Actor SpawnedEffect);

defaultproperties
{
    debugSlow=true
        bHidden=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.209 - Created with UnCodeX