コード例 #1
0
        private IRefBase AddNew(IClassBase classBase, object value)
        {
            var id      = NextId();
            var refBase = classBase.Create(id, value);

            AddNewInstance(classBase, refBase, id);
            return(refBase);
        }
コード例 #2
0
        private IRef <T> AddNew <T>(IClassBase classBase, T value)
        {
            var id = NextId();

            classBase.NewRef(id, out var refBase);
            refBase.BaseValue = value;
            AddNewInstance(classBase, refBase, id);
            return(refBase as IRef <T>);
        }
コード例 #3
0
        private void Reflect(IClassBase classBase, IRefBase refBase)
        {
            if (!(refBase.BaseValue is IReflected reflected))
            {
                return;
            }

            reflected.SelfBase = refBase;
            if (!(refBase is ConstRefBase self))
            {
                throw new Exception("Internal error: IRef is not a ConstRef");
            }

            self.Registry = this;
            self.Class    = classBase;
        }
コード例 #4
0
        public void CreateDefaultCharacter(string name)
        {
            Greatsword greatSword = new Greatsword();
            ScaleMail  scaleMail  = new ScaleMail();

            Level               = 1;
            Name                = name;
            _class              = new Fighter();
            Weapon              = greatSword;
            Armor               = scaleMail;
            Strength            = 16;
            Dexterity           = 14;
            Constitution        = 12;
            Intelligence        = 8;
            Wisdom              = 10;
            Charisma            = 11;
            MaxHeathPoints      = (byte)(_class.hitDie + ConstitutionModifier);
            CurrentHealthPoints = MaxHeathPoints;
        }
コード例 #5
0
 public void CreateDefaultCharacter(string name)
 {
     Greatsword greatSword = new Greatsword();
     ScaleMail scaleMail = new ScaleMail();
     Level = 1;
     Name = name;
     _class = new Fighter();
     Weapon = greatSword;
     Armor = scaleMail;
     Strength = 16;
     Dexterity = 14;
     Constitution = 12;
     Intelligence = 8;
     Wisdom = 10;
     Charisma = 11;
     MaxHeathPoints = (byte)(_class.hitDie + ConstitutionModifier);
     CurrentHealthPoints = MaxHeathPoints;
 }
コード例 #6
0
 public IRefBase NewRef(IClassBase @class, Stack <object> dataStack)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public object New(IClassBase @class, Stack <object> dataStack)
 {
     return(@class.NewInstance());//dataStack);
 }
コード例 #8
0
 private void AddClass(Type type, IClassBase @class)
 {
     _classes[type]         = @class;
     _classNames[type.Name] = @class;
 }
コード例 #9
0
 public bool Register(IClassBase @class)
 {
     AddClass(@class.Type, @class);
     return(true);
 }
コード例 #10
0
 private void AddNewInstance(IClassBase classBase, IRefBase refBase, Id id)
 {
     Reflect(classBase, refBase);
     _instances.Add(id, refBase);
 }
コード例 #11
0
 private IRef <T> AddNew <T>(IClassBase classBase)
 {
     return(AddNew <T>(classBase, (T)classBase.NewInstance()));
 }
コード例 #12
0
 public ConstRefBase(IRegistry reg, IClassBase @class, Id id, object val)
     : this(reg, @class, id)
 {
     reg.AddConst(val);
 }
コード例 #13
0
 public ConstRefBase(IRegistry reg, IClassBase klass, Id id)
 {
     _id      = id;
     Registry = reg;
     Class    = klass;
 }
コード例 #14
0
 public ConstRef(IRegistry reg, IClassBase @class, Id id, T value)
     : this(reg, @class, id)
 {
     reg.AddConst(value);
 }
コード例 #15
0
 public ConstRef(IRegistry reg, IClassBase @class, Id id)
     : base(reg, @class, id)
 {
 }