コード例 #1
0
        protected void CreateLine(ActionSet actionSet, Line line, Element visibleTo, Element location, Element rotation, Element scale, IWorkshopTree reevaluation)
        {
            Vertex  vertex1 = line.Vertex1;
            Vertex  vertex2 = line.Vertex2;
            Element pos1;
            Element pos2;

            bool scaleSet    = false;
            bool rotationSet = false;

            if (scale != null)
            {
                double?constantScale = null;

                // Double constant scale
                if (scale.ConstantSupported <double>())
                {
                    constantScale = (double)scale.GetConstant();
                }

                // Null constant rotation
                else if (scale is V_Null)
                {
                    constantScale = 1;
                }

                if (constantScale == 1)
                {
                    scaleSet = true;
                }

                if (!scaleSet && constantScale != null)
                {
                    vertex1  = vertex1.Scale((double)constantScale);
                    vertex2  = vertex2.Scale((double)constantScale);
                    scaleSet = true;
                }
            }

            if (rotation != null)
            {
                Vertex rotationConstant = null;

                // Vector constant rotation
                if (rotation.ConstantSupported <Vertex>())
                {
                    rotationConstant = (Vertex)rotation.GetConstant();
                }

                // Double constant rotation
                else if (rotation.ConstantSupported <double>())
                {
                    rotationConstant = new Vertex(0, (double)rotation.GetConstant(), 0);
                }

                // Null constant rotation
                else if (rotation is V_Null)
                {
                    rotationConstant = new Vertex(0, 0, 0);
                }

                if (rotationConstant != null && rotationConstant.EqualTo(new Vertex(0, 0, 0)))
                {
                    rotationSet = true;
                }

                if (rotationConstant != null && !rotationSet)
                {
                    vertex1     = vertex1.Rotate(rotationConstant);
                    vertex2     = vertex2.Rotate(rotationConstant);
                    rotationSet = true;
                }
            }

            if (rotation != null && !rotationSet)
            {
                var pos1X = vertex1.X;
                var pos1Y = vertex1.Y;
                var pos1Z = vertex1.Z;
                var pos2X = vertex2.X;
                var pos2Y = vertex2.Y;
                var pos2Z = vertex2.Z;

                var yaw   = Element.Part <V_HorizontalAngleFromDirection>(rotation);
                var pitch = Element.Part <V_VerticalAngleFromDirection>(rotation);

                var cosa = Element.Part <V_CosineFromDegrees>(pitch);
                var sina = Element.Part <V_SineFromDegrees>(pitch);

                var cosb = Element.Part <V_CosineFromDegrees>(yaw);
                var sinb = Element.Part <V_SineFromDegrees>(yaw);

                var Axx = cosa * cosb;
                var Axy = 0 - sina;
                var Axz = cosa * sinb;

                var Ayx = sina * cosb;
                var Ayy = cosa;
                var Ayz = sina * sinb;

                var Azx = -sinb;

                pos1 = Element.Part <V_Vector>(
                    Axx * pos1X +
                    Axy * pos1Y +
                    Axz * pos1Z,
                    Ayx * pos1X +
                    Ayy * pos1Y +
                    Ayz * pos1Z,
                    Azx * pos1X +
                    pos1Z
                    );

                pos2 = Element.Part <V_Vector>(
                    Axx * pos2X +
                    Axy * pos2Y +
                    Axz * pos2Z,
                    Ayx * pos2X +
                    Ayy * pos2Y +
                    Ayz * pos2Z,
                    Azx * pos2X +
                    pos2Z
                    );
            }
            else
            {
                pos1 = vertex1.ToVector();
                pos2 = vertex2.ToVector();
            }

            if (scale != null && !scaleSet)
            {
                pos1 = pos1 * scale;
                pos2 = pos2 * scale;
            }

            actionSet.AddAction(Element.Part <A_CreateBeamEffect>(
                                    visibleTo,
                                    EnumData.GetEnumValue(BeamType.GrappleBeam),
                                    location + pos1,
                                    location + pos2,
                                    EnumData.GetEnumValue(Elements.Color.Red),
                                    reevaluation
                                    ));
        }
コード例 #2
0
 public virtual IWorkshopTree Contains(IWorkshopTree reference, IWorkshopTree value) => Element.Contains(reference, value);
コード例 #3
0
        protected IWorkshopTree RenderModel(ActionSet actionSet, Model model, Element visibleTo, Element location, Element rotation, Element scale, IWorkshopTree reevaluation, bool getEffectIDs)
        {
            IndexReference effects = null;

            if (getEffectIDs)
            {
                effects = actionSet.VarCollection.Assign("_modelEffects", actionSet.IsGlobal, true);
                actionSet.AddAction(effects.SetVariable(new V_EmptyArray()));
            }

            for (int i = 0; i < model.Lines.Length; i++)
            {
                CreateLine(actionSet, model.Lines[i], visibleTo, location, rotation, scale, reevaluation);

                // Get the last created effect and append it to the store array.
                if (effects != null)
                {
                    actionSet.AddAction(effects.ModifyVariable(Operation.AppendToArray, new V_LastCreatedEntity()));
                }

                // Add a wait every 12 effects to prevent high server load.
                if (i % 10 == 0)
                {
                    actionSet.AddAction(A_Wait.MinimumWait);
                }
            }

            return(effects?.GetVariable());
        }
コード例 #4
0
 public virtual IWorkshopTree FirstOf(IWorkshopTree reference) => Element.FirstOf(reference);
コード例 #5
0
 public virtual IWorkshopTree LastOf(IWorkshopTree reference) => Element.LastOf(reference);
コード例 #6
0
 public SkipStartMarker(ActionSet actionSet, IWorkshopTree condition)
 {
     ActionSet = actionSet;
     Condition = condition;
 }
コード例 #7
0
 public virtual IWorkshopTree Length(IWorkshopTree reference) => Element.CountOf(reference);
コード例 #8
0
 public ALAction(IWorkshopTree calling)
 {
     Calling = calling;
 }
コード例 #9
0
 public void AddAction(IWorkshopTree action)
 {
     ActionList.Add(new ALAction(action));
 }
コード例 #10
0
 public bool EqualTo(IWorkshopTree other) => throw new NotImplementedException();
コード例 #11
0
 public AssignmentOperationInfo(string comment, ActionSet actionSet, VariableElements variableInfo, IWorkshopTree value)
 {
     _comment  = comment;
     ActionSet = actionSet;
     Value     = value;
     _elements = variableInfo;
 }
コード例 #12
0
 public override IndexReference GetObjectSource(DeltinScript translateInfo, IWorkshopTree element)
 {
     return(translateInfo.SetupClasses().ClassArray.CreateChild((Element)element));
 }