예제 #1
0
파일: Incoming.cs 프로젝트: wshanshan/DDD
/// <summary>
/// Adds an item to the Incoming event list
/// </summary>
/// <param name="e">An event (published by a lower level)</param>
        public static void Add(ScenarioEventType e)
        {
            lock(syncObject)
            {
            incoming.Add(e);
            }
        }
예제 #2
0
파일: Timer.cs 프로젝트: wshanshan/DDD
        public static void SeekSpeciesHappening(ScenarioEventType thisItem, string dataToTest)
        {
            for (int sce = SpeciesHappeningList.Happenings.Count - 1; sce >= 0; sce--)
            {
                if (SpeciesHappeningList.Happenings[sce].Matches(thisItem, dataToTest))
                {
                    SpeciesHappeningList.Happenings[sce].EnqueueEvents(thisItem.UnitID);
                    break;

                }


            }
        }
예제 #3
0
파일: EventLists.cs 프로젝트: wshanshan/DDD
 /// <summary>
 /// Add an event to the time queue
 /// </summary>
 /// <param name="time">The time at which this event fires</param>
 /// <param name="newEvent">The event to add</param>
 public static void Add(int time, ScenarioEventType newEvent)
 {
     time = Math.Max(_lastRetrievedTime + 1, time); //AD: put in place so you don't enqueue an event in the past
     //that should be sent out on the next time tick.
     if (!queue.ContainsKey(time))
     {
         queue.Add(time, new TimeNodeClass(time));
     }
     queue[time].AddEvent(newEvent);
 }
예제 #4
0
파일: EventLists.cs 프로젝트: wshanshan/DDD
        /// <summary>
        /// Adds an event to this node
        /// </summary>
        /// <param name="e"></param>
        public void AddEvent(ScenarioEventType e)
        {
            theseEvents.Add(e);
            if (e is ScenarioEventType)
            {

                if (!(theseUnits.ContainsKey(e.UnitID)))
                {
                    theseUnits.Add(e.UnitID, 1);
                }
                else
                {
                    theseUnits[e.UnitID] += 1;
                }

                List<string> allUnits = e.AllUnits;
                for (int other = 0; other < allUnits.Count; other++)
                {
                    if (!(TheseUnits.ContainsKey(allUnits[other])))
                    {
                        theseUnits.Add(allUnits[other], 1);
                    }
                    else
                    {
                        theseUnits[allUnits[other]] += 1;
                    }

                }
            }
        }
예제 #5
0
파일: EventLists.cs 프로젝트: wshanshan/DDD
        public static Boolean AttackApproved(ScenarioEventType s)
        {
            Boolean returnValue = false;
            /*
             * Approval algorithm;
             * If there are no matches on list, return check default condition
             * If there are any matches then any one that gives permission is enough
             * */

            Boolean denied = false;
            if ("Aptima.Asim.DDD.ScenarioController.AttackObjectRequestType" != s.GetType().ToString())
                return returnValue;
            AttackObjectRequestType alias = (AttackObjectRequestType)s;
            for (int i = 0; i < approvals.Count; i++)
            {
                ScenarioEventType candidate = approvals[i];
                if ("Aptima.Asim.DDD.ScenarioController.AttackRequestApprovalType" != candidate.GetType().ToString())
                    continue;
                AttackRequestApprovalType rule = (AttackRequestApprovalType)candidate;
                if (rule.Capability != alias.CapabilityName)
                    continue;

                if (rule.Actor != "")
                {
                    if ((!rule.ActorIsSpecies) && (rule.Actor != alias.UnitID))
                    {

                        continue;
                    }
                    if (rule.ActorIsSpecies && !Genealogy.UnderSpecies(alias.UnitID, rule.Actor))
                    {
                        continue;
                    }

                }
                if (rule.Target != "")
                {
                    if ((!rule.TargetIsSpecies) && (rule.Target != alias.TargetObjectID))
                    {
                        continue;
                    }
                    if (rule.TargetIsSpecies && !Genealogy.UnderSpecies(alias.TargetObjectID, rule.Target))
                    {
                        continue;
                    }

                }
                if (rule.TargetStates.Count != 0)
                {
                    if (!rule.TargetStates.Contains(UnitFacts.CurrentUnitStates[alias.TargetObjectID]))
                        continue;
                }
                // At this point we can say that the rule legitimaly refers to alias.UnitID
                if (!rule.EngramValid(alias.UnitID, alias.TargetObjectID))
                {
                    denied = true;
                    continue;
                }
                if ((rule.UseDefault) && (alias.DecisionMaker != UnitFacts.GetDM(alias.UnitID)))
                {
                    denied = true;
                    continue;
                }
                //Wow. This rule was passed
                returnValue = true;
                break;

            }
            if (!returnValue && !denied)
            {// Now use the default rule
                DecisionMakerType unitDM = DecisionMakerType.GetDM(UnitFacts.GetDM(alias.UnitID));
                if (
                    (alias.DecisionMaker == unitDM.Identifier)
          // &&
           //(UnitFacts.HostileTo(unitDM.Team, DecisionMakerType.GetDM(UnitFacts.GetDM(alias.TargetObjectID)).Team))
                    //AD: Changed to allow for non-hostiles to be engaged, as they are requested by live players.
                    )
                    returnValue = true;
            }
            return returnValue;
        }
예제 #6
0
파일: EventLists.cs 프로젝트: wshanshan/DDD
 public static void Add(ScenarioEventType s)
 {
     approvals.Add(s);
 }
예제 #7
0
 public void Add(ScenarioEventType s)
 {
     reiterateList.Add(s);
 }
예제 #8
0
        /// <summary>
        /// Tells whether this event is "about" this unit 
        /// </summary>
        /// <param name="unitID">unit identifier</param>
        /// <returns>True if unit is a predicate of event of the condition event it packages</returns>

        public Boolean Matches(ScenarioEventType incoming, string actionOrState)
        {
            /*
             * Note: This does not pay attention to any parameter other than the species -- i.e.,
             *  to which other units the action involves
             */
            Boolean returnValue = Genealogy.UnderSpecies(incoming.UnitID, this.species);
            if (returnValue)
            {
                returnValue = returnValue && (
                    (isAction && (action == actionOrState))
                    ||
                    (isStateChange && (newState == actionOrState))
                    );
            }
            return returnValue;
        }
예제 #9
0
 public void Add(ScenarioEventType s)
 {
     doThisList.Add(s);
 }
예제 #10
0
파일: Incoming.cs 프로젝트: wshanshan/DDD
 /// <summary>
 /// Constructs an item being returned from the Incoming list
 /// This is a container for the actual event
 /// </summary>
 /// <param name="theEvent">The event fas ound on the list</param>
 /// <param name="theIndex">The sequential position of the event</param>
 public IncomingItemType(ScenarioEventType theEvent, int theIndex)
 {
     this.theEvent = theEvent;
     this.theIndex = theIndex;
 }