Exemplo n.º 1
0
        static public void DeconstructBase(BaseDeconstructable target, Base targetBase, GameObject constructable, TechType tech)
        {
            lastConstructableObject = constructable;

            if (Multiplayer.main.blocked)
            {
                return;
            }

            if (buildConstructActive)
            {
                return;
            }

            var res = new ClientBuildDeconstructBase();

            res.deconstructableGuid = GuidHelper.Get(target.gameObject);
            res.constructableGuid   = GuidHelper.Get(GetNewConstructable());
            res.baseGuid            = GuidHelper.Get(targetBase?.gameObject);
            res.tech      = tech;
            res.position  = target.transform.position;
            res.faceType  = target.faceType;
            res.boundsMin = target.bounds.mins;
            res.boundsMax = target.bounds.maxs;

            var face = target.face.GetValueOrDefault();

            res.faceDirection = face.direction;
            res.faceCell      = face.cell;

            Multiplayer.main.Send(res);
        }
Exemplo n.º 2
0
        private void Process(ClientBuildDeconstructBase msg)
        {
            var target = FindBaseDeconstructable(msg.deconstructableGuid, msg.baseGuid, msg.faceType, new Base.Face(msg.faceCell, msg.faceDirection), new Int3.Bounds(msg.boundsMin, msg.boundsMax));

            if (target == null)
            {
                return;
            }

            Logic.Building.buildConstructActive = true;

            try {
                target.Deconstruct();
                GuidHelper.Set(Logic.Building.GetNewConstructable(), msg.constructableGuid);
            } catch (Exception exception) {
                UnityEngine.Debug.LogException(exception);
            }

            Logic.Building.buildConstructActive = false;
        }