Exemplo n.º 1
0
        public override ProgrammingElement Clone()
        {
            VerbActuator clone = new VerbActuator();

            CopyTo(clone);
            return(clone);
        }
        private void SetUpShotDamage(Reflex reflex, MissileHitTargetParam param)
        {
            if (param.defaultDamage != 0)
            {
                param.hitStrength = param.defaultDamage;
            }

            VerbActuator verbActuator = reflex.Actuator as VerbActuator;

            if (verbActuator != null)
            {
                // If a damage actuator exists, then do not apply damage and instead let the damage actuator change hit points.
                if (verbActuator.Verb == GameThing.Verbs.Damage)
                {
                    param.hitStrength   = 1;
                    param.defaultDamage = 0;
                }
                if (verbActuator.Verb == GameThing.Verbs.Heal)
                {
                    param.hitStrength   = -1;
                    param.defaultDamage = 0;
                }
            }
        }
Exemplo n.º 3
0
        private void RunActuators()
        {
            verbExecutions.SetAll(false);

            GameActor.Movement.UserControlled = IsUserControlled;

            // Do not update actuators during pre-game.
            if (InGame.inGame.PreGameActive)
            {
                return;
            }

            int initialTaskId = Brain.ActiveTaskId;

            for (int i = 0; i < reflexes.Count; ++i)
            {
                Reflex reflex = reflexes[i] as Reflex;
                if (reflex.Actuator != null && reflex.targetSet.AnyAction)
                {
                    if (reflex.Actuator is VerbActuator)
                    {
                        // Ugh, be backward compatible with the old arbitrated verb behavior.
                        VerbActuator verbAct = reflex.Actuator as VerbActuator;

                        // If the verb is exclusive AND we've already seen in then don't process it.
                        if (GameThing.VerbIsExclusive(verbAct.Verb) && verbExecutions.Get((int)verbAct.Verb))
                        {
                            continue;
                        }
                        else
                        {
                            // This is the first time we've seen the verb so flag it.
                            verbExecutions.Set((int)verbAct.Verb, true);
                        }
                    }

                    // If we have a mouse sensor AND a once modifier then
                    // we want to tag the mouse button with IgnoreUntilReleased.
                    // This makes once work correctly without blocking other
                    // reflexes from seeing the mouse.
                    if (reflex.Sensor is MouseSensor)
                    {
                        OnceModifier om = null;
                        for (int j = 0; j < reflex.Modifiers.Count; j++)
                        {
                            om = reflex.Modifiers[j] as OnceModifier;
                            if (om != null)
                            {
                                break;
                            }
                        }
                        if (om != null)
                        {
                            MouseFilter mf = null;
                            for (int j = 0; j < reflex.Filters.Count; j++)
                            {
                                mf = reflex.Filters[j] as MouseFilter;
                                if (mf != null)
                                {
                                    break;
                                }
                            }
                            if (mf != null)
                            {
                                // By setting IgnoreUntilReleased, this prevents another
                                // reflex from being triggered until the mouse is released.
                                switch (mf.type)
                                {
                                case MouseFilterType.LeftButton:
                                    MouseInput.Left.IgnoreUntilReleased = true;
                                    break;

                                case MouseFilterType.RightButton:
                                    MouseInput.Right.IgnoreUntilReleased = true;
                                    break;

                                default:
                                    // Nothing to see here, move along.
                                    break;
                                }
                            }
                        }
                    }

                    reflex.Actuator.Update(reflex);

                    // Stop updating actuators if we switched pages.
                    if (Brain.ActiveTaskId != initialTaskId)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
 protected void CopyTo(VerbActuator clone)
 {
     base.CopyTo(clone);
     clone.Verb = this.Verb;
 }