123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using CommonLang;
- using CommonLang.Concurrent;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CommonAI.Zone
- {
- abstract public class GameEntity : Disposable
- {
- private HashMap<string, object> mAttributes = new HashMap<string, object>();
-
- public GameEntity()
- {
- }
- public bool IsAttribute(string key)
- {
- return mAttributes.ContainsKey(key);
- }
- public void SetAttribute(string key, object value)
- {
- mAttributes.Put(key, value);
- }
- public object RemoveAttribute(string key)
- {
- return mAttributes.RemoveByKey(key);
- }
- public object GetAttribute(string key)
- {
- return mAttributes.Get(key);
- }
- public T GetAttributeAs<T>(string key)
- {
- object obj = mAttributes.Get(key);
- if (obj != null)
- {
- return (T)obj;
- }
- return default(T);
- }
- protected override void Disposing()
- {
- mAttributes.Clear();
- }
-
- }
- }
|