Exemplo n.º 1
0
        public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableBase, Base targetBase, TechType techType, Quaternion quaternion)
        {
            if (!Builder.isPlacing) //prevent possible echoing
            {
                return;
            }

            NitroxId  id             = NitroxEntity.GetId(constructableBase.gameObject);
            NitroxId  parentBaseId   = (targetBase == null) ? null : NitroxEntity.GetId(targetBase.gameObject);
            Vector3   placedPosition = constructableBase.gameObject.transform.position;
            Transform camera         = Camera.main.transform;
            Optional <RotationMetadata> rotationMetadata = rotationMetadataFactory.From(baseGhost);

            BasePiece      basePiece       = new BasePiece(id, placedPosition, quaternion, camera.position, camera.rotation, techType.Model(), Optional <NitroxId> .OfNullable(parentBaseId), false, rotationMetadata);
            PlaceBasePiece placedBasePiece = new PlaceBasePiece(basePiece);

            packetSender.Send(placedBasePiece);
        }
Exemplo n.º 2
0
        public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableBase, Base targetBase, TechType techType, Quaternion quaternion)
        {
            if (!Builder.isPlacing) //prevent possible echoing
            {
                return;
            }

            NitroxId id           = NitroxEntity.GetId(constructableBase.gameObject);
            NitroxId parentBaseId = null;

            if (targetBase != null)
            {
                parentBaseId = NitroxEntity.GetId(targetBase.gameObject);
            }
            else if (constructableBase != null)
            {
                Base playerBase = constructableBase.gameObject.GetComponentInParent <Base>();

                if (playerBase != null)
                {
                    parentBaseId = NitroxEntity.GetId(playerBase.gameObject);
                }
            }

            if (parentBaseId == null)
            {
                Base playerBase = baseGhost.gameObject.GetComponentInParent <Base>();

                if (playerBase != null)
                {
                    parentBaseId = NitroxEntity.GetId(playerBase.gameObject);
                }
            }

            Vector3   placedPosition = constructableBase.gameObject.transform.position;
            Transform camera         = Camera.main.transform;
            Optional <RotationMetadata> rotationMetadata = rotationMetadataFactory.From(baseGhost);

            BasePiece      basePiece       = new BasePiece(id, placedPosition.ToDto(), quaternion.ToDto(), camera.position.ToDto(), camera.rotation.ToDto(), techType.ToDto(), Optional.OfNullable(parentBaseId), false, rotationMetadata);
            PlaceBasePiece placedBasePiece = new PlaceBasePiece(basePiece);

            packetSender.Send(placedBasePiece);
        }