Merge commit '3d2374436c10bab43a85c2177f174fb530f751c4'
This commit is contained in:
parent
5f30069520
commit
56edf36785
@ -65,7 +65,7 @@ namespace RoboidControl.Unity {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void Update() {
|
protected virtual void Update() {
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
Debug.Log("Core thing is gone, self destruct in 0 seconds...");
|
// Debug.Log("Core thing is gone, self destruct in 0 seconds...");
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ namespace RoboidControl.Unity {
|
|||||||
core.nameChanged = false;
|
core.nameChanged = false;
|
||||||
}
|
}
|
||||||
if (core.hierarchyChanged) {
|
if (core.hierarchyChanged) {
|
||||||
Debug.Log("Parent changed");
|
// Debug.Log("Parent changed");
|
||||||
if (core.parent == null)
|
if (core.parent == null)
|
||||||
this.transform.SetParent(null, true);
|
this.transform.SetParent(null, true);
|
||||||
else
|
else
|
||||||
|
@ -16,6 +16,8 @@ namespace RoboidControl.Unity {
|
|||||||
get => (RoboidControl.TouchSensor)base.core;
|
get => (RoboidControl.TouchSensor)base.core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SphereCollider collider = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the Unity represention
|
/// Start the Unity represention
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -24,6 +26,7 @@ namespace RoboidControl.Unity {
|
|||||||
participant = FindAnyObjectByType<SiteServer>();
|
participant = FindAnyObjectByType<SiteServer>();
|
||||||
SetCoreThing(new RoboidControl.TouchSensor(participant.site));
|
SetCoreThing(new RoboidControl.TouchSensor(participant.site));
|
||||||
}
|
}
|
||||||
|
collider = GetComponent<SphereCollider>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -53,11 +56,26 @@ namespace RoboidControl.Unity {
|
|||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update() {
|
||||||
|
base.Update();
|
||||||
|
if (collider.radius == 0.01f &&
|
||||||
|
this.transform.parent != null && this.transform.localPosition.magnitude > 0
|
||||||
|
) {
|
||||||
|
collider.radius = Vector3.Distance(this.transform.position, this.transform.parent.position) / 2;
|
||||||
|
this.transform.position = (this.transform.position + this.transform.parent.position) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other) {
|
private void OnTriggerEnter(Collider other) {
|
||||||
if (other.isTrigger)
|
Debug.Log("Touch?");
|
||||||
|
if (other.isTrigger) {
|
||||||
|
Debug.Log($" was trigger {other.name}");
|
||||||
return;
|
return;
|
||||||
if (this.transform.root == other.transform.root)
|
}
|
||||||
|
if (this.transform.root == other.transform.root) {
|
||||||
|
Debug.Log($" was myself {other.name}");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log($"*** {this} Touch");
|
Debug.Log($"*** {this} Touch");
|
||||||
this.coreSensor.touchedSomething = true;
|
this.coreSensor.touchedSomething = true;
|
||||||
|
@ -73,7 +73,9 @@ namespace RoboidControl {
|
|||||||
|
|
||||||
if (this.isIsolated == false) {
|
if (this.isIsolated == false) {
|
||||||
// Send to all other participants
|
// Send to all other participants
|
||||||
foreach (Participant participant in Participant.participants) {
|
//foreach (Participant participant in Participant.participants) {
|
||||||
|
for (int participantIx = 0; participantIx < Participant.participants.Count; participantIx++) {
|
||||||
|
Participant participant = Participant.participants[participantIx];
|
||||||
if (participant == null || participant == this)
|
if (participant == null || participant == this)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ namespace RoboidControl {
|
|||||||
Console.WriteLine($"Could not find parent [{msg.networkId}/{msg.parentId}]");
|
Console.WriteLine($"Could not find parent [{msg.networkId}/{msg.parentId}]");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Console.Write($"Dropped {thing.id}");
|
// Console.Write($"Dropped {thing.id}");
|
||||||
thing.parent = null;
|
thing.parent = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace RoboidControl {
|
|||||||
this.id = thingId;
|
this.id = thingId;
|
||||||
this.type = thingType;
|
this.type = thingType;
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
Console.Write($"New thing added to {owner}");
|
// Console.Write($"New thing added to {owner}");
|
||||||
this.owner.Add(this);
|
this.owner.Add(this);
|
||||||
InvokeNewThing(this);
|
InvokeNewThing(this);
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ namespace RoboidControl {
|
|||||||
get { return _touchedSomething; }
|
get { return _touchedSomething; }
|
||||||
set {
|
set {
|
||||||
if (_touchedSomething != value) {
|
if (_touchedSomething != value) {
|
||||||
touchUpdated = true;
|
|
||||||
_touchedSomething = value;
|
_touchedSomething = value;
|
||||||
}
|
}
|
||||||
|
touchUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private bool touchUpdated = false;
|
private bool touchUpdated = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user