예제 #1
0
파일: Test.cs 프로젝트: notwo/UnityApp
    // Use this for initialization
    void Start()
    {
        // example of loading csv file
        csv = CSVLoader.Instance;
        //TextAsset txt = csv.loadFile(1, 1, "Alocer_Dania");
        unit = new Unit();
        unit.readCharCSV(1, "Lancelot_Tartare");
        //Debug.Log("step Name: " + BLance.getName());

        // including fade and transition
        fm = FadeManager.Instance;

        // example of sound playing
        snd = SoundManager.Instance;
        //snd.PlayBGM(0);

        // example of random value
        util = UtilCommon.Instance;

        // example of using ClassBase
        cb = ClassBase.Instance;

        ps = ParameterScreen.Instance;
        ps.inactivateGuages();

        mb = MessageBase.Instance;

        ms = MapScreen.Instance;
        //ms.showMap();

        DontDestroyOnLoad(this.gameObject);
    }
        /// <summary>
        /// Finds the given class member in the given class.
        /// </summary>
        /// <param name="word">The word to check.</param>
        /// <param name="parentClass">The class the word appears in.</param>
        /// <param name="members">The collection of members of the parent class.</param>
        /// <param name="interfaces">True if interface implementations should be included.</param>
        /// <returns>Returns the class members that match against the given name.</returns>
        private static ICollection <Element> FindClassMember(
            string word, ClassBase parentClass, Dictionary <string, List <Element> > members, bool interfaces)
        {
            Param.AssertNotNull(word, "word");
            Param.AssertNotNull(parentClass, "parentClass");
            Param.AssertNotNull(members, "members");
            Param.Ignore(interfaces);

            // If the word is the same as the class name, then this is a constructor and we
            // don't want to match against it.
            if (word != parentClass.Name)
            {
                ICollection <Element> matches = ReadabilityRules.MatchClassMember(word, members, interfaces);
                if (matches != null && matches.Count > 0)
                {
                    return(matches);
                }
            }

            return(null);
        }
        public object PlayerClassSet(LookupKey lookupKey, [FromBody] ClassChange change)
        {
            if (lookupKey.IsInvalid)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest, lookupKey.IsIdInvalid ? @"Invalid player id." : @"Invalid player name."
                           ));
            }

            if (change.ClassId == Guid.Empty || ClassBase.Get(change.ClassId) == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $@"Invalid class id ${change.ClassId}."));
            }

            var(client, player) = Player.Fetch(lookupKey);
            if (player != null)
            {
                player.ClassId = change.ClassId;
                player.RecalculateStatsAndPoints();
                player.UnequipInvalidItems();
                if (player.Online)
                {
                    PacketSender.SendEntityDataToProximity(player);
                }

                using (var context = DbInterface.CreatePlayerContext(false))
                {
                    context.Update(player);
                    context.SaveChanges();
                }

                return(player);
            }

            return(Request.CreateErrorResponse(
                       HttpStatusCode.NotFound,
                       lookupKey.HasId ? $@"No player with id '{lookupKey.Id}'." : $@"No player with name '{lookupKey.Name}'."
                       ));
        }
예제 #4
0
        private void addTemplateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Ask the user to select the type of Template
            ClassBase          godzClass = ClassBase.findClass("ObjectTemplate");
            ClassSelectionForm form      = new ClassSelectionForm(godzClass);

            if (form.ShowDialog() == DialogResult.OK)
            {
                //open up the template editor for this type...
                mTemplate = form.mSelectedType.newInstance();
                mTemplate.setPackage(mSelectedPackage);

                //Assign this object a package...
                mTemplate.setPackage(mSelectedPackage);

                object proxy = Editor.GetNewObjectProxy(mTemplate);
                propertyGrid1.SelectedObject = proxy;

                AddTemplateToTree(mPackageNode, mTemplate);

                Editor.AddEntity(mSelectedPackage.GetName(), mTemplate);
            }
        }
예제 #5
0
        private void addSubObject(ObjectBase objbase, TreeNode parentnode)
        {
            uint   hash = objbase.getObjectName();
            string text;

            if (hash == 0)
            {
                ClassBase godzClass = objbase.getClass();
                text = godzClass.ClassName;
            }
            else
            {
                text = Editor.GetHashString(hash);
            }

            System.Windows.Forms.TreeNode subobjnode = new TreeNode(text);
            subobjnode.Tag     = objbase;
            objectMap[objbase] = subobjnode;

            parentnode.Nodes.Add(subobjnode);

            addSubProperties(objbase, subobjnode);
        }
        private void classPickComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //user selected a class...
            uint classhash = GodzUtil.GetHashCode((string)classPickComboBox.SelectedItem);

            activeClass = null;

            foreach (ClassBase tempClass in classes)
            {
                if (tempClass.getObjectName() == classhash)
                {
                    activeClass = tempClass;
                    break;
                }
            }

            //grab all the properties....
            props.Clear();
            activeClass.getPropertiesNonRecurse(props);

            propertyListBox1.Items.Clear();
            foreach (ClassPropertyInfo cp in props)
            {
                propertyListBox1.Items.Add(cp.mName);
            }

            //grab the documentation for this class from the database...
            classInfo = (GodzClassInfo)GodzClassDescriptionRegistry.get(activeClass.getObjectName());

            if (classInfo == null)
            {
                classInfo = new GodzClassInfo();
                GodzClassDescriptionRegistry.put(activeClass.getObjectName(), classInfo);
            }

            dbProperties = classInfo.cpList;
        }
        static void Main(string[] args)
        {
            // A1. Implicit conversions  (Smaller -> Larger)
            int    x = 100;
            double y = x;

            // A2.Implicit conversions  (DrivedClass -> BaseClass)
            ClassDerived D = new ClassDerived();
            ClassBase    B = D;

            //===================================================================

            // B1.Explicit conversions (Larger -> Smaller)
            double d  = 123.4567;
            int    nd = (int)d; // Output: 123

            // B2.Explicit conversions   (BaseClass -> DrivedClass)
            ClassBase    Ba = new ClassBase();
            ClassDerived De = (ClassDerived)Ba;

            //===================================================================

            // C. Parse / TryParse

            string strName = "Reza";
            string strId   = "0010";

            bool Result          = int.TryParse(strName, out int converted_strName); //bool:TryParse(string,Int) : Check possibility of converting digits-OnString -> int and retrun boolean
            int  converted_strId = int.Parse(strId);                                 // int.Parse(string) : Convert String -> int

            //===================================================================

            // D. Convert.To_X

            int    I = 100;
            double J = Convert.ToDouble(I);
        }
        /// <summary>
        /// Parses the given statement list.
        /// </summary>
        /// <param name="statementParent">The direct parent of the statements to check.</param>
        /// <param name="parentElement">The element that contains the statements.</param>
        /// <param name="parentClass">The class that the element belongs to.</param>
        /// <param name="members">The collection of members of the parent class.</param>
        private void CheckClassMemberRulesForStatements(
            CodeUnit statementParent,
            Element parentElement,
            ClassBase parentClass,
            Dictionary <string, List <Element> > members)
        {
            Param.AssertNotNull(statementParent, "statementParent");
            Param.AssertNotNull(parentElement, "parentElement");
            Param.Ignore(parentClass);
            Param.Ignore(members);

            // Loop through each of the statements.
            for (Statement statement = statementParent.FindFirstChildStatement(); statement != null; statement = statement.FindNextSiblingStatement())
            {
                if (statement.Children.StatementCount > 0)
                {
                    // Parse the sub-statements.
                    this.CheckClassMemberRulesForStatements(statement, parentElement, parentClass, members);
                }

                // Parse the expressions in the statement.
                this.CheckClassMemberRulesForExpressions(statement, null, parentElement, parentClass, members);
            }
        }
예제 #9
0
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            currentNode = e.Node;
            if (e.Node.Tag is PackageInfo)
            {
                mPackageNode = e.Node;
                PackageInfo pinfo = (PackageInfo)e.Node.Tag;

                // Find the package...
                Package p = GodzUtil.FindPackage(pinfo.hash);
                if (p != null)
                {
                    mSelectedPackage = p;
                }
                else
                {
                    // Create the package.
                    // Note/Bug: if the pack exists somewhere on the
                    // hard drive and the user later loads that one
                    // it will lose this object.
                    mSelectedPackage = GodzUtil.AddPackage(pinfo.name, pinfo.type);
                }

                mTemplate = null;
                mValue    = null;
                propertyGrid1.SelectedObject = null;
            }
            else if (e.Node.Tag is ObjectBase)
            {
                // Stores context information
                PropertyContextData contextData   = null;
                ClassBase           templateClass = ClassBase.findClass("ObjectTemplate");

                ObjectBase obj = (ObjectBase)e.Node.Tag;
                if (obj.IsA(templateClass))
                {
                    mTemplate     = (ObjectBase)e.Node.Tag;
                    mTemplateNode = e.Node;

                    mSelectedPackage = mTemplate.getPackage();
                }
                else
                {
                    mSelectedPackage = obj.getPackage();

                    //Set the 'Template' parent object as the context. This way
                    //the property knows about it's parent Object
                    TreeNode tnode = e.Node.Parent;
                    while (tnode != null)
                    {
                        Object temp = tnode.Tag;
                        if (temp is ObjectBase)
                        {
                            ObjectBase tempBase = (ObjectBase)temp;
                            if (tempBase.IsA(templateClass))
                            {
                                contextData          = new PropertyContextData();
                                contextData.context1 = tempBase;
                                break;
                            }
                        }

                        tnode = tnode.Parent;
                    }
                }

                //Debug.Assert(mSelectedPackage != null);
                object          proxy    = Editor.GetNewObjectProxy(obj);
                ObjectBaseProxy objProxy = (ObjectBaseProxy)proxy;
                objProxy.contextData         = contextData;
                propertyGrid1.SelectedObject = proxy;

                mValue = null;
            }
            else if (e.Node.Tag is PropertyClassSelection)
            {
                PropertyClassSelection propertySelection = (PropertyClassSelection)e.Node.Tag;
                mSelectedPackage = propertySelection.obj.getPackage();
                mValue           = new PropertyGridValue();

                //refresh the property
                propertySelection.cp = propertySelection.obj.getPropertyValue(propertySelection.cp.mName);

                if (propertySelection.cp.mPropertyType == ClassPropertyType.PropertyType_HashCode)
                {
                    mValue.value = Editor.GetHashString(propertySelection.cp.mObjectHash);
                }
                else
                {
                    mValue.value = propertySelection.cp.mText;
                }

                mValue.mPropertySelection    = propertySelection;
                propertyGrid1.SelectedObject = mValue;
            }
        }
예제 #10
0
        /// <summary>
        /// Loads a guild and it's members from the database
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Guild LoadGuild(Guid id)
        {
            if (!Guilds.TryGetValue(id, out Guild found))
            {
                using (var context = DbInterface.CreatePlayerContext())
                {
                    var guild = context.Guilds.Where(g => g.Id == id).Include(g => g.Bank).FirstOrDefault();
                    if (guild != null)
                    {
                        //Load Members
                        var members = context.Players.Where(p => p.DbGuild.Id == id).ToDictionary(t => t.Id, t => new Tuple <Guid, string, int, int, Guid, Guid>(t.Id, t.Name, t.GuildRank, t.Level, t.ClassId, t.MapId));
                        foreach (var member in members)
                        {
                            var gmember = new GuildMember(member.Value.Item1, member.Value.Item2, member.Value.Item3, member.Value.Item4, ClassBase.GetName(member.Value.Item5), MapBase.GetName(member.Value.Item6));
                            guild.Members.AddOrUpdate(member.Key, gmember, (key, oldValue) => gmember);
                        }

                        SlotHelper.ValidateSlots(guild.Bank, guild.BankSlotsCount);
                        guild.Bank = guild.Bank.OrderBy(bankSlot => bankSlot?.Slot).ToList();

                        Guilds.AddOrUpdate(id, guild, (key, oldValue) => guild);

                        return(guild);
                    }
                }
            }
            else
            {
                return(found);
            }
            return(null);
        }
예제 #11
0
 public static RefObject GetRefObject(int value)
 {
     return(value > 0 ? ClassBase.GetRefObject() : null);
 }
예제 #12
0
 private void SaveFormValues(ClassIsCondition condition)
 {
     condition.ClassId = ClassBase.IdFromList(cmbClass.SelectedIndex);
 }
예제 #13
0
 public ClassWithLevelViewModel(ClassesViewModel owner, ClassBase classInstance)
     : base(owner, classInstance)
 {
 }
예제 #14
0
 static void Main()
 {
     ClassBase classA = ClassFactory.CreateClass("A");
     ClassBase classB = ClassFactory.CreateClass("B");
 }
예제 #15
0
파일: Method.cs 프로젝트: knuxbbs/gapi
        public void Generate(GenerationInfo generationInfo, ClassBase implementor)
        {
            Method complement = null;

            /* we are generated by the get Method, if there is one */
            if (IsSetter || IsGetter)
            {
                if (Modifiers != "new " && ContainerType.GetPropertyRecursively(Name.Substring(3)) != null)
                {
                    return;
                }

                complement = GetComplement();

                if (complement != null && IsSetter)
                {
                    if (Parameters.AccessorReturnType == complement.ReturnType)
                    {
                        return;
                    }

                    _call = string.Format("({0}{1})",
                                          IsStatic ? "" : ContainerType.CallByName() + (Parameters.Count > 0 ? ", " : ""),
                                          Body.GetCallString(false));

                    complement = null;
                    IsSetter   = false;
                }

                /* some setters take more than one arg */
                if (complement != null && !complement.IsSetter)
                {
                    complement = null;
                }
            }

            generationInfo.CurrentMember = Name;

            GenerateImport(generationInfo.Writer);
            if (complement != null && _returnValue.CsType == complement.Parameters.AccessorReturnType)
            {
                complement.GenerateImport(generationInfo.Writer);
            }

            if (IsDeprecated)
            {
                generationInfo.Writer.WriteLine("\t\t[Obsolete]");
            }
            generationInfo.Writer.Write("\t\t");
            if (Protection != "")
            {
                generationInfo.Writer.Write("{0} ", Protection);
            }
            GenerateDeclCommon(generationInfo.Writer, implementor);

            if (IsGetter || IsSetter)
            {
                generationInfo.Writer.Write("\t\t\t");
                generationInfo.Writer.Write(IsGetter ? "get" : "set");
                GenerateBody(generationInfo, implementor, "\t");
            }
            else
            {
                GenerateBody(generationInfo, implementor, "");
            }

            if (IsGetter || IsSetter)
            {
                if (complement != null && _returnValue.CsType == complement.Parameters.AccessorReturnType)
                {
                    generationInfo.Writer.WriteLine();
                    generationInfo.Writer.Write("\t\t\tset");
                    complement.GenerateBody(generationInfo, implementor, "\t");
                }

                generationInfo.Writer.WriteLine();
                generationInfo.Writer.WriteLine("\t\t}");
            }
            else
            {
                generationInfo.Writer.WriteLine();
            }

            if (Parameters.HasOptional && !(IsGetter || IsSetter))
            {
                GenerateOverloads(generationInfo.Writer);
            }

            generationInfo.Writer.WriteLine();

            Statistics.MethodCount++;
        }
예제 #16
0
        /// <summary>
        /// Gets a string to match the namespace of the type in a format that can be inserted into a regular expression for matching.
        /// </summary>
        /// <param name="type">The type to match.</param>
        /// <returns>Returns the namespace string.</returns>
        private static string BuildNamespaceRegex(ClassBase type)
        {
            Param.AssertNotNull(type, "type");

            // The fully-qualified name of a type should always begin with Root. This part should be ignored.
            return GetActualQualifiedNamespace(type);
        }
예제 #17
0
        /// <summary>
        /// Gets the actual qualified namespace of the class. For nested types where A.B.C.D exists and C.D is the type it returns A.B rather than A.B.C.
        /// </summary>
        /// <param name="type">The type to get the namespace for.</param>
        /// <returns>A string of the actual namespace.</returns>
        private static string GetActualQualifiedNamespace(ClassBase type)
        {
            Param.AssertNotNull(type, "type");

            Element localType = type;
            while (localType.Parent is ClassBase)
            {
                localType = (Element)localType.Parent;
            }

            string fullyQualifiedNameOfParentClass = localType.FullyQualifiedName;
            int lastIndexOfDot = fullyQualifiedNameOfParentClass.LastIndexOf('.');

            return lastIndexOfDot == -1 ? string.Empty : fullyQualifiedNameOfParentClass.Substring(0, lastIndexOfDot + 1);
        }
예제 #18
0
        /// <summary>
        /// Gets the actual name of the class. If nested type returns A+B rather than only B.
        /// </summary>
        /// <param name="type">The type to get the correct class name for.</param>
        /// <param name="showPlusInTypeName">True to show a '+' sign in a nested type.</param>
        /// <returns>A string of the actual class name.</returns>
        private static string GetActualClassName(ClassBase type, bool showPlusInTypeName)
        {
            Param.AssertNotNull(type, "type");
            Param.Ignore(showPlusInTypeName);

            Element localType = type;

            while (localType.Parent is ClassBase)
            {
                localType = (Element)localType.Parent;
            }

            int lastIndexOfDot = localType.FullyQualifiedName.LastIndexOf('.');
            if (lastIndexOfDot == -1)
            {
                return type.Name;
            }
            else
            {
                Debug.Assert(type.FullyQualifiedName.Length > lastIndexOfDot + 1, "The fully qualified name is corrupted.");
                string remainder = type.FullyQualifiedName.Substring(lastIndexOfDot + 1);
                return showPlusInTypeName ? remainder.Replace('.', '+') : remainder;
            }
        }
예제 #19
0
        /// <summary>
        /// Builds a regular expression that can be used to validate the name of the given type when 
        /// used within a documentation cref attribute.
        /// </summary>
        /// <param name="type">The type to match against.</param>
        /// <returns>Returns the regular expression object.</returns>
        private static string BuildCrefValidationStringForType(ClassBase type)
        {
            Param.AssertNotNull(type, "type");

            // We get the actual type name. For nested types this is A.B rather than just B.
            string actualTypeName = GetActualClassName(type, false);
            string[] typeNameParts = actualTypeName.Split('.');

            StringBuilder actualTypeNameWithoutGenerics = new StringBuilder();
            StringBuilder typeNameWithGenerics = new StringBuilder();

            for (int i = 0; i < typeNameParts.Length; ++i)
            {
                typeNameWithGenerics.Append(BuildTypeNameStringWithGenerics(typeNameParts[i]));
                actualTypeNameWithoutGenerics.Append(RemoveGenericsFromTypeName(typeNameParts[i]));

                if (i < typeNameParts.Length - 1)
                {
                    typeNameWithGenerics.Append(@"\.");
                    actualTypeNameWithoutGenerics.Append(@"\.");
                }
            }

            StringBuilder typeNameWithParamsNumber = new StringBuilder();
            for (int i = 0; i < typeNameParts.Length; i++)
            {
                typeNameWithParamsNumber.Append(BuildTypeNameStringWithParamsNumber(typeNameParts[i]));

                if (i < typeNameParts.Length - 1)
                {
                    typeNameWithParamsNumber.Append(@"\.");
                }
            }

            // Also capture the fully qualified name of the type, without generic parameters included.
            string namespaceRegex = BuildNamespaceRegex(type);

            // Build the regex string to match all possible formats for the type name.
            return string.Format(CultureInfo.InvariantCulture, CrefRegex, namespaceRegex, actualTypeNameWithoutGenerics, typeNameWithGenerics, typeNameWithParamsNumber);
        }
예제 #20
0
        /// <summary>
        /// Checks the Xml header block of the given class for consistency with the class.
        /// </summary>
        /// <param name="classElement">The element to parse.</param>
        /// <param name="settings">The analyzer settings.</param>
        private void CheckClassElementHeader(ClassBase classElement, AnalyzerSettings settings)
        {
            Param.AssertNotNull(classElement, "classElement");
            Param.Ignore(settings);

            AnalyzerSettings adjustedSettings = settings;
            adjustedSettings.RequireFields = false;

            if (classElement.ContainsModifier(TokenType.Partial))
            {
                // This is a partial element. Check for the possible partial element header types.
                this.CheckHeader(classElement, adjustedSettings, true);
            }
            else
            {
                // Just perform the regular set of checks on the header.
                this.CheckHeader(classElement, adjustedSettings, false);
            }
        }
예제 #21
0
    internal void Restore(ClassBase cb)
    {
        ClassManager.InitClassBase(cb.type.Value, cb, this);

        TypeManager.InitializeClass(this, cb, cb.type.Value);
    }
        /// <summary>
        /// Parses the given literal token.
        /// </summary>
        /// <param name="token">The literal token node.</param>
        /// <param name="expression">The expression that contains the token.</param>
        /// <param name="parentExpression">The parent of the expression that contains the token.</param>
        /// <param name="parentElement">The element that contains the expression.</param>
        /// <param name="parentClass">The class that the element belongs to.</param>
        /// <param name="members">The collection of members of the parent class.</param>
        private void CheckClassMemberRulesForLiteralToken(
            Token token,
            Expression expression,
            Expression parentExpression,
            Element parentElement,
            ClassBase parentClass,
            Dictionary <string, List <Element> > members)
        {
            Param.AssertNotNull(token, "token");
            Param.AssertNotNull(expression, "expression");
            Param.Ignore(parentExpression);
            Param.AssertNotNull(parentElement, "parentElement");
            Param.Ignore(parentClass);
            Param.Ignore(members);

            // Skip types. We only care about named members.
            if (token.TokenType != TokenType.Type)
            {
                // If the name starts with a dot, ignore it.
                if (!token.Text.StartsWith(".", StringComparison.Ordinal))
                {
                    if (token.Text == "base" && parentExpression != null)
                    {
                        // An item is only allowed to start with base if there is an implementation of the
                        // item in the local class and the caller is trying to explicitly call the base
                        // class implementation instead of the local class implementation. Extract the name
                        // of the item being accessed.
                        Token name = ReadabilityRules.ExtractBaseClassMemberName(parentExpression, token);
                        if (name != null)
                        {
                            ICollection <Element> matches = ReadabilityRules.FindClassMember(name.Text, parentClass, members, true);

                            // Check to see if there is a non-static match.
                            bool found = false;
                            if (matches != null)
                            {
                                foreach (Element match in matches)
                                {
                                    if (!match.ContainsModifier(TokenType.Static))
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                            }

                            if (!found)
                            {
                                this.AddViolation(parentElement, name.LineNumber, Rules.DoNotPrefixCallsWithBaseUnlessLocalImplementationExists, name);
                            }
                        }
                    }
                    else if (token.Text != "this")
                    {
                        // Check whether this word should really start with this.
                        this.CheckWordUsageAgainstClassMemberRules(
                            token.Text,
                            token,
                            token.LineNumber,
                            expression,
                            parentElement,
                            parentClass,
                            members);
                    }
                }
            }
        }
        /// <summary>
        /// Checks a word to see if it should start with this. or base.
        /// </summary>
        /// <param name="word">The word text to check.</param>
        /// <param name="item">The word being checked.</param>
        /// <param name="line">The line that the word appears on.</param>
        /// <param name="expression">The expression the word appears within.</param>
        /// <param name="parentElement">The element that contains the word.</param>
        /// <param name="parentClass">The parent class that this element belongs to.</param>
        /// <param name="members">The collection of members of the parent class.</param>
        private void CheckWordUsageAgainstClassMemberRules(
            string word,
            Token item,
            int line,
            Expression expression,
            Element parentElement,
            ClassBase parentClass,
            Dictionary <string, List <Element> > members)
        {
            Param.AssertValidString(word, "word");
            Param.AssertNotNull(item, "item");
            Param.AssertGreaterThanZero(line, "line");
            Param.AssertNotNull(expression, "expression");
            Param.AssertNotNull(parentElement, "parentElement");
            Param.Ignore(parentClass);
            Param.Ignore(members);

            // If there is a local variable with the same name, or if the item we're checking is within the left-hand side
            // of an object initializer expression, then ignore it.
            if (!IsLocalMember(word, item, expression) && !IsObjectInitializerLeftHandSideExpression(expression))
            {
                // Determine if this is a member of our class.
                Element foundMember = null;
                ICollection <Element> classMembers = ReadabilityRules.FindClassMember(word, parentClass, members, false);
                if (classMembers != null)
                {
                    foreach (Element classMember in classMembers)
                    {
                        if (classMember.ContainsModifier(TokenType.Static) ||
                            (classMember.ElementType == ElementType.Field && ((Field)classMember).Const))
                        {
                            // There is a member with a matching name that is static or is a const field. In this case,
                            // ignore the issue and quit.
                            foundMember = null;
                            break;
                        }
                        else if (classMember.ElementType != ElementType.Class &&
                                 classMember.ElementType != ElementType.Struct &&
                                 classMember.ElementType != ElementType.Delegate &&
                                 classMember.ElementType != ElementType.Enum)
                        {
                            // Found a matching member.
                            if (foundMember == null)
                            {
                                foundMember = classMember;
                            }
                        }
                    }

                    if (foundMember != null)
                    {
                        if (foundMember.ElementType == ElementType.Property)
                        {
                            // If the property's name and type are the same, then this is not a violation.
                            // In this case, the type is being accessed, not the property.
                            Property property = (Property)foundMember;
                            if (property.ReturnType.Text != property.Name)
                            {
                                this.Violation <Token>(
                                    Rules.PrefixLocalCallsWithThis,
                                    new ViolationContext(parentElement, line, word),
                                    this.FixPrefixLocalCallsWithThisViolation,
                                    item);
                            }
                        }
                        else
                        {
                            this.Violation <Token>(
                                Rules.PrefixLocalCallsWithThis,
                                new ViolationContext(parentElement, line, word),
                                this.FixPrefixLocalCallsWithThisViolation,
                                item);
                        }
                    }
                }
            }
        }
예제 #24
0
파일: FieldBase.cs 프로젝트: knuxbbs/gapi
 protected FieldBase(XmlElement element, ClassBase containerType) : base(element, containerType)
 {
 }
예제 #25
0
파일: Method.cs 프로젝트: knuxbbs/gapi
        private void GenerateDeclCommon(TextWriter textWriter, ClassBase implementor)
        {
            if (IsStatic)
            {
                textWriter.Write("static ");
            }

            textWriter.Write(Safety);

            Method dup = null;

            if (ContainerType != null)
            {
                dup = ContainerType.GetMethodRecursively(Name);
            }

            if (implementor != null)
            {
                dup = implementor.GetMethodRecursively(Name);
            }

            switch (Name)
            {
            case "ToString" when Parameters.Count == 0 && (!(ContainerType is InterfaceGen) || implementor != null):
                textWriter.Write("override ");
                break;

            case "GetGType" when ContainerType is ObjectGen || ContainerType?.Parent != null &&
                ContainerType.Parent.Methods.ContainsKey("GetType"):
                textWriter.Write("new ");
                break;

            default:
            {
                if (Modifiers == "new " || dup != null &&
                    (dup.Signature != null && Signature != null &&
                     dup.Signature.ToString() == Signature.ToString() ||
                     dup.Signature == null && Signature == null))
                {
                    textWriter.Write("new ");
                }

                break;
            }
            }

            if (Name.StartsWith(ContainerType.Name))
            {
                Name = Name.Substring(ContainerType.Name.Length);
            }

            if (IsGetter || IsSetter)
            {
                textWriter.Write(_returnValue.IsVoid ? Parameters.AccessorReturnType : _returnValue.CsType);
                textWriter.Write(" ");

                if (Name.StartsWith("Get") || Name.StartsWith("Set"))
                {
                    textWriter.Write(Name.Substring(3));
                }
                else
                {
                    var dotIndex = Name.LastIndexOf('.');

                    if (dotIndex != -1 && (Name.Substring(dotIndex + 1, 3) == "Get" ||
                                           Name.Substring(dotIndex + 1, 3) == "Set"))
                    {
                        textWriter.Write(Name.Substring(0, dotIndex + 1) + Name.Substring(dotIndex + 4));
                    }
                    else
                    {
                        textWriter.Write(Name);
                    }
                }

                textWriter.WriteLine(" { ");
            }
            else if (IsAccessor)
            {
                textWriter.Write($"{Signature.AccessorType} {Name}({Signature.AsAccessor})");
            }
            else
            {
                textWriter.Write($"{_returnValue.CsType} {Name}({(Signature != null ? Signature.ToString() : "")})");
            }
        }
예제 #26
0
 public void SetClass(ClassBase PickedClass)
 {
     MyClass = PickedClass;
 }
예제 #27
0
 public ChildProperty(XmlElement element, ClassBase containerType) : base(element, containerType)
 {
 }
예제 #28
0
        private void addToWorldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPanelData data = mMainForm.getTabPanel();

            if (data.mActiveLayer == null)
            {
                MessageBox.Show("Cannot add an entity without an active Sector. Please add one to the Level");
                return;
            }

            if (packageTreeView1.SelectedNode == null || packageTreeView1.SelectedNode.Tag == null)
            {
                //They must have selected a package node...
                return;
            }

            ObjectBase selectedNode = (ObjectBase)packageTreeView1.SelectedNode.Tag;

            //TODO: need to somehow cache off a global placement position
            GodzGlue.Vector3 cameraPos = data.mPrimaryCamera.getLocation();

            GodzGlue.Vector3 fdir = data.mPrimaryCamera.getForward();

            //y+ up
            fdir.z    += 100.0f;
            cameraPos += fdir;

            GodzGlue.Entity newActor = null;

            if (selectedNode.IsA("Mesh"))
            {
                //build entity then set Mesh
                newActor = data.mActiveLayer.spawnActor("WEntity", ref cameraPos, ref zero);

                //Get mesh from the package
                Mesh m = (Mesh)selectedNode;
                newActor.setMesh(m);
            }
            else if (selectedNode.IsA("WSunLight"))
            {
                if (data.mSun != null)
                {
                    //display error, can only have 1 Sun
                    MessageBox.Show("You can only have 1 sunlight in the scene");
                }
                else
                {
                    data.mSun = (GodzGlue.SunLight)data.mActiveLayer.spawnActor("WSunLight", ref cameraPos, ref zero);
                    data.mSun.setSunLight();
                    newActor = data.mSun;
                }
            }
            else
            {
                ClassBase gc = selectedNode.getClass();
                newActor = data.mActiveLayer.spawnActor(gc.getObjectName(), ref cameraPos, ref zero);
            }

            //set package....
            newActor.setPackage(data.mActiveLayer.getPackage());

            //Add to the Database
            Editor.AddEntity(data.mActiveLayer.getName(), newActor);

            //tick the actors so they send events over to renderer
            GodzUtil.RunMainPass();

            //Add the entity to the 'Actors' list
            AddActorToTree(newActor, actorsTreeView1.Nodes[0]);
        }
예제 #29
0
 public ClassViewModel(ClassesViewModel owner, ClassBase classInstance)
 {
     Owner         = owner;
     ClassInstance = classInstance;
 }
예제 #30
0
 public MethodAbiField(XmlElement element, ClassBase containerType, string infoName) :
     base(element, containerType, infoName)
 {
 }
예제 #31
0
 private void SetupFormValues(ClassIsCondition condition)
 {
     cmbClass.SelectedIndex = ClassBase.ListIndex(condition.ClassId);
 }
        /// <summary>
        /// Parses the given expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="parentExpression">The parent expression, if there is one.</param>
        /// <param name="parentElement">The element that contains the expressions.</param>
        /// <param name="parentClass">The class that the element belongs to.</param>
        /// <param name="members">The collection of members of the parent class.</param>
        private void CheckClassMemberRulesForExpression(
            Expression expression,
            Expression parentExpression,
            Element parentElement,
            ClassBase parentClass,
            Dictionary <string, List <Element> > members)
        {
            Param.AssertNotNull(expression, "expression");
            Param.Ignore(parentExpression);
            Param.AssertNotNull(parentElement, "parentElement");
            Param.AssertNotNull(parentClass, "parentClass");
            Param.AssertNotNull(members, "members");

            if (expression.ExpressionType == ExpressionType.Literal)
            {
                LiteralExpression literalExpression = (LiteralExpression)expression;

                // Check to see whether this literal is preceded by a member access symbol. If not
                // then we want to check whether this is a reference to one of our class members.
                if (!IsLiteralTokenPrecededByMemberAccessSymbol(literalExpression.Token))
                {
                    // Process the literal.
                    this.CheckClassMemberRulesForLiteralToken(
                        literalExpression.Token,
                        expression,
                        parentExpression,
                        parentElement,
                        parentClass,
                        members);
                }
            }
            else
            {
                if (expression.ExpressionType == ExpressionType.Assignment &&
                    parentExpression != null &&
                    parentExpression.ExpressionType == ExpressionType.CollectionInitializer)
                {
                    // When we encounter assignment expressions within collection initializer expressions, we ignore the expression
                    // on the left-hand side of the assignment. This is because we know that the left-hand side refers to a property on
                    // the type being initialized, not a property on the local class. Thus, it does not ever need to be prefixed by this.
                    // Without this check we can get name collisions, such as:
                    // public sealed class Person
                    // {
                    //     public string FirstName { get; }
                    //     public void CreateAnonymousType()
                    //     {
                    //         var anonymousType = new { FirstName = this.FirstName };
                    //     }
                    // }
                    this.CheckClassMemberRulesForExpression(((AssignmentExpression)expression).RightHandSide, expression, parentElement, parentClass, members);
                }
                else if (expression.Children.ExpressionCount > 0)
                {
                    // Check each child expression within this expression.
                    this.CheckClassMemberRulesForExpressions(expression, expression, parentElement, parentClass, members);
                }

                if (expression.Children.QueryClauseCount > 0)
                {
                    for (QueryClause clause = expression.FindFirstChildQueryClause(); clause != null; clause = clause.FindNextSiblingQueryClause())
                    {
                        this.CheckClassMemberRulesForQueryClause(clause, expression, parentElement, parentClass, members);
                    }
                }

                // Check if this is an anonymous method expression, which contains a child statement list.
                if (expression.ExpressionType == ExpressionType.AnonymousMethod)
                {
                    // Check the statements under this anonymous method.
                    this.CheckClassMemberRulesForStatements(expression, parentElement, parentClass, members);
                }
                else if (expression.ExpressionType == ExpressionType.MethodInvocation)
                {
                    // Check each of the arguments passed into the method call.
                    MethodInvocationExpression methodInvocation = (MethodInvocationExpression)expression;
                    foreach (Argument argument in methodInvocation.ArgumentList)
                    {
                        // Check each expression within this child expression.
                        this.CheckClassMemberRulesForExpression(
                            argument.Expression,
                            null,
                            parentElement,
                            parentClass,
                            members);
                    }
                }
            }
        }
예제 #33
0
        //Methods
        public void Update()
        {
            if (mCharacterWindow.IsHidden)
            {
                return;
            }

            mCharacterName.Text          = Globals.Me.Name;
            mCharacterLevelAndClass.Text = Strings.Character.levelandclass.ToString(
                Globals.Me.Level, ClassBase.GetName(Globals.Me.Class)
                );

            //Load Portrait
            //UNCOMMENT THIS LINE IF YOU'D RATHER HAVE A FACE HERE GameTexture faceTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Face, Globals.Me.Face);
            var entityTex = Globals.ContentManager.GetTexture(
                GameContentManager.TextureType.Entity, Globals.Me.MySprite
                );

            /* UNCOMMENT THIS BLOCK IF YOU"D RATHER HAVE A FACE HERE if (Globals.Me.Face != "" && Globals.Me.Face != _currentSprite && faceTex != null)
             * {
             *   _characterPortrait.Texture = faceTex;
             *   _characterPortrait.SetTextureRect(0, 0, faceTex.GetWidth(), faceTex.GetHeight());
             *   _characterPortrait.SizeToContents();
             *   Align.Center(_characterPortrait);
             *   _characterPortrait.IsHidden = false;
             *   for (int i = 0; i < Options.EquipmentSlots.Count; i++)
             *   {
             *       _paperdollPanels[i].Hide();
             *   }
             * }
             * else */
            if (Globals.Me.MySprite != "" && Globals.Me.MySprite != mCurrentSprite && entityTex != null)
            {
                for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
                {
                    var paperdoll = "";
                    var type      = GameContentManager.TextureType.Paperdoll;
                    if (Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z]) > -1)
                    {
                        var equipment = Globals.Me.MyEquipment;
                        if (equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])] > -1 &&
                            equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])] <
                            Options.MaxInvItems)
                        {
                            var itemNum = Globals.Me
                                          .Inventory[equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])]]
                                          .ItemId;

                            if (ItemBase.Get(itemNum) != null)
                            {
                                var itemdata = ItemBase.Get(itemNum);
                                if (Globals.Me.Gender == 0)
                                {
                                    paperdoll = itemdata.MalePaperdoll;
                                }
                                else
                                {
                                    paperdoll = itemdata.FemalePaperdoll;
                                }
                            }
                        }
                    }
                    else if (Options.PaperdollOrder[1][z] == "Player")
                    {
                        PaperdollPanels[z].Show();
                        PaperdollPanels[z].Texture = entityTex;
                        PaperdollPanels[z].SetTextureRect(0, 0, entityTex.GetWidth() / 4, entityTex.GetHeight() / 4);
                        PaperdollPanels[z].SizeToContents();
                        Align.Center(PaperdollPanels[z]);
                    }

                    if (paperdoll == "" && Options.PaperdollOrder[1][z] == Options.Equipment.HairSlot)
                    {
                        paperdoll = Globals.Me.CustomSpriteLayers[(int)Enums.CustomSpriteLayers.Hair];
                        type      = GameContentManager.TextureType.Hair;
                    }

                    if (string.IsNullOrWhiteSpace(paperdoll) && !string.IsNullOrWhiteSpace(PaperdollTextures[z]) && Options.PaperdollOrder[1][z] != "Player")
                    {
                        PaperdollPanels[z].Texture = null;
                        PaperdollPanels[z].Hide();
                        PaperdollTextures[z] = "";
                    }
                    else if (paperdoll != "" && paperdoll != PaperdollTextures[z])
                    {
                        var paperdollTex = Globals.ContentManager.GetTexture(
                            type, paperdoll
                            );

                        PaperdollPanels[z].Texture = paperdollTex;
                        if (paperdollTex != null)
                        {
                            PaperdollPanels[z]
                            .SetTextureRect(
                                0, 0, PaperdollPanels[z].Texture.GetWidth() / 4,
                                PaperdollPanels[z].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[z]
                            .SetSize(
                                PaperdollPanels[z].Texture.GetWidth() / 4,
                                PaperdollPanels[z].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[z]
                            .SetPosition(
                                mCharacterContainer.Width / 2 - PaperdollPanels[z].Width / 2,
                                mCharacterContainer.Height / 2 - PaperdollPanels[z].Height / 2
                                );
                        }

                        PaperdollPanels[z].Show();
                        PaperdollTextures[z] = paperdoll;
                    }
                }
            }
            else if (Globals.Me.MySprite != mCurrentSprite && Globals.Me.Face != mCurrentSprite)
            {
                mCharacterPortrait.IsHidden = true;
                for (var i = 0; i < Options.EquipmentSlots.Count; i++)
                {
                    PaperdollPanels[i].Hide();
                }
            }

            mAttackLabel.SetText(
                Strings.Character.stat0.ToString(Strings.Combat.stat0, Globals.Me.Stat[(int)Stats.Attack])
                );

            mDefenseLabel.SetText(
                Strings.Character.stat2.ToString(Strings.Combat.stat2, Globals.Me.Stat[(int)Stats.Defense])
                );

            mSpeedLabel.SetText(
                Strings.Character.stat4.ToString(Strings.Combat.stat4, Globals.Me.Stat[(int)Stats.Speed])
                );

            mAbilityPwrLabel.SetText(
                Strings.Character.stat1.ToString(Strings.Combat.stat1, Globals.Me.Stat[(int)Stats.AbilityPower])
                );

            mMagicRstLabel.SetText(
                Strings.Character.stat3.ToString(Strings.Combat.stat3, Globals.Me.Stat[(int)Stats.MagicResist])
                );

            mPointsLabel.SetText(Strings.Character.points.ToString(Globals.Me.StatPoints));
            mAddAbilityPwrBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                         Globals.Me.Stat[(int)Stats.AbilityPower] == Options.MaxStatValue;

            mAddAttackBtn.IsHidden =
                Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int)Stats.Attack] == Options.MaxStatValue;

            mAddDefenseBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                      Globals.Me.Stat[(int)Stats.Defense] == Options.MaxStatValue;

            mAddMagicResistBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                          Globals.Me.Stat[(int)Stats.MagicResist] == Options.MaxStatValue;

            mAddSpeedBtn.IsHidden =
                Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int)Stats.Speed] == Options.MaxStatValue;

            for (var i = 0; i < Options.EquipmentSlots.Count; i++)
            {
                if (Globals.Me.MyEquipment[i] > -1 && Globals.Me.MyEquipment[i] < Options.MaxInvItems)
                {
                    if (Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId != Guid.Empty)
                    {
                        Items[i]
                        .Update(
                            Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId,
                            Globals.Me.Inventory[Globals.Me.MyEquipment[i]].StatBuffs
                            );
                    }
                    else
                    {
                        Items[i].Update(Guid.Empty, mEmptyStatBoost);
                    }
                }
                else
                {
                    Items[i].Update(Guid.Empty, mEmptyStatBoost);
                }
            }
        }
예제 #34
0
파일: Property.cs 프로젝트: knuxbbs/gapi
        public void Generate(GenerationInfo generationInfo, string indent, ClassBase implementor)
        {
            if (Hidden || !Readable && !Writeable)
            {
                return;
            }

            var name = Name;

            if (name == ContainerType.Name)
            {
                name += "Prop";
            }

            GenerateImports(generationInfo, indent);

            var streamWriter = generationInfo.Writer;
            var qpname       = $"\"{CName}\"";
            var modifiers    = "";

            if (IsNew || ContainerType.Parent?.GetPropertyRecursively(Name) != null ||
                implementor?.Parent?.GetPropertyRecursively(Name) != null)
            {
                modifiers = "new ";
            }

            if (IsDeprecated || Getter != null && Getter.IsDeprecated ||
                Setter != null && Setter.IsDeprecated)
            {
                streamWriter.WriteLine($"{indent}[Obsolete]");
            }

            streamWriter.WriteLine("{0}{1}", indent, PropertyAttribute(qpname));
            streamWriter.WriteLine($"{indent}public {modifiers}{CsType} {name} {{");
            indent += "\t";

            var table = SymbolTable.Table;
            var vType = "";

            if (table.IsInterface(CType))
            {
                vType = "(GLib.Object)";
            }
            else if (table.IsOpaque(CType))
            {
                vType = "(GLib.Opaque)";
            }
            else if (table.IsEnum(CType))
            {
                vType = "(Enum)";
            }

            if (Getter != null)
            {
                streamWriter.Write($"{indent}get ");
                Getter.GenerateBody(generationInfo, implementor, "\t");
                streamWriter.WriteLine();
            }
            else if (Readable)
            {
                streamWriter.WriteLine($"{indent}get {{");
                streamWriter.WriteLine($"{indent}\tGLib.Value val = {RawGetter(qpname)};");

                if (table.IsOpaque(CType) || table.IsBoxed(CType))
                {
                    streamWriter.WriteLine($"{indent}\t{CsType} ret = ({CsType})val;");
                }
                else if (table.IsInterface(CType))
                {
                    var interfaceGen = table.GetInterfaceGen(CType);

                    // Do we have to dispose the GLib.Object from the GLib.Value?
                    streamWriter.WriteLine("{2}\t{0} ret = {1}.GetObject((GLib.Object)val);",
                                           interfaceGen.QualifiedName, interfaceGen.QualifiedAdapterName, indent);
                }
                else
                {
                    streamWriter.Write($"{indent}\t{CsType} ret = ");
                    streamWriter.Write($"({CsType}) ");

                    if (vType != "")
                    {
                        streamWriter.Write($"{vType} ");
                    }

                    streamWriter.WriteLine("val;");
                }

                streamWriter.WriteLine($"{indent}\tval.Dispose();");
                streamWriter.WriteLine($"{indent}\treturn ret;");
                streamWriter.WriteLine($"{indent}}}");
            }

            if (Setter != null)
            {
                streamWriter.Write($"{indent}set ");
                Setter.GenerateBody(generationInfo, implementor, "\t");
                streamWriter.WriteLine();
            }
            else if (Writeable)
            {
                streamWriter.WriteLine($"{indent}set {{");
                streamWriter.Write($"{indent}\tGLib.Value val = ");

                if (table.IsBoxed(CType))
                {
                    streamWriter.WriteLine("(GLib.Value)value;");
                }
                else if (table.IsOpaque(CType))
                {
                    streamWriter.WriteLine("new GLib.Value(value, \"{0}\");", CType);
                }
                else
                {
                    streamWriter.Write("new GLib.Value(");

                    if (vType != "" && !(table.IsObject(CType) || table.IsInterface(CType) || table.IsOpaque(CType)))
                    {
                        streamWriter.Write($"{vType} ");
                    }

                    streamWriter.WriteLine("value);");
                }

                streamWriter.WriteLine($"{indent}\t{RawSetter(qpname)};");
                streamWriter.WriteLine($"{indent}\tval.Dispose();");
                streamWriter.WriteLine($"{indent}}}");
            }

            streamWriter.WriteLine($"{indent.Substring(1)}}}");
            streamWriter.WriteLine();

            Statistics.PropCount++;
        }
예제 #35
0
 protected PropertyBase(XmlElement element, ClassBase containerType)
 {
     Element       = element;
     ContainerType = containerType;
 }
예제 #36
0
        //GameObjectPacket
        private static void HandlePacket(GameObjectPacket packet)
        {
            var id      = packet.Id;
            var deleted = packet.Deleted;
            var json    = "";

            if (!packet.Deleted)
            {
                json = packet.Data;
            }

            switch (packet.Type)
            {
            case GameObjectType.Animation:
                if (deleted)
                {
                    var anim = AnimationBase.Get(id);
                    anim.Delete();
                }
                else
                {
                    var anim = new AnimationBase(id);
                    anim.Load(json);
                    try
                    {
                        AnimationBase.Lookup.Set(id, anim);
                    }
                    catch (Exception exception)
                    {
                        Log.Error($"Another mystery NPE. [Lookup={AnimationBase.Lookup}]");
                        if (exception.InnerException != null)
                        {
                            Log.Error(exception.InnerException);
                        }

                        Log.Error(exception);
                        Log.Error($"{nameof(id)}={id},{nameof(anim)}={anim}");

                        throw;
                    }
                }

                break;

            case GameObjectType.Class:
                if (deleted)
                {
                    var cls = ClassBase.Get(id);
                    cls.Delete();
                }
                else
                {
                    var cls = new ClassBase(id);
                    cls.Load(json);
                    ClassBase.Lookup.Set(id, cls);
                }

                break;

            case GameObjectType.Item:
                if (deleted)
                {
                    var itm = ItemBase.Get(id);
                    itm.Delete();
                }
                else
                {
                    var itm = new ItemBase(id);
                    itm.Load(json);
                    ItemBase.Lookup.Set(id, itm);
                }

                break;

            case GameObjectType.Npc:
                if (deleted)
                {
                    var npc = NpcBase.Get(id);
                    npc.Delete();
                }
                else
                {
                    var npc = new NpcBase(id);
                    npc.Load(json);
                    NpcBase.Lookup.Set(id, npc);
                }

                break;

            case GameObjectType.Projectile:
                if (deleted)
                {
                    var proj = ProjectileBase.Get(id);
                    proj.Delete();
                }
                else
                {
                    var proj = new ProjectileBase(id);
                    proj.Load(json);
                    ProjectileBase.Lookup.Set(id, proj);
                }

                break;

            case GameObjectType.Quest:
                if (deleted)
                {
                    var qst = QuestBase.Get(id);
                    qst.Delete();
                }
                else
                {
                    var qst = new QuestBase(id);
                    qst.Load(json);
                    foreach (var tsk in qst.Tasks)
                    {
                        qst.OriginalTaskEventIds.Add(tsk.Id, tsk.CompletionEventId);
                    }

                    QuestBase.Lookup.Set(id, qst);
                }

                break;

            case GameObjectType.Resource:
                if (deleted)
                {
                    var res = ResourceBase.Get(id);
                    res.Delete();
                }
                else
                {
                    var res = new ResourceBase(id);
                    res.Load(json);
                    ResourceBase.Lookup.Set(id, res);
                }

                break;

            case GameObjectType.Shop:
                if (deleted)
                {
                    var shp = ShopBase.Get(id);
                    shp.Delete();
                }
                else
                {
                    var shp = new ShopBase(id);
                    shp.Load(json);
                    ShopBase.Lookup.Set(id, shp);
                }

                break;

            case GameObjectType.Spell:
                if (deleted)
                {
                    var spl = SpellBase.Get(id);
                    spl.Delete();
                }
                else
                {
                    var spl = new SpellBase(id);
                    spl.Load(json);
                    SpellBase.Lookup.Set(id, spl);
                }

                break;

            case GameObjectType.CraftTables:
                if (deleted)
                {
                    var cft = CraftingTableBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftingTableBase(id);
                    cft.Load(json);
                    CraftingTableBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Crafts:
                if (deleted)
                {
                    var cft = CraftBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftBase(id);
                    cft.Load(json);
                    CraftBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Map:
                //Handled in a different packet
                break;

            case GameObjectType.Event:
                var wasCommon = false;
                if (deleted)
                {
                    var evt = EventBase.Get(id);
                    wasCommon = evt.CommonEvent;
                    evt.Delete();
                }
                else
                {
                    var evt = new EventBase(id);
                    evt.Load(json);
                    wasCommon = evt.CommonEvent;
                    EventBase.Lookup.Set(id, evt);
                }

                if (!wasCommon)
                {
                    return;
                }

                break;

            case GameObjectType.PlayerVariable:
                if (deleted)
                {
                    var pvar = PlayerVariableBase.Get(id);
                    pvar.Delete();
                }
                else
                {
                    var pvar = new PlayerVariableBase(id);
                    pvar.Load(json);
                    PlayerVariableBase.Lookup.Set(id, pvar);
                }

                break;

            case GameObjectType.ServerVariable:
                if (deleted)
                {
                    var svar = ServerVariableBase.Get(id);
                    svar.Delete();
                }
                else
                {
                    var svar = new ServerVariableBase(id);
                    svar.Load(json);
                    ServerVariableBase.Lookup.Set(id, svar);
                }

                break;

            case GameObjectType.Tileset:
                var obj = new TilesetBase(id);
                obj.Load(json);
                TilesetBase.Lookup.Set(id, obj);
                if (Globals.HasGameData && !packet.AnotherFollowing)
                {
                    GameContentManager.LoadTilesets();
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GameObjectUpdatedDelegate?.Invoke(packet.Type);
        }