Esempio n. 1
0
        protected override void OnCopyItem(object parameter)
        {            
            if (parameter == null || !CanEditItem(parameter))
                return;

            var item = ((ItemWrapper) parameter).WrappedItem;
            ItemWrapper copy;

            if (item is WeaponRecord)
                copy = new WeaponWrapper();
            else copy = new ItemWrapper();

            copy.Name = I18NDataManager.Instance.ReadText(item.NameId);
            copy.TypeId = (int) item.TypeId;
            copy.Description = I18NDataManager.Instance.ReadText(item.DescriptionId);
            copy.IconId = item.IconId;
            copy.Level = item.Level;
            copy.RealWeight = item.RealWeight;
            copy.Cursed = item.Cursed;
            copy.UseAnimationId = item.UseAnimationId;
            copy.Usable = item.Usable;
            copy.Targetable = item.Targetable;
            copy.Price = item.Price;
            copy.TwoHanded = item.TwoHanded;
            copy.Etheral = item.Etheral;
            copy.ItemSetId = (uint) item.ItemSetId;
            copy.Criteria = item.Criteria;
            copy.CriteriaTarget = item.CriteriaTarget;
            copy.HideEffects = item.HideEffects;
            copy.Enhanceable = item.Enhanceable;
            copy.NonUsableOnAnother = item.NonUsableOnAnother;
            copy.AppearanceId = item.AppearanceId;
            copy.SecretRecipe = item.SecretRecipe;
            copy.RecipeIds = item.RecipeIds;
            copy.BonusIsSecret = item.BonusIsSecret;
            copy.WrappedEffects = new ObservableCollection<EffectWrapper>(item.PossibleEffects.Select(EffectWrapper.Create));
            copy.FavoriteSubAreas = item.FavoriteSubAreas;
            copy.FavoriteSubAreasBonus = item.FavoriteSubAreasBonus;
            copy.Weight = item.Weight;

            if (item is WeaponRecord)
            {
                var weapon = item as WeaponRecord;
                var copy_weapon = copy as WeaponWrapper;

                copy_weapon.ApCost = weapon.ApCost;
                copy_weapon.MinRange = weapon.MinRange;
                copy_weapon.Range = weapon.Range;
                copy_weapon.CastInLine = weapon.CastInLine;
                copy_weapon.CastInDiagonal = weapon.CastInDiagonal;
                copy_weapon.CastTestLos = weapon.CastTestLos;
                copy_weapon.CriticalHitProbability = weapon.CriticalHitProbability;
                copy_weapon.CriticalHitBonus = weapon.CriticalHitBonus;
                copy_weapon.CriticalFailureProbability = weapon.CriticalFailureProbability;

            }

            var editor = new ItemEditor(copy);
            editor.Show();
        }
Esempio n. 2
0
        private void OnTankPostSpawn()
        {
            if (data == null)
            {
                return;
            }
            var blockman = base.block.tank.blockman;

            foreach (var group in data.groups)
            {
                var actual_group = new WeaponGroup()
                {
                    name    = group.name,
                    keyCode = (KeyCode)group.keyCode
                };

                var weapons = group.positions.Select(p =>
                {
                    var block = blockman.GetBlockAtPosition(p);
                    if (block)
                    {
                        var weapon = new WeaponWrapper(block);
                        if (weapon.hammer)
                        {
                            if (ModuleWeaponGroupController.groups_for_hammer.TryGetValue(weapon.hammer, out var groups))
                            {
                                groups.Add(actual_group);
                            }
                            else
                            {
                                ModuleWeaponGroupController.groups_for_hammer.Add(weapon.hammer, new List <ModuleWeaponGroupController.WeaponGroup>()
                                {
                                    actual_group
                                });
                            }
                        }
                        return(weapon);
                    }
                    return(null);
                }).Where(ww => ww != null).ToList();

                actual_group.weapons = weapons;

                groups.Add(actual_group);
            }
            base.block.tank.ResetPhysicsEvent.Unsubscribe(this.OnTankPostSpawn);
        }