コード例 #1
0
        private void pushSimToPeeBeforeShow(Sim sim)
        {
            try
            {
                IToilet toilet = findNearestToilet(sim);
                if (toilet != null && !toilet.InUse)
                {
                    List <InteractionObjectPair> interactions  = toilet.GetAllInteractionsForActor(sim);
                    InteractionDefinition        peeDefinition = null;
                    foreach (InteractionObjectPair interaction in interactions)
                    {
                        InteractionDefinition interactionDef = interaction.InteractionDefinition;
                        string name = interactionDef.GetType().ToString();


                        if (name != null && name.Contains("UseToilet"))
                        {
                            peeDefinition = interactionDef;
                            break;
                        }
                    }

                    if (peeDefinition != null)
                    {
                        InteractionInstance instance = peeDefinition.CreateInstance(toilet, sim,
                                                                                    new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), false, false);
                        sim.InteractionQueue.AddAfterCheckingForDuplicates(instance);
                    }
                }
            }
            catch (Exception ex)
            {
                Message.Sender.ShowError(this, "Sim cannot pee before show", false, ex);
            }
        }
コード例 #2
0
ファイル: UnityTests.cs プロジェクト: dragnilar/PatternTests
        public void RunRegisteredInstancesWithContainerTest()
        {
            Console.WriteLine("Creating new unity container...");
            IUnityContainer container = new UnityContainer();

            Console.WriteLine("Registering fun stuff...");
            FunContainers.RegisterFunStuffForRegisterTest(container);

            Console.WriteLine("Resolving fun stuff...");
            IClown clown = container.Resolve <IClown>();

            clown.ClownName = "Bubbles";

            Console.WriteLine($"Clowns name is: {clown.ClownName}");

            IElephant elephant = container.Resolve <IElephant>();

            elephant.ElephantName = "Barbar";

            Console.WriteLine($"The elephants name is: {elephant.ElephantName}");

            IToilet toilet = container.Resolve <Toilet>();

            Console.WriteLine($"The toilet is hiding here: {toilet.ToiletLocation}");

            ICircus circus = container.Resolve <ICircus>(new ParameterOverride("clown", clown),
                                                         new ParameterOverride("elephant", elephant),
                                                         new ParameterOverride("location", "Some Place Imaginary"));

            Console.WriteLine("Executing circus methods...");
            Console.WriteLine(circus.GetLocation());
            circus.MakeElephantDoSomethingWithClown();
        }