Torque3D Documentation / _generateds / ExampleAsset.cpp

ExampleAsset.cpp

Engine/source/T3D/assets/ExampleAsset.cpp

More...

Public Functions

ConsoleSetType(TypeExampleAssetPtr )
ConsoleType(ExampleAssetPtr , TypeExampleAssetPtr , ExampleAsset , ASSET_ID_FIELD_PREFIX )

Detailed Description

Public Functions

ConsoleSetType(TypeExampleAssetPtr )

ConsoleType(ExampleAssetPtr , TypeExampleAssetPtr , ExampleAsset , ASSET_ID_FIELD_PREFIX )

IMPLEMENT_CONOBJECT(ExampleAsset )

  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
 24#ifndef _EXAMPLE_ASSET_H_
 25#include "ExampleAsset.h"
 26#endif
 27
 28#ifndef _ASSET_MANAGER_H_
 29#include "assets/assetManager.h"
 30#endif
 31
 32#ifndef _CONSOLETYPES_H_
 33#include "console/consoleTypes.h"
 34#endif
 35
 36#ifndef _TAML_
 37#include "persistence/taml/taml.h"
 38#endif
 39
 40#ifndef _ASSET_PTR_H_
 41#include "assets/assetPtr.h"
 42#endif
 43
 44// Debug Profiling.
 45#include "platform/profiler.h"
 46
 47//-----------------------------------------------------------------------------
 48
 49IMPLEMENT_CONOBJECT(ExampleAsset);
 50
 51ConsoleType(ExampleAssetPtr, TypeExampleAssetPtr, ExampleAsset, ASSET_ID_FIELD_PREFIX)
 52
 53//-----------------------------------------------------------------------------
 54
 55ConsoleGetType(TypeExampleAssetPtr)
 56{
 57   // Fetch asset Id.
 58   return (*((AssetPtr<ExampleAsset>*)dptr)).getAssetId();
 59}
 60
 61//-----------------------------------------------------------------------------
 62
 63ConsoleSetType(TypeExampleAssetPtr)
 64{
 65   // Was a single argument specified?
 66   if (argc == 1)
 67   {
 68      // Yes, so fetch field value.
 69      const char* pFieldValue = argv[0];
 70
 71      // Fetch asset pointer.
 72      AssetPtr<ExampleAsset>* pAssetPtr = dynamic_cast<AssetPtr<ExampleAsset>*>((AssetPtrBase*)(dptr));
 73
 74      // Is the asset pointer the correct type?
 75      if (pAssetPtr == NULL)
 76      {
 77         // No, so fail.
 78         //Con::warnf("(TypeExampleAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
 79         return;
 80      }
 81
 82      // Set asset.
 83      pAssetPtr->setAssetId(pFieldValue);
 84
 85      return;
 86   }
 87
 88   // Warn.
 89   Con::warnf("(TypeExampleAssetPtr) - Cannot set multiple args to a single asset.");
 90}
 91
 92//-----------------------------------------------------------------------------
 93
 94ExampleAsset::ExampleAsset()
 95{
 96}
 97
 98//-----------------------------------------------------------------------------
 99
100ExampleAsset::~ExampleAsset()
101{
102}
103
104//-----------------------------------------------------------------------------
105
106void ExampleAsset::initPersistFields()
107{
108   // Call parent.
109   Parent::initPersistFields();
110
111}
112
113//------------------------------------------------------------------------------
114
115void ExampleAsset::copyTo(SimObject* object)
116{
117   // Call to parent.
118   Parent::copyTo(object);
119}
120