private static void OpenLoadoutWindow(Pawn pawn, CompAwesomeInventoryLoadout comp, ThingGroupSelector groupSelector)
        {
            Find.WindowStack.Add(AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(new object[] { comp.Loadout, pawn, false }));
            ThingDef allowedThing = groupSelector.AllowedThing;

            if (allowedThing.MadeFromStuff || allowedThing.HasComp(typeof(CompQuality)) || allowedThing.useHitPoints)
            {
                Find.WindowStack.Add(new Dialog_StuffAndQuality(groupSelector));
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterTypeAttribute"/> class.
        /// </summary>
        /// <param name="base"> Base type. </param>
        /// <param name="derived"> Derived type, usually is the type this attribute is adorned on. </param>
        public RegisterTypeAttribute(Type @base, Type derived)
        {
            ValidateArg.NotNull(@base, nameof(@base));

            if ([email protected](derived))
            {
                AIDebug.Logger.WriteError($"{derived} is not a derived type of {@base}.");
            }

            AwesomeInventoryServiceProvider.AddType(@base, derived);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterServiceAttribute"/> class.
        /// </summary>
        /// <param name="base"> Type of service. </param>
        /// <param name="service"> Instance of service. </param>
        public RegisterServiceAttribute(Type @base, Type service)
        {
            ValidateArg.NotNull(@base, nameof(@base));
            ValidateArg.NotNull(service, nameof(service));

            if ([email protected](service))
            {
                AIDebug.Logger.WriteError($"Service {service} is not of type {@base}.");
            }

            if (AwesomeInventoryServiceProvider.TryGetService(@base, out object value) && !service.IsSubclassOf(value.GetType()))
            {
                return;
            }

            AwesomeInventoryServiceProvider.AddService(@base, Activator.CreateInstance(service));
        }
Example #4
0
        /// <summary>
        /// Make float menu options for creating empty loadout or loadout derived from equipped items.
        /// </summary>
        /// <param name="selPawn"> Selected pawn. </param>
        /// <returns> A list of options. </returns>
        public static List <FloatMenuOption> MakeActionableLoadoutOption(this Pawn selPawn)
        {
            ValidateArg.NotNull(selPawn, nameof(selPawn));

            return(new List <FloatMenuOption>()
            {
                new FloatMenuOption(
                    UIText.MakeEmptyLoadout.Translate(selPawn.NameShortColored)
                    , () =>
                {
                    AwesomeInventoryLoadout emptyLoadout = AwesomeInventoryLoadout.MakeEmptyLoadout(selPawn);
                    LoadoutManager.AddLoadout(emptyLoadout);
                    selPawn.SetLoadout(emptyLoadout);
                    Find.WindowStack.Add(
                        AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(emptyLoadout, selPawn, true));

                    if (BetterPawnControlUtility.IsActive)
                    {
                        BetterPawnControlUtility.SaveState(new List <Pawn> {
                            selPawn
                        });
                    }
                }),
                new FloatMenuOption(
                    UIText.MakeNewLoadout.Translate(selPawn.NameShortColored)
                    , () =>
                {
                    AwesomeInventoryLoadout loadout = new AwesomeInventoryLoadout(selPawn);
                    LoadoutManager.AddLoadout(loadout);
                    selPawn.SetLoadout(loadout);
                    Find.WindowStack.Add(
                        AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(loadout, selPawn, true));

                    if (BetterPawnControlUtility.IsActive)
                    {
                        BetterPawnControlUtility.SaveState(new List <Pawn> {
                            selPawn
                        });
                    }
                }),
            });
        }
Example #5
0
 static InGameLogger()
 {
     AwesomeInventoryServiceProvider.AddService(typeof(ILogger), new InGameLogger());
 }
Example #6
0
 /// <summary>
 /// Register derived type of <see cref="ThingGroupSelector"/>.
 /// </summary>
 /// <typeparam name="T"> Derived Type of <see cref="ThingGroupSelector"/>. </typeparam>
 protected static void RegisterThingGroupSelector <T>()
     where T : ThingGroupSelector
 => AwesomeInventoryServiceProvider.AddType(typeof(ThingGroupSelector), typeof(T));
Example #7
0
 /// <summary>
 /// Register derived type of <see cref="GenericThingSelector"/>.
 /// </summary>
 /// <typeparam name="T"> Derived Type of <see cref="GenericThingSelector"/>. </typeparam>
 protected static void RegisterGenericThingSelector <T>()
     where T : GenericThingSelector
 => AwesomeInventoryServiceProvider.AddType(typeof(GenericThingSelector), typeof(T));
Example #8
0
 /// <summary>
 /// Register <see cref="AwesomeInventoryTabBase"/>.
 /// </summary>
 /// <param name="awesomeInventoryTabBase"> Implementation of <paramref name="awesomeInventoryTabBase"/>. </param>
 protected static void RegisterAwesomeInventoryTabBase(AwesomeInventoryTabBase awesomeInventoryTabBase)
 {
     AwesomeInventoryServiceProvider.AddService(typeof(AwesomeInventoryTabBase), awesomeInventoryTabBase);
 }
Example #9
0
 /// <summary>
 /// Register <see cref="IDrawHelper"/>.
 /// </summary>
 /// <param name="drawHelper"> Instance of <paramref name="drawHelper"/> to register. </param>
 protected static void RegisterIDrawHelper(IDrawHelper drawHelper)
 {
     AwesomeInventoryServiceProvider.AddService(typeof(IDrawHelper), drawHelper);
 }
Example #10
0
 /// <summary>
 /// Register <see cref="IInventoryHelper"/>.
 /// </summary>
 /// <param name="inventoryHelper"> Instance of <paramref name="inventoryHelper"/> to register. </param>
 protected static void RegisterIInventoryHelper(IInventoryHelper inventoryHelper)
 {
     AwesomeInventoryServiceProvider.AddService(typeof(IInventoryHelper), inventoryHelper);
 }
Example #11
0
 /// <summary>
 /// Register <paramref name="customRace"/> to Awesome Inventory's service provider.
 /// </summary>
 /// <param name="customRace"> Plugin to register. </param>
 protected static void Register(CustomRace customRace)
 {
     AwesomeInventoryServiceProvider.AddPlugIn(customRace);
 }
 /// <summary>
 /// Register derived type of <see cref="Dialog_ManageLoadouts"/>.
 /// </summary>
 /// <typeparam name="T"> Derived type of <see cref="Dialog_ManageLoadouts"/>. </typeparam>
 protected static void RegisterDialogManageLoadout <T>()
     where T : Dialog_ManageLoadouts
 => AwesomeInventoryServiceProvider.AddType(typeof(Dialog_ManageLoadouts), typeof(T));