Add gore censoring option

This commit is contained in:
Jens Pitkänen 2019-08-04 02:45:32 +03:00
parent 2daf97a490
commit 2546b1575b
10 changed files with 293 additions and 11 deletions

BIN
Assets/Graphics/Flower.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

View File

@ -0,0 +1,115 @@
fileFormatVersion: 2
guid: 1a2ef685debc2114187302af36eac8fb
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: 16
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,128 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1882677610630750272
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1882677610630750273}
- component: {fileID: 1882677610630750274}
m_Layer: 0
m_Name: Flower
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1882677610630750273
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882677610630750272}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2, y: 2, z: 2}
m_Children: []
m_Father: {fileID: 1882677610906969933}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1882677610630750274
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882677610630750272}
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: 1a2ef685debc2114187302af36eac8fb, 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.0625, y: 0.0625}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1882677610906969932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1882677610906969933}
- component: {fileID: 1882677610906969934}
m_Layer: 0
m_Name: BloodParticle (Censored)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1882677610906969933
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882677610906969932}
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: 1882677610630750273}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1882677610906969934
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882677610906969932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3}
m_Name:
m_EditorClassIdentifier:
LaunchForce: {x: 0, y: 0}
Settled: 0

View File

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

View File

@ -322,9 +322,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
BloodParticlePrefab: {fileID: 5625006176899801348, guid: 3eace925ee10ebb4da4f6d8f8ce22f5a,
type: 3}
CensoredBloodParticlePrefab: {fileID: 1882677610906969932, guid: 079fe6df2fbccbe4198535d6e8793dca,
type: 3}
ParticleRoot: {fileID: 188743843}
MaxParticles: 10000
DebugLaunch: 0
CensorGore: 1
--- !u!4 &188743843
Transform:
m_ObjectHideFlags: 0

View File

@ -6,16 +6,17 @@ namespace Saltosion.OneWeapon {
public class BloodLauncher : MonoBehaviour {
private static BloodLauncher Singleton;
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) {
for (int i = 0; i < particleCount; i++) {
for (int i = 0; i < (int)(particleCount * Singleton.GetParticleCountMultiplier()); i++) {
if (Singleton.ParticleRoot.childCount >= Singleton.MaxParticles) {
Destroy(Singleton.ParticleRoot.GetChild((int)(Random.value * Singleton.ParticleRoot.childCount)).gameObject);
}
GameObject Obj = Instantiate(Singleton.BloodParticlePrefab, origin, new Quaternion(), Singleton.ParticleRoot);
GameObject Obj = Instantiate(Singleton.GetGorePrefab(), origin, new Quaternion(), Singleton.ParticleRoot);
BloodParticle Particle = Obj.GetComponent<BloodParticle>();
float Intensity = Mathf.Pow(Random.value * force, 1.1f);
float Cone = degrees / 360.0f;
@ -28,5 +29,13 @@ namespace Saltosion.OneWeapon {
private void Start() {
Singleton = this;
}
private GameObject GetGorePrefab() {
return Options.CensorGore ? CensoredBloodParticlePrefab : BloodParticlePrefab;
}
private float GetParticleCountMultiplier() {
return Options.CensorGore ? 0.1f : 1f;
}
}
}

View File

@ -35,7 +35,7 @@ namespace Saltosion.OneWeapon {
Vector2 AppliedMovement = Velocity * Time.fixedDeltaTime;
RaycastHit2D Hit = Physics2D.Raycast(transform.position, AppliedMovement, AppliedMovement.magnitude);
if (Hit.collider != null) {
if (Hit.rigidbody != null) {
bool IsStatic = Hit.rigidbody.bodyType == RigidbodyType2D.Static;
Velocity = Velocity.normalized * Mathf.Min(IsStatic ? 15.0f : 60.0f, Velocity.magnitude);
CurrentlyStuckOn = Hit.rigidbody;

View File

@ -27,16 +27,20 @@ namespace Saltosion.OneWeapon {
public void Explode() {
foreach (GameObject Obj in BodypartPrefabs) {
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), null);
Rigidbody2D Bodypart = NewObj.GetComponent<Rigidbody2D>();
if (Bodypart == null) {
continue;
// No body parts flying in censored mode
if (!Options.CensorGore) {
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), null);
Rigidbody2D Bodypart = NewObj.GetComponent<Rigidbody2D>();
if (Bodypart == null) {
continue;
}
float Force = 0.5f + Random.value * 0.5f;
float DirectionRadians = Random.value * Mathf.PI * 2.0f;
Bodypart.AddForce(new Vector2(Mathf.Cos(DirectionRadians), Mathf.Sin(DirectionRadians)) * Force, ForceMode2D.Impulse);
Bodypart.AddTorque((Random.value - 0.5f) * Force, ForceMode2D.Impulse);
}
float Force = 0.5f + Random.value * 0.5f;
float DirectionRadians = Random.value * Mathf.PI * 2.0f;
Bodypart.AddForce(new Vector2(Mathf.Cos(DirectionRadians), Mathf.Sin(DirectionRadians)) * Force, ForceMode2D.Impulse);
Bodypart.AddTorque((Random.value - 0.5f) * Force, ForceMode2D.Impulse);
// Blood is replaced by flowers though, no problem with that
BloodLauncher.Splatter(transform.position, Vector2.zero, 70, 50f, 360f);
}
}

View File

@ -0,0 +1,5 @@
namespace Saltosion.OneWeapon {
public class Options {
public static bool CensorGore = false;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 195c2baa617dca5439a992cae285f76a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: