Example #1
0
            public override Sim GetTarget(Sim actor, TTarget target, InteractionInstance interaction)
            {
                if (mTarget != null)
                {
                    return(mTarget);
                }

                if (interaction == null)
                {
                    return(null);
                }

                Sim selected = interaction.GetSelectedObject() as Sim;

                if (selected != null)
                {
                    return(selected);
                }

                List <Sim> potentials = GetPotentials(actor, target, interaction.Autonomous, null);

                if ((potentials == null) || (potentials.Count == 0))
                {
                    try
                    {
                        throw new Exception();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(actor, target, "No Potentials", e);
                    }
                    return(null);
                }

                interaction.mSelectedObjects = new List <object>();
                interaction.mSelectedObjects.Add(RandomUtil.GetRandomObjectFromList(potentials));

                return(interaction.GetSelectedObject() as Sim);
            }