Пример #1
0
        partial void pCTC_Material(BaseEffectHandler eh, TotalChange tc)
        {
            try
            {
                ChangeInitInfo info;
                if (!ValidateChangeInit(ChangeType.Item_Material_Set, out info))
                {
                    return;
                }

                ItemMaterials material;
                if (tc.Components.Count < 1)
                {
                    material = Default_Material;
                }
                else
                {
                    // last entry counts
                    material = (ItemMaterials)tc.Components[0].GetParameters()[0];
                }

                var finalChange = Change.Create(info, new List <object>()
                {
                    material
                });
                tc.SetTotal(finalChange);
            }
            catch (Exception ex) { MakeLogError("Error while caclulating TotalChange via pCTC_Material: " + ex); }
        }
Пример #2
0
        partial void pCTC_CDStatic(BaseEffectHandler eh, TotalChange tc)
        {
            try
            {
                ChangeInitInfo info;
                if (!ValidateChangeInit(ChangeType.Vob_CDStatic_Set, out info))
                {
                    return;
                }

                // use default or value from last Change
                bool val = Default_CDStatic;
                if (tc.Components.Count > 0)
                {
                    val = (bool)tc.Components.Last().GetParameters()[0];
                }

                var finalChange = Change.Create(info, new List <object>()
                {
                    val
                });
                tc.SetTotal(finalChange);
            }
            catch (Exception ex) { MakeLogError("Error while caclulating TotalChange via pCTC_CDStatic: " + ex); }
        }
Пример #3
0
        partial void pCTC_VobType(BaseEffectHandler eh, TotalChange tc)
        {
            try
            {
                // stop here when there are no Changes to process
                if (tc.Components.Count < 1)
                {
                    return;
                }

                ChangeInitInfo info;
                if (!ValidateChangeInit(ChangeType.Vob_VobType_Set, out info))
                {
                    return;
                }

                // TO DO: only change VobType if the linked object is actually able to !!!
                // last entry counts
                var finalChange = Change.Create(info,
                                                new List <object>()
                {
                    tc.Components[tc.Components.Count - 1]
                });
                tc.SetTotal(finalChange);
            }
            catch (Exception ex) { MakeLogError("Error while caclulating TotalChange via pCTC_VobType: " + ex); }
        }
Пример #4
0
        public static TotalChange ReadTotalChange(PacketReader pr)
        {
            var tc = new TotalChange();

            // head
            var changeDest  = (ChangeDestination)TypeToRW[typeof(ChangeDestination)].Read(pr);
            var changeType  = (ChangeType)TypeToRW[typeof(ChangeType)].Read(pr);
            var paramLength = (int)TypeToRW[typeof(int)].Read(pr);

            // parameters
            List <object> param = new List <object>(paramLength);

            // generate the simplified TotalChange with only a total-value, no components
            var total = Change.Create(changeType, param);

            tc.SetTotal(total);

            return(tc);
        }
Пример #5
0
        protected bool TryGenerateIDAndChanges(List <List <object> > tableChange,
                                               out List <IDAndChanges> idAndChangesList)
        {
            idAndChangesList = new List <IDAndChanges>();
            if ((tableChange == null) || (tableChange.Count < 1))
            {
                return(false);
            }

            Change         change = null;
            int            effectID, changeID;
            ChangeType     changeType;
            string         paramsString   = null;
            List <object>  parameters     = null;
            ChangeInitInfo changeInitInfo = null;

            try
            {
                lock (loadLock)
                {
                    for (int i = 0; i < tableChange.Count; i++)
                    {
                        changeID = (int)tableChange[i][0];
                        effectID = (int)tableChange[i][1];

                        // translate the changeType
                        if (!Enum.TryParse((string)tableChange[i][2], out changeType))
                        {
                            MakeLogError(string.Format("Received unsupported ChangeType {0} "
                                                       + "from database! Aborting initialization of Change with ID {1}.",
                                                       tableChange[i][2], changeID));
                            continue;
                        }

                        // translate the parameters
                        paramsString = (string)tableChange[i][3];
                        if (!BaseChangeInit.TryGetChangeInitInfo(changeType, out changeInitInfo))
                        {
                            MakeLogError("Aborting initialization of Change with ID " + changeID
                                         + " because ChangeInitInfo for retrieving parameter types was not found!");
                            continue;
                        }
                        if (!TryParseParameters(paramsString, changeInitInfo.ParameterTypes, out parameters))
                        {
                            MakeLogError("Aborting initialization of Change because an error occured "
                                         + "while parsing respective parameters!");
                            continue;
                        }

                        // finally create the change
                        change = Change.Create(changeType, parameters);
                        if ((idAndChangesList.Count > 0) && (effectID == idAndChangesList[idAndChangesList.Count - 1].ID))
                        {
                            idAndChangesList[i].Changes.Add(change);
                        }
                        else
                        {
                            idAndChangesList.Add(new IDAndChanges(effectID, new List <Change>()
                            {
                                change
                            }));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MakeLogError("Error while parsing sqlResults to Changes and Effects: " + ex);
                return(false);
            }

            return(true);
        }
Пример #6
0
 public static IChange ToChange(this EntityEntry entry)
 => Change.Create(entry.State.ToEntityChange(), entry.Entity.GetType(), entry.Entity);