Advertisement
KpoKec

Untitled

Jul 25th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using Controllers;
  3. using SO;
  4.  
  5. namespace Effects {
  6.     [Serializable]
  7.     public class EffectHolder {
  8.         public int                  id;
  9.         public EffectsSO.EffectData Effect => MainDatabase.Effects.GetEffect(id);
  10.  
  11.         public EffectHolder(string name) {
  12.             id = MainDatabase.Effects.GetId(name);
  13.         }
  14.  
  15.         public EffectHolder(int id) {
  16.             this.id = id;
  17.         }
  18.  
  19.         protected bool Equals(EffectHolder other) {
  20.             return id == other.id;
  21.         }
  22.  
  23.         public override bool Equals(object obj) {
  24.             if (obj                     == null) return (false);
  25.             if (obj.GetType()           != this.GetType()) return false;
  26.             if (((EffectHolder) obj).id == -1) return false;
  27.             return (this.id == ((EffectHolder) obj).id);
  28.         }
  29.  
  30.         public override int GetHashCode() {
  31.             return id;
  32.         }
  33.  
  34.         public static bool operator ==(EffectHolder e1, EffectHolder e2) {
  35.             if (e1 == null || e1.id == -1) return (e2 == null || e2.id == -1);
  36.             return e1.Equals(e2);
  37.         }
  38.  
  39.         public static bool operator !=(EffectHolder e1, EffectHolder e2) {
  40.             return !(e1 == e2);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement