public void Attach(bool disparentHands = true, IKFixer optional = null) { if (optional == null) { optional = transform.root.GetComponent <IKFixer>(); } if (optional == null) { return; } lastIK = optional; /* * DISPARENT HANDS, USED FOR WEAPONS * */ if (disparentHands) { IKData.IK getIK = IKData.GetItemIK(lastIK.PlayerClass, gameObject.name); transform.localPosition = getIK.objLocalPosition; transform.localEulerAngles = getIK.objLocalEulerAngles; transform.localScale = getIK.objLocalScale; if (IKLeft != null) { IKLeft.localPosition = getIK.leftHandPosition; IKLeft.localEulerAngles = getIK.leftHandEulerAngles; IKLeft.SetParent(transform.parent); } if (IKRight != null) { IKRight.localPosition = getIK.rightHandPosition; IKRight.localEulerAngles = getIK.rightHandEulerAngles; IKRight.SetParent(transform.parent); } handsDisparented = true; } /* * */ optional.attachLeft = IKLeft; optional.attachRight = IKRight; }
void Start() { list.Add(this); cameraHolder = transform.Find("CameraHolder"); // standart camera position if (cameraHolder != null) { defaultCamPosition = cameraHolder.localPosition; } focusHolder = transform.Find("FocusHolder"); // camera position when right mouse aimed aim = new A(); identity = GetComponent <SNet_Identity>(); health = new Health(identity.identity); inventory = GetComponent <PlayerInventory>(); ik = GetComponent <IKFixer>(); // Add default starting item of the map. if (!string.IsNullOrEmpty(GameMap.instance.startingItem)) { inventory.AddItem(ResourcesLoader.prefabs.Find(x => x.name == GameMap.instance.startingItem).GetComponent <Item>().item); } // aimBone = identity.animator.animator.GetBoneTransform(HumanBodyBones.Spine); if (isLocalPlayer) { /* * Local players & host controlled NPCs must sync themselves * */ MonoBehaviourExtensions.Invoke(this, GeneralSync, 5f); // Hide the player spawner panel, because we are already spawned. SNet_Manager.instance.panel_Game.transform.Find("playerSpawner").gameObject.SetActive(false); } else { // Other players UI UI_PlayerAgent = Instantiate(SNet_Manager.instance.UI_PlayerAgent, aimBone.parent); UI_PlayerAgent.localPosition = SNet_Manager.instance.UI_PlayerAgent.localPosition; UI_PlayerAgent.Find("steamAvatar").GetComponent <Facepunch_Avatar>().Fetch(identity.identity); UI_PlayerAgent.Find("steamName").GetComponent <Text>().text = Client.Instance.Friends.GetName(identity.identity); } /* * THIS IS A NEW PLAYER, UPDATE THE SPAWNED IDENTITIES FOR THE NEW PLAYER * */ if (SNet_Network.instance.isHost()) { // Host will update the spawneds Debug.Log("New player spawned, SpawnAll()"); int sCount = SNet_Identity.list.Count; for (int i = 0; i < sCount; i++) { if (!SNet_Identity.list[i].controller) { // Refresh only non-player objects SNet_Network.Spawn sp = new SNet_Network.Spawn (SNet_Identity.list[i].prefab, SNet_Identity.list[i].transform.position, SNet_Identity.list[i].transform.rotation, SNet_Identity.list[i].transform.localScale, 0, true); sp.i = SNet_Identity.list[i].identity; SNet_Network.instance.Send_Message(sp, identity.identity); /* * UPDATE SYNCERS (Transforms, rigidbodies), But DON'T MAKE ANGRY STEAM SERVERS, SO USE RANDOM VALUES * */ if (SNet_Identity.list[i].tform != null) { SNet_Identity.list[i].tform.ReUpdate(); } if (SNet_Identity.list[i].rbody != null) { SNet_Identity.list[i].rbody.ReUpdate(); } if (SNet_Identity.list[i].vehicle != null) { MonoBehaviourExtensions.Invoke(SNet_Identity.list[i].vehicle, SNet_Identity.list[i].vehicle.VehicleUpdate, 3f); } } } } }