Example #1
0
        public void RunCommands(List <VMArchitectureCommand> commands)
        {
            for (var i = 0; i < commands.Count; i++)
            {
                var com = commands[i];
                switch (com.Type)
                {
                case VMArchitectureCommandType.WALL_LINE:
                    VMArchitectureTools.DrawWall(this, new Point(com.x, com.y), com.x2, com.y2, com.pattern, com.style, com.level, false);
                    break;

                case VMArchitectureCommandType.WALL_DELETE:
                    VMArchitectureTools.EraseWall(this, new Point(com.x, com.y), com.x2, com.y2, com.pattern, com.style, com.level);
                    break;

                case VMArchitectureCommandType.WALL_RECT:
                    VMArchitectureTools.DrawWallRect(this, new Rectangle(com.x, com.y, com.x2, com.y2), com.pattern, com.style, com.level);
                    break;

                case VMArchitectureCommandType.PATTERN_FILL:
                    VMArchitectureTools.WallPatternFill(this, new Point(com.x, com.y), com.pattern, com.level);
                    break;

                case VMArchitectureCommandType.PATTERN_DOT:
                    VMArchitectureTools.WallPatternDot(this, new Point(com.x, com.y), com.pattern, com.x2, com.y2, com.level);
                    break;

                case VMArchitectureCommandType.FLOOR_FILL:
                    VMArchitectureTools.FloorPatternFill(this, new Point(com.x, com.y), com.pattern, com.level);
                    break;

                case VMArchitectureCommandType.FLOOR_RECT:
                    VMArchitectureTools.FloorPatternRect(this, new Rectangle(com.x, com.y, com.x2, com.y2), com.style, com.pattern, com.level);
                    break;
                }
            }
        }
Example #2
0
        public int RunCommands(List <VMArchitectureCommand> commands, bool transient)
        {
            int      cost       = 0; //negative for sellback;
            int      pdCount    = 0;
            ushort   pdVal      = 0;
            VMAvatar lastAvatar = null;

            for (var i = 0; i < commands.Count; i++)
            {
                var com    = commands[i];
                var avaEnt = Context.VM.Entities.FirstOrDefault(x => x.PersistID == com.CallerUID);
                if ((avaEnt == null || avaEnt is VMGameObject) && !transient)
                {
                    return(0);                                                          //we need an avatar to run a command from net
                }
                var avatar = (transient)? null : (VMAvatar)avaEnt;
                lastAvatar = avatar;
                var styleInd = -1;
                var walls    = Content.Content.Get().WorldWalls;
                walls.WallStyleToIndex.TryGetValue(com.style, out styleInd);
                //if patterns are invalid, don't do anything.
                switch (com.Type)
                {
                case VMArchitectureCommandType.WALL_LINE:
                    if (styleInd == -1)
                    {
                        break;                     //MUST be purchasable style
                    }
                    var lstyle  = walls.GetWallStyle(com.style);
                    var nwCount = VMArchitectureTools.DrawWall(this, new Point(com.x, com.y), com.x2, com.y2, com.pattern, com.style, com.level, false);
                    if (nwCount > 0)
                    {
                        cost += nwCount * lstyle.Price;
                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "placed " + nwCount + " walls."
                                                                       ));
                        }
                    }
                    break;

                case VMArchitectureCommandType.WALL_DELETE:
                    var dwCount = VMArchitectureTools.EraseWall(this, new Point(com.x, com.y), com.x2, com.y2, com.pattern, com.style, com.level);
                    if (dwCount > 0)
                    {
                        cost -= 7 * dwCount;
                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "erased " + dwCount + " walls."
                                                                       ));
                        }
                    }
                    break;

                case VMArchitectureCommandType.WALL_RECT:
                    if (styleInd == -1)
                    {
                        break;                     //MUST be purchasable style
                    }
                    var rstyle  = walls.GetWallStyle(com.style);
                    var rwCount = VMArchitectureTools.DrawWallRect(this, new Rectangle(com.x, com.y, com.x2, com.y2), com.pattern, com.style, com.level);
                    if (rwCount > 0)
                    {
                        cost += rwCount * rstyle.Price;
                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "placed " + rwCount + " walls (rect)."
                                                                       ));
                        }
                    }
                    break;

                case VMArchitectureCommandType.PATTERN_FILL:
                    var pattern = GetPatternRef(com.pattern);
                    if (pattern == null && com.pattern != 0)
                    {
                        break;
                    }
                    var pfCount = VMArchitectureTools.WallPatternFill(this, new Point(com.x, com.y), com.pattern, com.level);
                    if (pfCount.Total > 0)
                    {
                        cost -= pfCount.Cost - pfCount.Cost / 5;
                        cost += (pattern == null) ? 0 : pattern.Price * pfCount.Total;
                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "pattern filled " + pfCount + " walls with pattern #" + com.pattern
                                                                       ));
                        }
                    }
                    break;

                case VMArchitectureCommandType.PATTERN_DOT:
                    var pdpattern = GetPatternRef(com.pattern);
                    if (pdpattern == null && com.pattern != 0)
                    {
                        break;
                    }
                    var dot = VMArchitectureTools.WallPatternDot(this, new Point(com.x, com.y), com.pattern, com.x2, com.y2, com.level);
                    pdVal = com.pattern;
                    if (dot.Total > -1)
                    {
                        cost -= dot.Cost - dot.Cost / 5;
                        cost += (pdpattern == null) ? 0 : pdpattern.Price;
                        pdCount++;
                    }

                    break;

                case VMArchitectureCommandType.FLOOR_FILL:
                    var ffpattern = GetFloorRef(com.pattern);
                    if (ffpattern == null && com.pattern != 0)
                    {
                        break;
                    }
                    var ffCount = VMArchitectureTools.FloorPatternFill(this, new Point(com.x, com.y), com.pattern, com.level);
                    if (ffCount.Total > 0)
                    {
                        cost -= (ffCount.Cost - ffCount.Cost / 5) / 2;
                        cost += (ffpattern == null) ? 0 : ffpattern.Price * ffCount.Total / 2;

                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "floor filled " + ffCount.Total / 2f + " with pattern #" + com.pattern
                                                                       ));
                        }
                    }
                    break;

                case VMArchitectureCommandType.FLOOR_RECT:
                    var frpattern = GetFloorRef(com.pattern);
                    if (frpattern == null && com.pattern != 0)
                    {
                        break;
                    }
                    var frCount = VMArchitectureTools.FloorPatternRect(this, new Rectangle(com.x, com.y, com.x2, com.y2), com.style, com.pattern, com.level);
                    if (frCount.Total > 0)
                    {
                        cost -= (frCount.Cost - frCount.Cost / 5) / 2;
                        cost += (frpattern == null) ? 0 : frpattern.Price * frCount.Total / 2;

                        if (avatar != null)
                        {
                            Context.VM.SignalChatEvent(new VMChatEvent(avatar.PersistID, VMChatEventType.Arch,
                                                                       avatar.Name,
                                                                       Context.VM.GetUserIP(avatar.PersistID),
                                                                       "placed " + frCount.Total / 2f + " tiles with pattern #" + com.pattern
                                                                       ));
                        }
                    }
                    break;
                }
            }
            if (lastAvatar != null && pdCount > 0)
            {
                Context.VM.SignalChatEvent(new VMChatEvent(lastAvatar.PersistID, VMChatEventType.Arch,
                                                           lastAvatar.Name,
                                                           Context.VM.GetUserIP(lastAvatar.PersistID),
                                                           "pattern dotted " + pdCount + " walls with pattern #" + pdVal
                                                           ));
            }

            return(cost);
        }