Weapos Rejiggered

Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged
Added machine gun weapon & VFX
Moved third party code to Plugins folder to improve compile times
This commit is contained in:
Reinier Vens 2021-01-31 03:52:32 +00:00
commit dbc522a224
2105 changed files with 7033 additions and 1141 deletions

View file

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
public class CodeGenerator : UnityEditor.Editor
{
private static readonly string GENERATED_CODE_TARGET_FOLDER =
(Application.dataPath.Replace("Assets", string.Empty) + AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("CodeGenerator")[0]))
.Replace("CodeGenerator.cs", string.Empty)
.Replace("/", "\\");
private static readonly string CLASS_NAME_PLACEHOLDER = "__classname__";
private static readonly string ENTRIES_PLACEHOLDER = "__entries__";
private static readonly string META_ENTRY_FORMAT = "metasByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
private static readonly string DRAWER_ENTRY_FORMAT = "drawersByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
private static readonly string GROUPER_ENTRY_FORMAT = "groupersByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
private static readonly string VALIDATOR_ENTRY_FORMAT = "validatorsByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
private static readonly string DRAW_CONDITION_ENTRY_FORMAT = "drawConditionsByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
//[UnityEditor.Callbacks.DidReloadScripts]
[MenuItem("NaughtyAttributes/Update Attributes Database")]
private static void GenerateCode()
{
GenerateScript<PropertyMeta, PropertyMetaAttribute>("PropertyMetaDatabase", "PropertyMetaDatabaseTemplate", META_ENTRY_FORMAT);
GenerateScript<PropertyDrawer, PropertyDrawerAttribute>("PropertyDrawerDatabase", "PropertyDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
GenerateScript<PropertyGrouper, PropertyGrouperAttribute>("PropertyGrouperDatabase", "PropertyGrouperDatabaseTemplate", GROUPER_ENTRY_FORMAT);
GenerateScript<PropertyValidator, PropertyValidatorAttribute>("PropertyValidatorDatabase", "PropertyValidatorDatabaseTemplate", VALIDATOR_ENTRY_FORMAT);
GenerateScript<PropertyDrawCondition, PropertyDrawConditionAttribute>("PropertyDrawConditionDatabase", "PropertyDrawConditionDatabaseTemplate", DRAW_CONDITION_ENTRY_FORMAT);
GenerateScript<FieldDrawer, FieldDrawerAttribute>("FieldDrawerDatabase", "FieldDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
GenerateScript<MethodDrawer, MethodDrawerAttribute>("MethodDrawerDatabase", "MethodDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
GenerateScript<NativePropertyDrawer, NativePropertyDrawerAttribute>("NativePropertyDrawerDatabase", "NativePropertyDrawerDbTemplate", DRAWER_ENTRY_FORMAT);
AssetDatabase.Refresh();
}
private static void GenerateScript<TClass, TAttribute>(string scriptName, string templateName, string entryFormat)
where TAttribute : IAttribute
{
string[] templateAssets = AssetDatabase.FindAssets(templateName);
if (templateAssets.Length == 0)
{
return;
}
string templateGUID = templateAssets[0];
string templateRelativePath = AssetDatabase.GUIDToAssetPath(templateGUID);
string templateFormat = (AssetDatabase.LoadAssetAtPath(templateRelativePath, typeof(TextAsset)) as TextAsset).ToString();
//string templateFullPath = (Application.dataPath.Replace("Assets", string.Empty) + templateRelativePath).Replace("/", "\\");
//string templateFormat = IOUtility.ReadFromFile(templateFullPath);
StringBuilder entriesBuilder = new StringBuilder();
List<Type> subTypes = GetAllSubTypes(typeof(TClass));
foreach (var subType in subTypes)
{
IAttribute[] attributes = (IAttribute[])subType.GetCustomAttributes(typeof(TAttribute), true);
if (attributes.Length > 0)
{
entriesBuilder.AppendFormat(entryFormat, attributes[0].TargetAttributeType.Name, subType.Name);
}
}
string scriptContent = templateFormat
.Replace(CLASS_NAME_PLACEHOLDER, scriptName)
.Replace(ENTRIES_PLACEHOLDER, entriesBuilder.ToString());
scriptContent = Regex.Replace(scriptContent, @"\r\n|\n\r|\r|\n", Environment.NewLine); // Normalize line endings
string scriptPath = GENERATED_CODE_TARGET_FOLDER + scriptName + ".cs";
IOUtility.WriteToFile(scriptPath, scriptContent);
}
private static List<Type> GetAllSubTypes(Type baseClass)
{
var result = new List<Type>();
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assemly in assemblies)
{
Type[] types = assemly.GetTypes();
foreach (var type in types)
{
if (type.IsSubclassOf(baseClass))
{
result.Add(type);
}
}
}
return result;
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 990da0e1629b14049842bf2ac82cbff0
timeCreated: 1508230160
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class FieldDrawerDatabase
{
private static Dictionary<Type, FieldDrawer> drawersByAttributeType;
static FieldDrawerDatabase()
{
drawersByAttributeType = new Dictionary<Type, FieldDrawer>();
drawersByAttributeType[typeof(ShowNonSerializedFieldAttribute)] = new ShowNonSerializedFieldFieldDrawer();
}
public static FieldDrawer GetDrawerForAttribute(Type attributeType)
{
FieldDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: b2406e32d0ab1214ab4959f1cdc8a609
timeCreated: 1508836346
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class MethodDrawerDatabase
{
private static Dictionary<Type, MethodDrawer> drawersByAttributeType;
static MethodDrawerDatabase()
{
drawersByAttributeType = new Dictionary<Type, MethodDrawer>();
drawersByAttributeType[typeof(ButtonAttribute)] = new ButtonMethodDrawer();
}
public static MethodDrawer GetDrawerForAttribute(Type attributeType)
{
MethodDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 40b81aa63ff76d34ea67277db99a6a25
timeCreated: 1508592498
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class NativePropertyDrawerDatabase
{
private static Dictionary<Type, NativePropertyDrawer> drawersByAttributeType;
static NativePropertyDrawerDatabase()
{
drawersByAttributeType = new Dictionary<Type, NativePropertyDrawer>();
drawersByAttributeType[typeof(ShowNativePropertyAttribute)] = new ShowNativePropertyNativePropertyDrawer();
}
public static NativePropertyDrawer GetDrawerForAttribute(Type attributeType)
{
NativePropertyDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 9fd2f82e21266a94ea967208610dda1e
timeCreated: 1510925645
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class PropertyDrawConditionDatabase
{
private static Dictionary<Type, PropertyDrawCondition> drawConditionsByAttributeType;
static PropertyDrawConditionDatabase()
{
drawConditionsByAttributeType = new Dictionary<Type, PropertyDrawCondition>();
drawConditionsByAttributeType[typeof(HideIfAttribute)] = new HideIfPropertyDrawCondition();
drawConditionsByAttributeType[typeof(ShowIfAttribute)] = new ShowIfPropertyDrawCondition();
}
public static PropertyDrawCondition GetDrawConditionForAttribute(Type attributeType)
{
PropertyDrawCondition drawCondition;
if (drawConditionsByAttributeType.TryGetValue(attributeType, out drawCondition))
{
return drawCondition;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 0b96dc9fe878bfc49865d28d601a7468
timeCreated: 1508414568
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,47 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class PropertyDrawerDatabase
{
private static Dictionary<Type, PropertyDrawer> drawersByAttributeType;
static PropertyDrawerDatabase()
{
drawersByAttributeType = new Dictionary<Type, PropertyDrawer>();
drawersByAttributeType[typeof(DropdownAttribute)] = new DropdownPropertyDrawer();
drawersByAttributeType[typeof(MinMaxSliderAttribute)] = new MinMaxSliderPropertyDrawer();
drawersByAttributeType[typeof(ReadOnlyAttribute)] = new ReadOnlyPropertyDrawer();
drawersByAttributeType[typeof(ReorderableListAttribute)] = new ReorderableListPropertyDrawer();
drawersByAttributeType[typeof(ResizableTextAreaAttribute)] = new ResizableTextAreaPropertyDrawer();
drawersByAttributeType[typeof(ShowAssetPreviewAttribute)] = new ShowAssetPreviewPropertyDrawer();
drawersByAttributeType[typeof(SliderAttribute)] = new SliderPropertyDrawer();
}
public static PropertyDrawer GetDrawerForAttribute(Type attributeType)
{
PropertyDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
public static void ClearCache()
{
foreach (var kvp in drawersByAttributeType)
{
kvp.Value.ClearCache();
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 57bb89ab38f8da84db719a3fad7934d2
timeCreated: 1508241644
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class PropertyGrouperDatabase
{
private static Dictionary<Type, PropertyGrouper> groupersByAttributeType;
static PropertyGrouperDatabase()
{
groupersByAttributeType = new Dictionary<Type, PropertyGrouper>();
groupersByAttributeType[typeof(BoxGroupAttribute)] = new BoxGroupPropertyGrouper();
}
public static PropertyGrouper GetGrouperForAttribute(Type attributeType)
{
PropertyGrouper grouper;
if (groupersByAttributeType.TryGetValue(attributeType, out grouper))
{
return grouper;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 0e5fed99fdc5f794291677a80073b4ba
timeCreated: 1508333008
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class PropertyMetaDatabase
{
private static Dictionary<Type, PropertyMeta> metasByAttributeType;
static PropertyMetaDatabase()
{
metasByAttributeType = new Dictionary<Type, PropertyMeta>();
metasByAttributeType[typeof(BlankSpaceAttribute)] = new BlankSpacePropertyMeta();
metasByAttributeType[typeof(InfoBoxAttribute)] = new InfoBoxPropertyMeta();
metasByAttributeType[typeof(OnValueChangedAttribute)] = new OnValueChangedPropertyMeta();
metasByAttributeType[typeof(SectionAttribute)] = new SectionPropertyMeta();
}
public static PropertyMeta GetMetaForAttribute(Type attributeType)
{
PropertyMeta meta;
if (metasByAttributeType.TryGetValue(attributeType, out meta))
{
return meta;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 57233c5ec1975024aa0723241b2f8210
timeCreated: 1508497398
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class PropertyValidatorDatabase
{
private static Dictionary<Type, PropertyValidator> validatorsByAttributeType;
static PropertyValidatorDatabase()
{
validatorsByAttributeType = new Dictionary<Type, PropertyValidator>();
validatorsByAttributeType[typeof(MaxValueAttribute)] = new MaxValuePropertyValidator();
validatorsByAttributeType[typeof(MinValueAttribute)] = new MinValuePropertyValidator();
validatorsByAttributeType[typeof(RequiredAttribute)] = new RequiredPropertyValidator();
validatorsByAttributeType[typeof(ValidateInputAttribute)] = new ValidateInputPropertyValidator();
}
public static PropertyValidator GetValidatorForAttribute(Type attributeType)
{
PropertyValidator validator;
if (validatorsByAttributeType.TryGetValue(attributeType, out validator))
{
return validator;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 24e9da8a6b324374a9f655d3a867b284
timeCreated: 1508241122
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7b15ea6695a69d74ab656006617d8d21
folderAsset: yes
timeCreated: 1508230862
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, FieldDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, FieldDrawer>();
__entries__
}
public static FieldDrawer GetDrawerForAttribute(Type attributeType)
{
FieldDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 943b4c41373856243996247275be2cd8
timeCreated: 1508836344
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, MethodDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, MethodDrawer>();
__entries__
}
public static MethodDrawer GetDrawerForAttribute(Type attributeType)
{
MethodDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 52d15465eb3439f4a9b95963a21d19b7
timeCreated: 1508592495
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, NativePropertyDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, NativePropertyDrawer>();
__entries__
}
public static NativePropertyDrawer GetDrawerForAttribute(Type attributeType)
{
NativePropertyDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b82f5f6bf1fd4314c93624a8bc8835fd
timeCreated: 1510924467
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyDrawCondition> drawConditionsByAttributeType;
static __classname__()
{
drawConditionsByAttributeType = new Dictionary<Type, PropertyDrawCondition>();
__entries__
}
public static PropertyDrawCondition GetDrawConditionForAttribute(Type attributeType)
{
PropertyDrawCondition drawCondition;
if (drawConditionsByAttributeType.TryGetValue(attributeType, out drawCondition))
{
return drawCondition;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b36f5858330c2d140a697f19ba6cc36b
timeCreated: 1508414568
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,39 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, PropertyDrawer>();
__entries__
}
public static PropertyDrawer GetDrawerForAttribute(Type attributeType)
{
PropertyDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
public static void ClearCache()
{
foreach (var kvp in drawersByAttributeType)
{
kvp.Value.ClearCache();
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 136a96a904b577244b08be5d5542a77d
timeCreated: 1508241102
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyGrouper> groupersByAttributeType;
static __classname__()
{
groupersByAttributeType = new Dictionary<Type, PropertyGrouper>();
__entries__
}
public static PropertyGrouper GetGrouperForAttribute(Type attributeType)
{
PropertyGrouper grouper;
if (groupersByAttributeType.TryGetValue(attributeType, out grouper))
{
return grouper;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fcc5bff99ecd4843b766f23cd585b55
timeCreated: 1508332899
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyMeta> metasByAttributeType;
static __classname__()
{
metasByAttributeType = new Dictionary<Type, PropertyMeta>();
__entries__
}
public static PropertyMeta GetMetaForAttribute(Type attributeType)
{
PropertyMeta meta;
if (metasByAttributeType.TryGetValue(attributeType, out meta))
{
return meta;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fde25cf95f45b50469fcf4ee1e38993c
timeCreated: 1508497401
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyValidator> validatorsByAttributeType;
static __classname__()
{
validatorsByAttributeType = new Dictionary<Type, PropertyValidator>();
__entries__
}
public static PropertyValidator GetValidatorForAttribute(Type attributeType)
{
PropertyValidator validator;
if (validatorsByAttributeType.TryGetValue(attributeType, out validator))
{
return validator;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a21c3d37c1492da4386198388150024c
timeCreated: 1508230862
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: