MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Element_Block.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  Element_Block.h Basic non-diffusing non-behaving lump
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 
27 #ifndef ELEMENT_BLOCK_H
28 #define ELEMENT_BLOCK_H
29 
30 #include "Element.h"
31 #include "EventWindow.h"
32 #include "ElementTable.h"
33 #include "itype.h"
34 #include "Atom.h"
35 
36 namespace MFM
37 {
38 
39  template <class CC>
40  class Element_Block : public Element<CC>
41  {
42  // Short names for params
43  typedef typename CC::ATOM_TYPE T;
44  typedef typename CC::PARAM_CONFIG P;
45  enum { R = P::EVENT_WINDOW_RADIUS };
46 
47  public:
48  enum {
49  BLOCK_VERSION = 1
50  };
51 
52  static Element_Block THE_INSTANCE;
53  static const u32 TYPE()
54  {
55  return THE_INSTANCE.GetType();
56  }
57 
58  Element_Block() : Element<CC>(MFM_UUID_FOR("Block", BLOCK_VERSION))
59  {
61  Element<CC>::SetName("Block");
62  }
63 
64  virtual const T & GetDefaultAtom() const
65  {
66  static T defaultAtom(TYPE(),0,0,0);
67  return defaultAtom;
68  }
69 
70  virtual u32 DefaultPhysicsColor() const
71  {
72  return 0xff00ff00;
73  }
74 
75  virtual u32 DefaultLowlightColor() const
76  {
77  return 0xff00af00;
78  }
79 
80  virtual u32 Diffusability(EventWindow<CC> & ew, SPoint nowAt, SPoint maybeAt) const
81  {
82  return nowAt.Equals(maybeAt)?Element<CC>::COMPLETE_DIFFUSABILITY:0;
83  }
84 
85  virtual u32 PercentMovable(const T& you,
86  const T& me, const SPoint& offset) const
87  {
88  return 0;
89  }
90 
91  virtual void Behavior(EventWindow<CC>& window) const
92  {}
93  };
94 
95  template <class CC>
96  Element_Block<CC> Element_Block<CC>::THE_INSTANCE;
97 }
98 
99 #endif /* ELEMENT_BLOCK_H */
virtual void Behavior(EventWindow< CC > &window) const
Definition: Element_Block.h:91
virtual u32 PercentMovable(const T &you, const T &me, const SPoint &offset) const
Definition: Element_Block.h:85
u32 GetType() const
Definition: Element.h:290
virtual u32 DefaultPhysicsColor() const
Definition: Element_Block.h:70
bool Equals(const Point< T > &rhs) const
Definition: Point.tcc:205
void SetName(const char *name)
Definition: Element.h:209
void SetAtomicSymbol(const char *symbol)
Definition: Element.h:193
virtual u32 Diffusability(EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
Definition: Element_Block.h:80
virtual const T & GetDefaultAtom() const
Definition: Element_Block.h:64
Definition: ElementTable.h:43
Definition: Element_Block.h:40
Definition: Atom.h:43
virtual u32 DefaultLowlightColor() const
Definition: Element_Block.h:75