Beispiel #1
0
 internal void Setup(LSAgent agent, int id)
 {
     System.Type mainType = this.GetType();
     if (mainType.IsSubclassOf(typeof(ActiveAbility)))
     {
         while (mainType.BaseType != typeof(ActiveAbility) &&
                mainType.GetCustomAttributes(typeof(CustomActiveAbilityAttribute), false).Length == 0)
         {
             mainType = mainType.BaseType;
         }
         Data = AbilityDataItem.FindInterfacer(mainType);
         if (Data == null)
         {
             throw new System.ArgumentException("The Ability of type " + mainType + " has not been registered in database");
         }
         this.MyAbilityCode = Data.Name;
     }
     else
     {
         this.MyAbilityCode = mainType.Name;
     }
     _agent = agent;
     ID     = id;
     TemplateSetup();
     OnSetup();
     this.VariableContainerTicket = LSVariableManager.Register(this);
     this._variableContainer      = LSVariableManager.GetContainer(VariableContainerTicket);
 }
Beispiel #2
0
        public IEnumerable <LSVariable> GetDesyncs(int[] compare)
        {
            int position = 0;

            foreach (int ticket in this.TrackedLockstepTickets)
            {
                LSVariableContainer container = LSVariableManager.GetContainer(ticket);
                int[] hashes = container.GetCompareHashes();
                for (int i = 0; i < hashes.Length; i++)
                {
                    if (compare[i] != hashes[position])
                    {
                        yield return(container.Variables[i]);
                    }
                    position++;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Registers an object and returns a ticket to access variable info about the object.
        /// Note: Ticket may vary on multiple clients and sessions.
        /// </summary>
        /// <param name="lockstepObject">Lockstep object.</param>
        public static int Register(object lockstepObject)
        {
            Type type = lockstepObject.GetType();

            string[]            propertyNames;
            LSVariableContainer container;

            if (!CachedLockstepPropertyNames.TryGetValue(type, out propertyNames))
            {
                bufferPropertyNames.FastClear();
                container = new LSVariableContainer(GetVariables(lockstepObject, type));
                foreach (LSVariable info in container.Variables)
                {
                    bufferPropertyNames.Add(info.Info.Name);
                }
                CachedLockstepPropertyNames.Add(type, bufferPropertyNames.ToArray());
            }
            else
            {
                container = new LSVariableContainer(GetVariables(lockstepObject, type, propertyNames));
            }
            return(Containers.Add(container));
        }