MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Element_Res.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  Element_Res.h Basic resource element
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
28 #ifndef ELEMENT_RES_H
29 #define ELEMENT_RES_H
30 
31 #include "Element.h"
32 #include "EventWindow.h"
33 #include "ElementTable.h"
34 #include "itype.h"
35 #include "P1Atom.h"
36 
37 namespace MFM
38 {
39 
40 #define RES_VERSION 1
41 
47  template <class CC>
48  class Element_Res : public Element<CC>
49  {
50  // Extract short names for parameter types
51  typedef typename CC::ATOM_TYPE T;
52 
53  public:
54  static Element_Res THE_INSTANCE;
55  static const u32 TYPE() {
56  return THE_INSTANCE.GetType();
57  }
58 
59  Element_Res() : Element<CC>(MFM_UUID_FOR("Res", RES_VERSION))
60  {
62  Element<CC>::SetName("Res");
63  }
64 
65  virtual u32 PercentMovable(const T& you,
66  const T& me, const SPoint& offset) const
67  {
68  return 100;
69  }
70 
71  virtual u32 DefaultPhysicsColor() const
72  {
73  return 0xff676700;
74  }
75 
76  virtual u32 DefaultLowlightColor() const
77  {
78  return 0xff333300;
79  }
80 
81  virtual const char* GetDescription() const
82  {
83  return "The Element which represents a universal resource. Other atoms may freely "
84  "convert these atoms into something else without disturbing the DREG's "
85  "regulatory properties.";
86  }
87 
88  virtual void Behavior(EventWindow<CC>& window) const
89  {
90  this->Diffuse(window);
91  }
92  };
93 
94  template <class CC>
95  Element_Res<CC> Element_Res<CC>::THE_INSTANCE;
96 
97 }
98 
99 #endif /* ELEMENT_RES_H */
void Diffuse(EventWindow< CC > &window) const
Definition: Element.tcc:73
u32 GetType() const
Definition: Element.h:290
void SetName(const char *name)
Definition: Element.h:209
void SetAtomicSymbol(const char *symbol)
Definition: Element.h:193
virtual u32 DefaultPhysicsColor() const
Definition: Element_Res.h:71
virtual const char * GetDescription() const
Definition: Element_Res.h:81
Definition: Element_Res.h:48
Definition: ElementTable.h:43
virtual void Behavior(EventWindow< CC > &window) const
Definition: Element_Res.h:88
Definition: Atom.h:43
virtual u32 PercentMovable(const T &you, const T &me, const SPoint &offset) const
Definition: Element_Res.h:65
virtual u32 DefaultLowlightColor() const
Definition: Element_Res.h:76