示例#1
0
        public static bool Prefix(Vector2 tileLocation, Farmer who, NetPoint ___humanDoor, NetInt ___tileX, NetInt ___tileY, Building __instance)
        {
            int doorWidth = 2;
            int xDist     = (int)tileLocation.X - (___humanDoor.X + ___tileX.Value);

            if (who.IsLocalPlayer && CabinHelper.IsElevatorBuilding(__instance) &&
                xDist < doorWidth && xDist >= 0 && tileLocation.Y == ___humanDoor.Y + ___tileY.Value)
            {
                if (who.mount != null)
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:DismountBeforeEntering"));
                    return(false);
                }
                if (who.team.buildLock.IsLocked())
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:CantEnter"));
                    return(false);
                }

                //indoors.Value.isStructure.Value = true;

                who.currentLocation.playSoundAt("crystal", tileLocation);

                if (Game1.activeClickableMenu == null)
                {
                    Game1.activeClickableMenu = new ElevatorMenu();
                }

                return(false);
            }
            return(true);
        }
        private static void Postfix(Farmer who)
        {
            if (!who.usingSlingshot || !who.IsLocalPlayer)
            {
                return;
            }

            NetPoint aimPos = (who.CurrentTool as Slingshot).aimPos;

            aimPos.Value = Reflect(Utils.GetCorrectFarmerPosition(who), aimPos.Value);
        }
示例#3
0
 private void CalculateLengthsAppro()
 {
     for (int i = 0; i < net.lengthNum; i++)
     {
         int    start  = net.netLengths[i].start;
         int    end    = net.netLengths[i].end;
         double length = NetPoint.Distance
                             (net.netPoints[start], net.netPoints[end]);
         net.netLengths[i].value  = length;
         observeAppro.value[i, 0] = length;
     }
 }
示例#4
0
 private void CalculateAngleAppro()
 {
     for (int i = 0; i < net.angleNum; i++)
     {
         int parent = net.netAngles[i].parent;
         int me     = net.netAngles[i].me;
         int child  = net.netAngles[i].child;
         //mp + theta = mc
         double angle_mp = NetPoint.Azimuth
                               (net.netPoints[me], net.netPoints[parent]);
         double angle_mc = NetPoint.Azimuth
                               (net.netPoints[me], net.netPoints[child]);
         double theta = angle_mc - angle_mp;
         theta = IMathNet.Adjust_0To2PI(theta);
         net.netAngles[i].value = theta;
         observeAppro.value[i + net.lengthNum, 0] = theta;
     }
 }
示例#5
0
 public void Equation_L()
 {
     for (int i = 0; i < net.lengthNum; i++)
     {
         int    start   = net.netLengths[i].start;
         int    end     = net.netLengths[i].end;
         double azimuth = NetPoint.Azimuth
                              (net.netPoints[start], net.netPoints[end]);
         double cos = Math.Cos(azimuth);
         double sin = Math.Sin(azimuth);
         if (start != net.startKnownPoint && start != net.endKnownPoint)
         {
             B.value[i, xDict[start]] = -cos;
             B.value[i, yDict[start]] = -sin;
         }
         if (end != net.startKnownPoint && end != net.endKnownPoint)
         {
             B.value[i, xDict[end]] = cos;
             B.value[i, yDict[end]] = sin;
         }
     }
 }
示例#6
0
        public void Equation_A()
        {
            double theta, dis, c_mp, d_mp, c_mc, d_mc;

            for (int i = 0; i < net.angleNum; i++)
            {
                int parent = net.netAngles[i].parent;
                int me     = net.netAngles[i].me;
                int child  = net.netAngles[i].child;
                //mp
                theta = NetPoint.Azimuth(net.netPoints[me], net.netPoints[parent]);
                dis   = NetPoint.Distance(net.netPoints[me], net.netPoints[parent]);
                c_mp  = -Math.Sin(theta) / dis;
                d_mp  = Math.Cos(theta) / dis;
                theta = NetPoint.Azimuth(net.netPoints[me], net.netPoints[child]);
                dis   = NetPoint.Distance(net.netPoints[me], net.netPoints[child]);
                c_mc  = -Math.Sin(theta) / dis;
                d_mc  = Math.Cos(theta) / dis;

                int row = i + net.lengthNum;
                if (parent != net.endKnownPoint && parent != net.startKnownPoint)
                {
                    B.value[row, xDict[parent]] = -c_mp;
                    B.value[row, yDict[parent]] = -d_mp;
                }
                if (me != net.endKnownPoint && me != net.startKnownPoint)
                {
                    B.value[row, xDict[me]] = c_mp - c_mc;
                    B.value[row, yDict[me]] = d_mp - d_mc;
                }
                if (child != net.endKnownPoint && child != net.startKnownPoint)
                {
                    B.value[row, xDict[child]] = c_mc;
                    B.value[row, yDict[child]] = d_mc;
                }
            }
        }
示例#7
0
        public static bool Postfix(bool b, int xTile, int yTile, Farmer who, Building __instance, NetPoint ___humanDoor, bool __result, NetInt ___tileX, NetInt ___tileY)
        {
            if (!CabinHelper.IsElevatorBuilding(__instance))
            {
                return(__result);
            }


            int doorWidth = 2;
            int dist      = xTile - (___tileX.Value + ___humanDoor.X);

            if (___humanDoor.X >= 0 && yTile == ___tileY.Value + ___humanDoor.Y &&
                dist < doorWidth && dist >= 0)
            {
                return(true);
            }

            return(false);
        }
示例#8
0
        private void CalculateChildPoint(int parent, int me, int child)
        {
            double azimuth_pm  = NetPoint.Azimuth(net.netPoints[parent], net.netPoints[me]);
            int    angleOrder  = -1; //设置-1,以检查错误
            int    lengthOrder = -1; //设置-1,以检查错误
            bool   isleft      = false;
            int    i;

            //寻找角度序号
            for (i = 0; i < net.angleNum; i++)
            {
                if (net.netAngles[i].me == me)
                {
                    if (net.netAngles[i].parent == parent && net.netAngles[i].child == child)
                    {
                        isleft     = true;
                        angleOrder = i;
                        break;
                    }
                    if (net.netAngles[i].parent == child && net.netAngles[i].child == parent)
                    {
                        isleft     = false;
                        angleOrder = i;
                        break;
                    }
                }
            }

            //计算当前点到子点的坐标方位角
            double azimuth_mc;

            if (isleft)
            {
                azimuth_pm += PI;                                           //反向
                azimuth_mc  = azimuth_pm + net.netAngles[angleOrder].value; //加左角
                //azimuth_mc = IMathNet.Adjust_0To2PI(azimuth_mc);//调范围
            }
            else
            {
                azimuth_pm += PI;                                           //反向
                azimuth_mc  = azimuth_pm - net.netAngles[angleOrder].value; //减右角
                                                                            // azimuth_mc = IMathNet.Adjust_0To2PI(azimuth_mc);//调范围
            }

            //寻找长度序号

            for (i = 0; i < net.lengthNum; i++)
            {
                if (child == net.netLengths[i].start || child == net.netLengths[i].end)
                {
                    if (me == net.netLengths[i].start || me == net.netLengths[i].end)
                    {
                        lengthOrder = i;
                        break;
                    }
                }
            }
            double dis = net.netLengths[lengthOrder].value;

            //计算子点坐标
            double dx = dis * Math.Cos(azimuth_mc);
            double dy = dis * Math.Sin(azimuth_mc);

            net.netPoints[child].x = net.netPoints[me].x + dx;
            net.netPoints[child].y = net.netPoints[me].y + dy;
        }