Exemple #1
0
        public InserterCopy(InserterCopy_V1 model, BlueprintData_V1 data)
        {
            FieldInfo[] fields = GetType().GetFields();
            foreach (FieldInfo field in fields)
            {
                FieldInfo fieldOrg = model.GetType().GetField(field.Name);
                if (fieldOrg != null && field.FieldType == fieldOrg.FieldType)
                {
                    field.SetValue(this, fieldOrg.GetValue(model));
                }
            }

            BuildingCopy_V1 building       = data.copiedBuildings[referenceBuildingId];
            Vector2         buildingSprPos = building.originalPos.ToSpherical();

            Vector2 oldPosDelta  = (building.originalPos + building.originalRot * model.posDelta).ToSpherical();
            Vector2 oldPos2Delta = (building.originalPos + building.originalRot * model.pos2Delta).ToSpherical();

            posDelta  = (oldPosDelta - buildingSprPos).Clamp();
            pos2Delta = (oldPos2Delta - buildingSprPos).Clamp();

            posDeltaCount  = oldPosDelta.GetSegmentsCount();
            pos2DeltaCount = oldPos2Delta.GetSegmentsCount();

            Vector2 oldOtherSprPos = BlueprintData_V1.GetPointFromMoves(building.originalPos, model.movesFromReference, building.originalRot).ToSpherical();

            otherPosDelta      = oldOtherSprPos - buildingSprPos;
            otherPosDeltaCount = oldOtherSprPos.GetSegmentsCount();
        }
Exemple #2
0
        public BuildingCopy(BuildingCopy_V1 model, Vector2 referencePos, float referenceYaw)
        {
            FieldInfo[] fields = GetType().GetFields();
            foreach (FieldInfo field in fields)
            {
                FieldInfo fieldOrg = model.GetType().GetField(field.Name);
                if (fieldOrg != null && field.FieldType == fieldOrg.FieldType)
                {
                    field.SetValue(this, fieldOrg.GetValue(model));
                }
            }

            Vector2 sourceSprPos = model.originalPos.ToSpherical();

            originalSegmentCount = sourceSprPos.GetSegmentsCount();
            cursorRelativePos    = (sourceSprPos - referencePos).Clamp();
            cursorRelativeYaw    = model.cursorRelativeYaw + referenceYaw;
        }