void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable) { if (!initialized || oven == null || fuel == null) { return; } ConsumeTypes type = StringToType(oven?.ShortPrefabName ?? string.Empty); if (type == ConsumeTypes.None) { return; } if (IsActiveType(type)) { if (usingPermissions && oven.OwnerID != 0U) { if (!HasPermission(oven.OwnerID.ToString(), type)) { return; } } fuel.amount += 1; } }
void CheckType(BaseOven oven) { if (oven == null) { return; } ConsumeTypes type = StringToType(oven?.ShortPrefabName ?? string.Empty); if (type == ConsumeTypes.None) { return; } if (configData.LightTypes[type]) { lights.Add(oven); } }
void OnItemUse(Item item, int amount) { if (!initialized || item == null || amount == 0 || !ValidFuelTypes.Contains(item.info.shortname)) { return; } string shortname = item?.parent?.parent?.info?.shortname ?? item?.GetRootContainer()?.entityOwner?.ShortPrefabName; if (string.IsNullOrEmpty(shortname)) { return; } ConsumeTypes type = StringToType(shortname); if (type == ConsumeTypes.None) { return; } if (IsActiveType(type)) { if (usingPermissions) { string playerId = item?.GetRootContainer()?.playerOwner?.UserIDString; string entityId = item?.GetRootContainer()?.entityOwner?.OwnerID.ToString(); if (!string.IsNullOrEmpty(playerId)) { if (!HasPermission(playerId, type)) { return; } } if (!string.IsNullOrEmpty(entityId) && entityId != "0") { if (!HasPermission(entityId, type)) { return; } } } item.amount += amount; } }
void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable) { if (!isActivated || nfrInstalled || configData.ConsumeFuel || oven == null || fuel == null || !lights.Contains(oven)) { return; } ConsumeTypes type = StringToType(oven?.ShortPrefabName ?? string.Empty); if (type == ConsumeTypes.None) { return; } if (configData.LightTypes[type]) { fuel.amount++; } }
void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable) { ConsumeTypes type = StringToType(oven?.ShortPrefabName); if (type == ConsumeTypes.None) { return; } if (IsActiveType(type)) { if (usingPermissions && oven.OwnerID != 0U) { if (!HasPermission(oven.OwnerID.ToString(), type)) { return; } } ++fuel.amount; } }
public static void ChapterTwo() { #region [ Create types ] CreateTypes createTypes = new CreateTypes(); //createTypes.StructAndClasses(); //createTypes.Aliens(); //createTypes.MyStackGeneric(); //createTypes.ThisConstructor(); //createTypes.DestoryAlien(); //createTypes.SummaryOfCh1to2_1(); #endregion #region [ Consume types ] ConsumeTypes consumeTypes = new ConsumeTypes(); //consumeTypes.BoxingAndUnboxing(); //consumeTypes.ImplicitExplicitOperator(); //consumeTypes.UsingDynamic(); #endregion #region [ Class hierarchies ] ClassHierarchy ch = new ClassHierarchy(); //ch.DepositInMyBank(20); //ch.ComparePricesInMyBank(); #endregion #region [ Reflection ] #region [ Attributes, Methods Invoke, Load Assemblies] RuntimeReflection reflection = new RuntimeReflection(); //reflection.TestConditional(); //reflection.CheckAttribute(); //reflection.CheckCustomAttribute(); //reflection.IdentityMembersInClass(); //reflection.CallMethodUsingReflection(); //reflection.ScanAssembly(); #endregion #region [ Code DOM , Expression Trees and Reflection ] #region [ CodeDOM ] CodeDOMExample cde = new CodeDOMExample(); //cde.GenerateCodDOM(); #endregion #region [ Expression Trees ] ExpressionTrees et = new ExpressionTrees(); //et.ExpressionTreeMultiply(); //et.ExpressionTreeModifyToAdd(); //et.IsAdultFemale(); #endregion #region [ More Reflection ] Assemblies assemblies = new Assemblies(); //assemblies.DisplayAssemblyInfo(); //assemblies.GetPropertyInfo(); //assemblies.GetMethodInfo(); #endregion #endregion #endregion #region [ Manipulate strings ] ManipulateStrings manipulateStrings = new ManipulateStrings(); //manipulateStrings.StringInterning(); //manipulateStrings.StringWriter(); //manipulateStrings.StringReader(); //manipulateStrings.SearchStrings(); //manipulateStrings.StringComparisonAndCulture(); //manipulateStrings.FormatString(); //manipulateStrings.FormattableString(); //manipulateStrings.MusicTrackFormatter(); #endregion }
bool IsActiveType(ConsumeTypes type) => configData.AffectedTypes[type];
bool HasPermission(string ownerId, ConsumeTypes type) => permission.UserHasPermission(ownerId, configData.Permissions[type]);
public void MenuOpt1() { ConsumeTypes.Menu(); }