blob: 8bfe6742c732e6847ccb45114d3f5d253c0af01a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
using System;
using System.Collections;
using Photon.Pun;
using UnityEngine;
public class PhotonMapObject : MonoBehaviour
{
private Map map;
private bool photonSpawned;
private float counter;
private bool waitingToBeRemoved;
private void Awake()
{
if (base.transform.parent != null)
{
UnityEngine.Object.DestroyImmediate(GetComponent<PhotonView>());
}
}
private void Start()
{
Rigidbody2D component = GetComponent<Rigidbody2D>();
component.isKinematic = true;
component.simulated = false;
if (base.transform.parent == null)
{
photonSpawned = true;
base.transform.SetParent(MapManager.instance.currentMap.Map.transform, worldPositionStays: true);
map = GetComponentInParent<Map>();
map.missingObjects--;
Map obj = map;
obj.mapIsReadyAction = (Action)Delegate.Combine(obj.mapIsReadyAction, new Action(Go));
if (map.hasRope && !GetComponent<PhotonView>().IsMine)
{
component.gravityScale = 0f;
}
}
else
{
map = GetComponentInParent<Map>();
Map obj2 = map;
obj2.mapIsReadyEarlyAction = (Action)Delegate.Combine(obj2.mapIsReadyEarlyAction, new Action(GoEarly));
}
}
private void GoEarly()
{
if (waitingToBeRemoved)
{
UnityEngine.Object.DestroyImmediate(base.gameObject);
}
}
private void Go()
{
StartCoroutine(IGo());
}
private IEnumerator IGo()
{
Rigidbody2D rig = GetComponent<Rigidbody2D>();
yield return new WaitForSeconds(0f);
yield return new WaitForSeconds(0f);
yield return new WaitForSeconds(0f);
rig.isKinematic = false;
rig.simulated = true;
if ((bool)rig)
{
for (float i = 0f; i < 1f; i += Time.deltaTime * 1f)
{
rig.velocity -= rig.velocity * i * 0.05f;
yield return null;
}
}
}
private void Update()
{
if (waitingToBeRemoved || photonSpawned)
{
return;
}
counter += Mathf.Clamp(Time.deltaTime, 0f, 0.1f);
if ((PhotonNetwork.OfflineMode && counter > 1f && map.hasEntered) || ((bool)map && map.hasEntered && map.LoadedForAll()))
{
if (PhotonNetwork.IsMasterClient)
{
PhotonNetwork.Instantiate("4 Map Objects/" + base.gameObject.name.Split(char.Parse(" "))[0], base.transform.position, base.transform.rotation, 0);
}
map.missingObjects++;
waitingToBeRemoved = true;
}
}
}
|