Refactor debris system

This commit is contained in:
Jens Pitkänen 2019-08-15 00:27:14 +03:00
parent c2f573f66c
commit 4a87c512c3
19 changed files with 577 additions and 39 deletions

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -45,7 +45,7 @@ TextureImporter:
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 2
spritePixelsToUnits: 32
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,115 @@
fileFormatVersion: 2
guid: 215eb4533a6ec2945aab7285ec81917e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 10
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 32
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0cd0b834e1996dc4eb175a1177fb31d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,267 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1716831649928673929
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1716831649928674037}
- component: {fileID: 1716831649928673928}
- component: {fileID: 1716831649928674038}
- component: {fileID: 1716831649928674039}
m_Layer: 0
m_Name: Destructible (Table)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1716831649928674037
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831649928673929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.46, y: 3.62, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1716831651141931473}
- {fileID: 1716831651171314107}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1716831649928673928
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831649928673929}
m_BodyType: 2
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!61 &1716831649928674038
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831649928673929}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0.1}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 2, y: 0.7}
m_EdgeRadius: 0
--- !u!114 &1716831649928674039
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831649928673929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2110188365a59e4cb31d0e84789fbbd, type: 3}
m_Name:
m_EditorClassIdentifier:
BodypartPrefabs:
- {fileID: 3847767376140256459, guid: 52797bed93d9def4fb0802efcbe9da0b, type: 3}
- {fileID: 3847767376140256459, guid: b3bfb4ae89e38244dad2c4396ec48ba3, type: 3}
- {fileID: 3847767376140256459, guid: 16e2e783575dcf147bd67039283f1c17, type: 3}
- {fileID: 3847767376140256459, guid: 7194f42d640f6cc4b8ff71eff6a9b85b, type: 3}
DebugExplode: 0
ParticlesPerBodypart: 40
BodypartCountMultiplier: 4
DebrisType: 2
--- !u!1 &1716831651141931474
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1716831651141931473}
- component: {fileID: 1716831651141931472}
m_Layer: 0
m_Name: OfficeSupplies_0
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1716831651141931473
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831651141931474}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1716831649928674037}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1716831651141931472
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831651141931474}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 106348079
m_SortingLayer: 3
m_SortingOrder: 0
m_Sprite: {fileID: -7697855389034428149, guid: 214b62ded47c3424c8ca6f7ac2681d8a,
type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1716831651171314108
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1716831651171314107}
- component: {fileID: 1716831651171314106}
m_Layer: 0
m_Name: OfficeSupplies_2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1716831651171314107
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831651171314108}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1716831649928674037}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1716831651171314106
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1716831651171314108}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 106348079
m_SortingLayer: 3
m_SortingOrder: 0
m_Sprite: {fileID: 2109281845590731511, guid: 214b62ded47c3424c8ca6f7ac2681d8a,
type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b58ccc83664f46d41b7771ad86253364
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -26,7 +26,7 @@ Transform:
m_GameObject: {fileID: 6669388256411233052}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 16, y: 15, z: 1}
m_Children: []
m_Father: {fileID: 6669388256411233039}
m_RootOrder: 0
@ -124,5 +124,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
Renderer: {fileID: 6669388256411233138}
LaunchForce: {x: 0, y: 0}
Settled: 0
GetsStuck: 1
Sprites: []

View File

@ -0,0 +1,131 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8205645559196366286
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8205645559196366287}
- component: {fileID: 8205645559196366284}
m_Layer: 10
m_Name: Wood
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8205645559196366287
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8205645559196366286}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 16, y: 16, z: 1}
m_Children: []
m_Father: {fileID: 8205645559456068291}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8205645559196366284
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8205645559196366286}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -1695068835
m_SortingLayer: 2
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 215eb4533a6ec2945aab7285ec81917e, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.1875, y: 0.1875}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8205645559456068290
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8205645559456068291}
- component: {fileID: 8205645559456068288}
m_Layer: 10
m_Name: WoodParticle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8205645559456068291
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8205645559456068290}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8205645559196366287}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8205645559456068288
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8205645559456068290}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
Renderer: {fileID: 8205645559196366284}
LaunchForce: {x: 0, y: 0}
Settled: 0
GetsStuck: 1
Sprites: []

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e0f0195950e91434491053557460a074
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -230,7 +230,8 @@ MonoBehaviour:
- {fileID: 90224928841595158, guid: 09e75a2e394f38f42bd5a1437c8be0d9, type: 3}
- {fileID: 90224928841595158, guid: 7639604b8e230d5458302c542e81934d, type: 3}
DebugExplode: 0
Type: 1
ParticlesPerBodypart: 70
DebrisType: 1
--- !u!1 &11699643844798482
GameObject:
m_ObjectHideFlags: 0

View File

@ -26,7 +26,7 @@ namespace Saltosion.OneWeapon.Effects {
Vector2 Offset = DripOffset + new Vector2(-ParentBody.velocity.y, ParentBody.velocity.x).normalized *
(WalkingSideWays ? 0.1f : 0.2f) *
(Step ? 1f : -1f);
BloodLauncher.Splatter(ParentBody.position + Offset, Vector2.zero, 1 + (int)(Random.value * 5), 0f, 360f, false);
DebrisLauncher.Splatter(DebrisType.Blood, ParentBody.position + Offset, Vector2.zero, 1 + (int)(Random.value * 5), 0f, 360f, false);
Drips++;
if (Drips >= DripCount) {
Destroy(gameObject);

View File

@ -4,30 +4,32 @@ using UnityEngine;
using Saltosion.OneWeapon.Utils;
namespace Saltosion.OneWeapon.Effects {
public class BloodLauncher : MonoBehaviour {
private static BloodLauncher Singleton;
public enum DebrisType {
Blood, Structural, Wood
}
public class DebrisLauncher : MonoBehaviour {
private static DebrisLauncher Singleton;
public GameObject StructuralParticlePrefab;
public GameObject WoodParticlePrefab;
public GameObject BloodParticlePrefab;
public GameObject CensoredBloodParticlePrefab;
public Transform ParticleRoot;
public int MaxParticles;
public bool DebugLaunch = false;
public static void Splatter(Vector2 origin, Vector2 direction, int particleCount, float force, float degrees, bool sticky = true) {
LaunchParticles(Singleton.GetGorePrefab(), origin, direction, particleCount, force, degrees, sticky);
}
public static void DebrisExplode(Vector2 origin, Vector2 direction, int particleCount, float force, float degrees, bool sticky = true) {
LaunchParticles(Singleton.StructuralParticlePrefab, origin, direction, particleCount, force, degrees, sticky);
public static void Splatter(DebrisType Type, Vector2 origin, Vector2 direction, int particleCount, float force, float degrees, bool sticky = true) {
int ParticleCount = (int)(particleCount * (Type == DebrisType.Blood ? Singleton.GetBloodParticleCountMultiplier() : 1));
LaunchParticles(Singleton.GetDebrisPrefab(Type), origin, direction, particleCount, force, degrees, sticky);
}
private static void LaunchParticles(GameObject prefab, Vector2 origin, Vector2 direction, int particleCount, float force, float degrees, bool sticky) {
for (int i = 0; i < (int)(particleCount * Singleton.GetParticleCountMultiplier()); i++) {
for (int i = 0; i < particleCount; i++) {
if (Singleton.ParticleRoot.childCount >= Singleton.MaxParticles) {
Destroy(Singleton.ParticleRoot.GetChild((int)(Random.value * Singleton.ParticleRoot.childCount)).gameObject);
}
GameObject Obj = Instantiate(prefab, origin, new Quaternion(), Singleton.ParticleRoot);
BloodParticle Particle = Obj.GetComponent<BloodParticle>();
DebrisParticle Particle = Obj.GetComponent<DebrisParticle>();
float Intensity = Mathf.Pow(Random.value, 0.8f) * force;
float Cone = degrees / 360.0f;
float Offset = Mathf.Atan2(direction.y, direction.x);
@ -41,11 +43,20 @@ namespace Saltosion.OneWeapon.Effects {
Singleton = this;
}
private GameObject GetGorePrefab() {
return Options.CensorGore ? CensoredBloodParticlePrefab : BloodParticlePrefab;
private GameObject GetDebrisPrefab(DebrisType Type) {
switch (Type) {
case DebrisType.Blood:
return Options.CensorGore ? CensoredBloodParticlePrefab : BloodParticlePrefab;
case DebrisType.Structural:
return StructuralParticlePrefab;
case DebrisType.Wood:
return WoodParticlePrefab;
default:
return CensoredBloodParticlePrefab;
}
}
private float GetParticleCountMultiplier() {
private float GetBloodParticleCountMultiplier() {
return Options.CensorGore ? 0.1f : 1.5f;
}
}

View File

@ -1,9 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
namespace Saltosion.OneWeapon.Effects {
public class BloodParticle : MonoBehaviour {
public class DebrisParticle : MonoBehaviour {
public SpriteRenderer Renderer;
public Vector2 LaunchForce = new Vector2();

View File

@ -3,15 +3,12 @@ using Saltosion.OneWeapon.Utils;
using Saltosion.OneWeapon.Player;
namespace Saltosion.OneWeapon.Effects {
public enum ExplodableType {
Blood, Debris
}
public class Explodable : MonoBehaviour {
public GameObject[] BodypartPrefabs;
public bool DebugExplode = false;
public int ParticlesPerBodypart = 70;
public ExplodableType Type;
public float BodypartCountMultiplier = 1;
public DebrisType DebrisType;
private CameraFX CameraFX;
private PlayerFun PlayerFun;
@ -38,13 +35,13 @@ namespace Saltosion.OneWeapon.Effects {
}
public void Explode(bool destroyGameObject) {
int Count = Mathf.Clamp((int)(BodypartPrefabs.Length * Random.value + 1), 1, BodypartPrefabs.Length);
int Count = (int)(BodypartPrefabs.Length * Random.value * BodypartCountMultiplier + 1);
for (int i = 0; i < Count; i++) {
GameObject Obj = BodypartPrefabs[i];
GameObject Obj = BodypartPrefabs[i % BodypartPrefabs.Length];
float DirectionRadians = Random.value * Mathf.PI * 2.0f;
Vector2 Direction = new Vector2(Mathf.Cos(DirectionRadians), Mathf.Sin(DirectionRadians));
if (!Options.CensorGore || Type != ExplodableType.Blood) {
if (!Options.CensorGore || DebrisType != DebrisType.Blood) {
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), null);
Rigidbody2D Bodypart = NewObj.GetComponent<Rigidbody2D>();
if (Bodypart == null) {
@ -55,14 +52,7 @@ namespace Saltosion.OneWeapon.Effects {
Bodypart.AddTorque((Random.value - 0.5f) * Force, ForceMode2D.Impulse);
}
switch (Type) {
case ExplodableType.Blood:
BloodLauncher.Splatter(transform.position + (Vector3)Direction * 0.5f, Vector2.zero, ParticlesPerBodypart, 50f, 360f);
break;
case ExplodableType.Debris:
BloodLauncher.DebrisExplode(transform.position + (Vector3)Direction * 0.5f, Vector2.zero, ParticlesPerBodypart, 60f, 360f);
break;
}
DebrisLauncher.Splatter(DebrisType, transform.position + (Vector3)Direction * 0.5f, Vector2.zero, ParticlesPerBodypart, 50f, 360f);
}
PlayerFun.Explosion(false);

View File

@ -19,7 +19,7 @@ namespace Saltosion.OneWeapon.Enemies {
}
public void Damage(float amount, Vector2 fromDirection, bool applyPlayerDamageBoost) {
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
DebrisLauncher.Splatter(DebrisType.Blood, transform.position, -fromDirection, (int)(amount), 100f, 100);
CurrentHealth -= amount * (1 + (applyPlayerDamageBoost ? PlayerFun.CurrentDamageBoost : 0.0f));
if (CurrentHealth <= 0) {
Explodable.Explode(true);

View File

@ -23,7 +23,7 @@ namespace Saltosion.OneWeapon.Guns {
} else if (Explodable != null) {
Explodable.Explode(true);
} else if (Collider.tag == "Environment") {
BloodLauncher.DebrisExplode(transform.position, Direction, (int)(5 * Intensity), 30 * Intensity, 360);
DebrisLauncher.Splatter(DebrisType.Structural, transform.position, Direction, (int)(5 * Intensity), 30 * Intensity, 360);
}
if (Collider.attachedRigidbody != null && Collider.attachedRigidbody.bodyType == RigidbodyType2D.Dynamic) {
Collider.attachedRigidbody.AddForce(Direction * 4 * Intensity, ForceMode2D.Impulse);