コード例 #1
0
    public override void OnEvent(BlockDestroy evnt)
    {
        if (entity.IsOwner)
        {
            GlobalReferences.AffectedParts.Remove(gameObject);
            GlobalReferences.FreeParts.Remove(gameObject);

            Part p = GetComponent <Part>();
            if (PlacementReferences.InfiniteParts && p.Respawn)
            {
                GameObject go = GlobalReferences.PartSpawner.SpawnPart(p.TemplateID);
                go.GetComponent <Part>().Respawn = true;

                if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
                {
                    GlobalReferences.AffectPart(go);
                    GlobalReferences.FreeParts.Remove(go);
                }
            }
            if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
            {
                GlobalReferences.ChangeAffectedNumber(PlacementReferences.AffectedParts);
            }

            BoltNetwork.Destroy(gameObject);
        }
    }
コード例 #2
0
    public override void OnEvent(BlockFreeze evnt)
    {
        Destroy(gameObject.GetComponent <ConstantForce>());
        Part p = gameObject.GetComponent <Part>();

        gameObject.transform.position = evnt.BlockPosition;
        gameObject.transform.rotation = evnt.BlockRotation;

        p.FreezePart(evnt.ID);
        p.Parent    = evnt.ParentID;
        p.ParentCon = evnt.ParentCon;

        Part parentPart = GlobalReferences.FrozenParts[evnt.ParentID].GetComponent <Part>();

        ConnectionVoxelContainer.RemoveConnection(parentPart.Connections[evnt.ParentCon]);
        ConnectionVoxelContainer.RemoveConnection(gameObject.GetComponent <Part>().Connections[evnt.ConnectionID]);

        parentPart.ChildCons.Add(evnt.ConnectionID);
        parentPart.SetInactive(parentPart.Connections[evnt.ParentCon]);
        p.SetInactive(p.Connections[evnt.ConnectionID]);

        parentPart.Children.Add((int)p.ID);

        gameObject.transform.position = evnt.BlockPosition;
        gameObject.transform.rotation = evnt.BlockRotation;

        if (PlacementReferences.InfiniteParts && entity.IsOwner && p.Respawn)
        {
            GameObject go = GlobalReferences.PartSpawner.SpawnPart(p.TemplateID);
            go.GetComponent <Part>().Respawn = true;

            if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
            {
                GlobalReferences.AffectPart(go);
                GlobalReferences.FreeParts.Remove(go);
            }
        }
        if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo && entity.IsOwner)
        {
            GlobalReferences.ChangeAffectedNumber(PlacementReferences.AffectedParts);
        }

        if (entity.IsOwner)
        {
            //entity.Freeze(true);
        }
    }
コード例 #3
0
    private void RealizeConnection()
    {
        if (lastDistAngle < connectionThreshold && ConnectionVoxelContainer.RevealConnections(bestOnPart).Contains(closestConnection))
        {
            Vector3    pos = gameObject.transform.position;
            Quaternion rot = gameObject.transform.rotation;

            AlignPlane.Orient(bestOnPart.Pln, closestConnection.Pln, gameObject);

            if (!CollisionDetection())
            {
                Part p = gameObject.GetComponent <Part>();
                p.FreezePart();
                p.Parent    = closestConnection.ParentPart.ID;
                p.ParentCon = closestConnection.ParentPart.Connections.IndexOf(closestConnection);

                ConnectionVoxelContainer.RemoveConnection(closestConnection);
                ConnectionVoxelContainer.RemoveConnection(bestOnPart);

                bestOnPart.ParentPart.SetInactive(bestOnPart);
                closestConnection.ParentPart.SetInactive(closestConnection);
                closestConnection.ParentPart.ChildCons.Add(bestOnPart.ParentPart.Connections.IndexOf(bestOnPart));

                closestConnection.ParentPart.Children.Add((int)p.ID);

                GameObject _g = PartsHolder.SpawnPart(p.TemplateID);
                _g.SetActive(true);
                if (GlobalReferences.PlacementType == PlacementTypeTool.PlaceChoreo.Choreo)
                {
                    GlobalReferences.AffectPart(_g);
                    GlobalReferences.FreeParts.Remove(_g);
                }

                ConnectionScanningHandler handler = gameObject.GetComponent <ConnectionScanningHandler>();
                if (handler != null)
                {
                    handler.TerminateConnection();
                }
            }
            else
            {
                gameObject.transform.position = pos;
                gameObject.transform.rotation = rot;
            }
        }
    }
コード例 #4
0
ファイル: CheckCollision.cs プロジェクト: jpdrude/DisCo-Code
    void FreezeSinglePlayer()
    {
        Part p = gameObject.GetComponent <Part>();

        p.FreezePart();

        p.Parent    = closestConnection.ParentPart.ID;
        p.ParentCon = closestConnection.ParentPart.Connections.IndexOf(closestConnection);

        p.ConToParent = bestOnPart.ParentPart.Connections.IndexOf(bestOnPart);

        ConnectionVoxelContainer.RemoveConnection(closestConnection);
        ConnectionVoxelContainer.RemoveConnection(bestOnPart);

        closestConnection.ParentPart.ChildCons.Add(bestOnPart.ParentPart.Connections.IndexOf(bestOnPart));
        closestConnection.ParentPart.Children.Add((int)p.ID);


        bestOnPart.ParentPart.SetInactive(bestOnPart);
        closestConnection.ParentPart.SetInactive(closestConnection);

        if (PlacementReferences.InfiniteParts && p.Respawn)
        {
            GameObject go = GlobalReferences.PartSpawner.SpawnPart(p.TemplateID);
            go.GetComponent <Part>().Respawn = true;

            if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
            {
                GlobalReferences.AffectPart(go);
                GlobalReferences.FreeParts.Remove(go);
            }
        }
        if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
        {
            GlobalReferences.ChangeAffectedNumber(PlacementReferences.AffectedParts);
        }
    }