Jypeli  9
The simple game programming library
GroupIgnorer.cs
Siirry tämän tiedoston dokumentaatioon.
1 #region MIT License
2 /*
3  * Copyright (c) 2005-2008 Jonathan Mark Porter. http://physics2d.googlepages.com/
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 deal
7  * in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #endregion
23 
24 
25 
26 #if UseDouble
27 using Scalar = System.Double;
28 #else
29 using Scalar = System.Single;
30 #endif
31 using System;
32 using Jypeli.Physics;
33 
34 namespace Jypeli
35 {
40  public class GroupIgnorer : Ignorer
41  {
43  public GroupIgnorer()
44  {
45  this.groups = new GroupCollection();
46  }
47  protected GroupIgnorer(GroupIgnorer copy)
48  : base(copy)
49  {
50  this.groups = new GroupCollection(copy.groups);
51  }
52  public override bool BothNeeded
53  {
54  get { return false; }
55  }
56  public GroupCollection Groups { get { return groups; } }
57  public bool CanCollide(GroupIgnorer other)
58  {
59  if (other == null) { throw new ArgumentNullException("other"); }
60  return CanCollideInternal(other);
61  }
62  private bool CanCollideInternal(GroupIgnorer other)
63  {
64  return !GroupCollection.Intersect(groups, other.groups);
65  }
66  public override bool CanCollide( IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other )
67  {
68  GroupIgnorer value = other as GroupIgnorer;
69  return
70  value == null ||
71  CanCollideInternal(value);
72  }
73  public virtual object Clone()
74  {
75  return new GroupIgnorer(this);
76  }
77  }
78 }
Jypeli.GroupIgnorer.Groups
GroupCollection Groups
Definition: GroupIgnorer.cs:56
Jypeli.GroupIgnorer.CanCollideInternal
bool CanCollideInternal(GroupIgnorer other)
Definition: GroupIgnorer.cs:62
Jypeli
Definition: Automobile.cs:5
Jypeli.GroupCollection.Intersect
static bool Intersect(GroupCollection groups1, GroupCollection groups2)
Definition: GroupCollection.cs:41
Jypeli.GroupIgnorer.GroupIgnorer
GroupIgnorer(GroupIgnorer copy)
Definition: GroupIgnorer.cs:47
Jypeli.GroupIgnorer.Clone
virtual object Clone()
Definition: GroupIgnorer.cs:73
Jypeli.GroupIgnorer
A collision ignorer that uses group numbers to do collision ignoring. If 2 objects are members of the...
Definition: GroupIgnorer.cs:41
Jypeli.GroupIgnorer.CanCollide
bool CanCollide(GroupIgnorer other)
Definition: GroupIgnorer.cs:57
Jypeli.Ignorer
Base class for Collision Ignorers to impliment.
Definition: Ignorer.cs:40
Jypeli.Physics.IPhysicsBody
Definition: IPhysicsBody.cs:4
Scalar
System.Single Scalar
Definition: Clamped.cs:29
Jypeli.GroupIgnorer.groups
GroupCollection groups
Definition: GroupIgnorer.cs:42
Jypeli.GroupIgnorer.BothNeeded
override bool BothNeeded
Definition: GroupIgnorer.cs:53
Jypeli.GroupIgnorer.GroupIgnorer
GroupIgnorer()
Definition: GroupIgnorer.cs:43
Jypeli.Physics
Definition: Collision.cs:4
Jypeli.GroupCollection
A collection that stores ints that represent groups
Definition: GroupCollection.cs:40
System
Definition: CFFauxAttributes.cs:29
Jypeli.GroupIgnorer.CanCollide
override bool CanCollide(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other)
Definition: GroupIgnorer.cs:66