Re-split Burnable and Item, make vr sticks burn

This commit is contained in:
Jens Pitkänen 2020-04-30 03:33:23 +03:00
parent d5d905a1f1
commit 726c670522
7 changed files with 59 additions and 11 deletions

View File

@ -140,6 +140,7 @@ GameObject:
- component: {fileID: -5925851218717166877}
- component: {fileID: 2081929903982442016}
- component: {fileID: 1226804790312226784}
- component: {fileID: 8044237247712289850}
m_Layer: 0
m_Name: BurningStick
m_TagString: Untagged
@ -226,9 +227,21 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f70b810850590804092bb2c772ea6012, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 62d0193d1d08b814d9328f3dd1d117cb, type: 2}
IgnitePoint: {fileID: 7948189956267693667}
Grabbed: 0
--- !u!114 &8044237247712289850
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086008818391599545}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b647d1ea5d6785a4d8e6f6b2208e5f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 62d0193d1d08b814d9328f3dd1d117cb, type: 2}
--- !u!1 &2819347287429737535
GameObject:
m_ObjectHideFlags: 0

View File

@ -56,6 +56,7 @@ GameObject:
- component: {fileID: 1830340994370403595}
- component: {fileID: 3556743581346332214}
- component: {fileID: 1732996613952540235}
- component: {fileID: 7014937997629475779}
m_Layer: 10
m_Name: stick
m_TagString: Untagged
@ -93,7 +94,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f70b810850590804092bb2c772ea6012, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 273b9cf97d0c80e449f24a33a2d261d1, type: 2}
IgnitePoint: {fileID: 8934967594637573488}
Grabbed: 0
--- !u!54 &1732996613952540235
@ -112,6 +112,19 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &7014937997629475779
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086008818391599545}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b647d1ea5d6785a4d8e6f6b2208e5f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 273b9cf97d0c80e449f24a33a2d261d1, type: 2}
--- !u!1 &7882310482220326929
GameObject:
m_ObjectHideFlags: 0

View File

@ -4902,6 +4902,7 @@ GameObject:
- component: {fileID: 2499151591214202486}
- component: {fileID: 5807904180460221178}
- component: {fileID: 4109150851726414724}
- component: {fileID: 3611004544794653208}
m_Layer: 10
m_Name: Stick VR
m_TagString: Untagged
@ -5087,7 +5088,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b525f40179118940b3017cbda89411f, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 273b9cf97d0c80e449f24a33a2d261d1, type: 2}
IgnitedQuality: {fileID: 11400000, guid: 62d0193d1d08b814d9328f3dd1d117cb, type: 2}
IgniteDuration: 0.25
Ignited: 0
@ -5099,6 +5099,19 @@ MonoBehaviour:
TorchLight: {fileID: 8748250233633719603}
WarnColor: {r: 1, g: 0.6509804, b: 0.44705883, a: 1}
TorchFuel: 0
--- !u!114 &3611004544794653208
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2086008818391599545}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b647d1ea5d6785a4d8e6f6b2208e5f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
Quality: {fileID: 11400000, guid: 273b9cf97d0c80e449f24a33a2d261d1, type: 2}
--- !u!1 &2973616090333718160
GameObject:
m_ObjectHideFlags: 0

View File

@ -2,6 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class Burnable : MonoBehaviour {
public BurnQuality Quality;
}

View File

@ -38,7 +38,7 @@ public class Campfire : MonoBehaviour {
private float NextRandomVariance = 0;
private float LastRandomVarianceChange = 0;
private List<Item> LogQueue = new List<Item>();
private List<Burnable> LogQueue = new List<Burnable>();
private float NextLogTime = 0;
private Transform Player;
@ -89,7 +89,7 @@ public class Campfire : MonoBehaviour {
Fuel = Mathf.Max(0, Fuel);
}
private bool BurnLog(Item burnable) {
private bool BurnLog(Burnable burnable) {
if (Fuel >= GoodFuelAmount * 2) {
return false;
} else {
@ -101,7 +101,7 @@ public class Campfire : MonoBehaviour {
private void OnCollisionEnter(Collision c) {
if (c.collider.attachedRigidbody != null && c.collider.attachedRigidbody) {
Item Burnable = c.collider.attachedRigidbody.GetComponent<Item>();
Burnable Burnable = c.collider.attachedRigidbody.GetComponent<Burnable>();
if (Burnable != null && !LogQueue.Contains(Burnable)) {
Flame.AddFuelEffect += Burnable.Quality.FlameEffect;
Sfx.ActiveBurn += Burnable.Quality.SoundEffect;
@ -115,7 +115,7 @@ public class Campfire : MonoBehaviour {
private void OnCollisionExit(Collision c) {
if (c.collider.attachedRigidbody != null && c.collider.attachedRigidbody) {
Item Burnable = c.collider.attachedRigidbody.GetComponent<Item>();
Burnable Burnable = c.collider.attachedRigidbody.GetComponent<Burnable>();
if (Burnable != null) {
LogQueue.Remove(Burnable);
}

View File

@ -3,13 +3,19 @@ using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(Burnable))]
public class Item : MonoBehaviour {
public BurnQuality Quality;
public Transform IgnitePoint;
public BurnQuality Quality {
get {
return Burnable.Quality;
}
}
[Header("Runtime values")]
public bool Grabbed = false;
private Burnable Burnable;
private Rigidbody Body;
private Transform World;
private bool BeingPlaced = false;
@ -18,6 +24,7 @@ public class Item : MonoBehaviour {
private Quaternion GrabRotation;
private void Awake() {
Burnable = GetComponent<Burnable>();
Body = GetComponent<Rigidbody>();
World = GameObject.FindGameObjectWithTag("World").transform;
}

View File

@ -5,8 +5,8 @@ using UnityEngine;
/*
* <summary>A replacement for the Item class in VR contexts.</summary>
*/
[RequireComponent(typeof(Burnable))]
public class ItemVR : MonoBehaviour {
public BurnQuality Quality;
public BurnQuality IgnitedQuality;
public float IgniteDuration;
public bool Ignited = false;
@ -23,11 +23,13 @@ public class ItemVR : MonoBehaviour {
[Header("Runtime values")]
public float TorchFuel;
private Burnable Burnable;
private int BurningSourceCount = 0;
private float IgnitionStartTime = -1;
private Color NormalColor;
private void Start() {
Burnable = GetComponent<Burnable>();
NormalColor = TorchLight.color;
TorchObject.SetActive(Ignited);
StickObject.SetActive(!Ignited);
@ -54,7 +56,7 @@ public class ItemVR : MonoBehaviour {
TorchObject.SetActive(true);
FireParticles.Play();
StickObject.SetActive(false);
Quality = IgnitedQuality;
Burnable.Quality = IgnitedQuality;
}
}