ScriptAsset.h

Engine/source/T3D/assets/ScriptAsset.h

More...

Classes:

Public Functions

DefineConsoleType(TypeScriptAssetPtr , ScriptAsset )

Detailed Description

Public Functions

DefineConsoleType(TypeScriptAssetPtr , ScriptAsset )

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2013 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23#ifndef SCRIPT_ASSET_H
24#define SCRIPT_ASSET_H
25#pragma once
26
27#ifndef _ASSET_BASE_H_
28#include "assets/assetBase.h"
29#endif
30
31#ifndef _ASSET_DEFINITION_H_
32#include "assets/assetDefinition.h"
33#endif
34
35#ifndef _STRINGUNIT_H_
36#include "string/stringUnit.h"
37#endif
38
39#ifndef _ASSET_FIELD_TYPES_H_
40#include "assets/assetFieldTypes.h"
41#endif
42
43#ifndef _ASSET_PTR_H_
44#include "assets/assetPtr.h"
45#endif
46
47//-----------------------------------------------------------------------------
48class ScriptAsset : public AssetBase
49{
50   typedef AssetBase Parent;
51
52   StringTableEntry        mScriptFile;
53   StringTableEntry        mScriptPath;
54   bool                    mIsServerSide;
55
56   Vector<AssetPtr<ScriptAsset>> mScriptAssets;
57
58public:
59   ScriptAsset();
60   virtual ~ScriptAsset();
61
62   /// Engine.
63   static void initPersistFields();
64   virtual void copyTo(SimObject* object);
65
66   /// Declare Console Object.
67   DECLARE_CONOBJECT(ScriptAsset);
68
69   void                    setScriptFile(const char* pScriptFile);
70   inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
71
72   inline StringTableEntry getScriptPath(void) const { return mScriptPath; };
73
74   bool execScript();
75
76protected:
77   virtual void            initializeAsset(void);
78   virtual void            onAssetRefresh(void);
79
80   static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<ScriptAsset*>(obj)->setScriptFile(data); return false; }
81   static const char* getScriptFile(void* obj, const char* data) { return static_cast<ScriptAsset*>(obj)->getScriptFile(); }
82};
83
84DefineConsoleType(TypeScriptAssetPtr, ScriptAsset)
85
86#endif // _ASSET_BASE_H_
87
88