Пример #1
0
    public void Equip(Equippable equippable)
    {
        AssignableSlotInstance slot = GetSlot(equippable.slot);

        slot.Assign(equippable);
        GameObject targetGameObject = GetTargetGameObject();

        Debug.Assert(targetGameObject, "GetTargetGameObject returned null in Equip");
        targetGameObject.Trigger(-448952673, equippable.GetComponent <KPrefabID>());
        equippable.Trigger(-1617557748, this);
        Attributes attributes = targetGameObject.GetAttributes();

        if (attributes != null)
        {
            foreach (AttributeModifier attributeModifier in equippable.def.AttributeModifiers)
            {
                attributes.Add(attributeModifier);
            }
        }
        SnapOn component = targetGameObject.GetComponent <SnapOn>();

        if ((Object)component != (Object)null)
        {
            component.AttachSnapOnByName(equippable.def.SnapOn);
            if (equippable.def.SnapOn1 != null)
            {
                component.AttachSnapOnByName(equippable.def.SnapOn1);
            }
        }
        KBatchedAnimController component2 = targetGameObject.GetComponent <KBatchedAnimController>();

        if ((Object)component2 != (Object)null && (Object)equippable.def.BuildOverride != (Object)null)
        {
            component2.GetComponent <SymbolOverrideController>().AddBuildOverride(equippable.def.BuildOverride.GetData(), equippable.def.BuildOverridePriority);
        }
        if ((bool)equippable.transform.parent)
        {
            Storage component3 = equippable.transform.parent.GetComponent <Storage>();
            if ((bool)component3)
            {
                component3.Drop(equippable.gameObject, true);
            }
        }
        equippable.transform.parent = slot.gameObject.transform;
        equippable.transform.SetLocalPosition(Vector3.zero);
        SetEquippableStoredModifiers(equippable, true);
        equippable.OnEquip(slot);
        if (refreshHandle.TimeRemaining > 0f)
        {
            Debug.LogWarning(targetGameObject.GetProperName() + " is already in the process of changing equipment (equip)");
            refreshHandle.ClearScheduler();
        }
        CreatureSimTemperatureTransfer transferer = targetGameObject.GetComponent <CreatureSimTemperatureTransfer>();

        if (!((Object)component2 == (Object)null))
        {
            refreshHandle = GameScheduler.Instance.Schedule("ChangeEquipment", 2f, delegate
            {
                if ((Object)transferer != (Object)null)
                {
                    transferer.RefreshRegistration();
                }
            }, null, null);
        }
        Game.Instance.Trigger(-2146166042, null);
    }
Пример #2
0
    public GameObject CreatePrefab()
    {
        string     name       = DUPLICANTS.MODIFIERS.BASEDUPLICANT.NAME;
        GameObject gameObject = EntityTemplates.CreateEntity(ID, name, true);

        gameObject.AddOrGet <StateMachineController>();
        MinionModifiers modifiers = gameObject.AddOrGet <MinionModifiers>();

        AddMinionAmounts(modifiers);
        AddMinionTraits(name, modifiers);
        gameObject.AddOrGet <MinionBrain>();
        gameObject.AddOrGet <KPrefabID>().AddTag(GameTags.DupeBrain, false);
        gameObject.AddOrGet <Worker>();
        gameObject.AddOrGet <ChoreConsumer>();
        Storage storage = gameObject.AddOrGet <Storage>();

        storage.fxPrefix   = Storage.FXPrefix.PickedUp;
        storage.dropOnLoad = true;
        storage.SetDefaultStoredItemModifiers(new List <Storage.StoredItemModifier>
        {
            Storage.StoredItemModifier.Preserve,
            Storage.StoredItemModifier.Seal
        });
        gameObject.AddOrGet <Health>();
        OxygenBreather oxygenBreather = gameObject.AddOrGet <OxygenBreather>();

        oxygenBreather.O2toCO2conversion  = 0.02f;
        oxygenBreather.lowOxygenThreshold = 0.52f;
        oxygenBreather.noOxygenThreshold  = 0.05f;
        oxygenBreather.mouthOffset        = new Vector2f(0.25f, 0.7f);
        oxygenBreather.minCO2ToEmit       = 0.02f;
        oxygenBreather.breathableCells    = new CellOffset[6]
        {
            new CellOffset(0, 0),
            new CellOffset(0, 1),
            new CellOffset(1, 1),
            new CellOffset(-1, 1),
            new CellOffset(1, 0),
            new CellOffset(-1, 0)
        };
        gameObject.AddOrGet <WarmBlooded>();
        gameObject.AddOrGet <MinionIdentity>();
        GridVisibility gridVisibility = gameObject.AddOrGet <GridVisibility>();

        gridVisibility.radius      = 30f;
        gridVisibility.innerRadius = 20f;
        gameObject.AddOrGet <MiningSounds>();
        gameObject.AddOrGet <SaveLoadRoot>();
        gameObject.AddOrGet <AntiCluster>();
        Navigator navigator = gameObject.AddOrGet <Navigator>();

        navigator.NavGridName    = "MinionNavGrid";
        navigator.CurrentNavType = NavType.Floor;
        KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.isMovable  = true;
        kBatchedAnimController.sceneLayer = Grid.SceneLayer.Move;
        kBatchedAnimController.AnimFiles  = new KAnimFile[8]
        {
            Assets.GetAnim("body_comp_default_kanim"),
            Assets.GetAnim("anim_construction_default_kanim"),
            Assets.GetAnim("anim_idles_default_kanim"),
            Assets.GetAnim("anim_loco_firepole_kanim"),
            Assets.GetAnim("anim_loco_new_kanim"),
            Assets.GetAnim("anim_loco_tube_kanim"),
            Assets.GetAnim("anim_construction_firepole_kanim"),
            Assets.GetAnim("anim_construction_jetsuit_kanim")
        };
        KBoxCollider2D kBoxCollider2D = gameObject.AddOrGet <KBoxCollider2D>();

        kBoxCollider2D.offset = new Vector2(0f, 0.8f);
        kBoxCollider2D.size   = new Vector2(1f, 1.5f);
        SnapOn snapOn = gameObject.AddOrGet <SnapOn>();

        snapOn.snapPoints = new List <SnapOn.SnapPoint>(new SnapOn.SnapPoint[17]
        {
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"dig",
                buildFile      = Assets.GetAnim("excavator_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"build",
                buildFile      = Assets.GetAnim("constructor_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"fetchliquid",
                buildFile      = Assets.GetAnim("water_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"paint",
                buildFile      = Assets.GetAnim("painting_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"harvest",
                buildFile      = Assets.GetAnim("plant_harvester_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"capture",
                buildFile      = Assets.GetAnim("net_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"attack",
                buildFile      = Assets.GetAnim("attack_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"pickup",
                buildFile      = Assets.GetAnim("pickupdrop_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"store",
                buildFile      = Assets.GetAnim("pickupdrop_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"disinfect",
                buildFile      = Assets.GetAnim("plant_spray_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"tend",
                buildFile      = Assets.GetAnim("plant_harvester_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "carry",
                automatic      = false,
                context        = (HashedString)string.Empty,
                buildFile      = null,
                overrideSymbol = (HashedString)"snapTo_chest"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "build",
                automatic      = false,
                context        = (HashedString)string.Empty,
                buildFile      = null,
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "remote",
                automatic      = false,
                context        = (HashedString)string.Empty,
                buildFile      = null,
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "snapTo_neck",
                automatic      = false,
                context        = (HashedString)string.Empty,
                buildFile      = Assets.GetAnim("helm_oxygen_kanim"),
                overrideSymbol = (HashedString)"snapTo_neck"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"powertinker",
                buildFile      = Assets.GetAnim("electrician_gun_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            },
            new SnapOn.SnapPoint
            {
                pointName      = "dig",
                automatic      = false,
                context        = (HashedString)"specialistdig",
                buildFile      = Assets.GetAnim("excavator_kanim"),
                overrideSymbol = (HashedString)"snapTo_rgtHand"
            }
        });
        gameObject.AddOrGet <Effects>();
        gameObject.AddOrGet <Traits>();
        gameObject.AddOrGet <AttributeLevels>();
        gameObject.AddOrGet <AttributeConverters>();
        PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>();

        primaryElement.InternalTemperature = 310.15f;
        primaryElement.MassPerUnit         = 30f;
        primaryElement.ElementID           = SimHashes.Creature;
        gameObject.AddOrGet <ChoreProvider>();
        gameObject.AddOrGetDef <DebugGoToMonitor.Def>();
        gameObject.AddOrGetDef <SpeechMonitor.Def>();
        gameObject.AddOrGetDef <BlinkMonitor.Def>();
        gameObject.AddOrGetDef <ConversationMonitor.Def>();
        gameObject.AddOrGet <Sensors>();
        gameObject.AddOrGet <Chattable>();
        gameObject.AddOrGet <FaceGraph>();
        gameObject.AddOrGet <Accessorizer>();
        gameObject.AddOrGet <Schedulable>();
        LoopingSounds loopingSounds = gameObject.AddOrGet <LoopingSounds>();

        loopingSounds.updatePosition = true;
        gameObject.AddOrGet <AnimEventHandler>();
        FactionAlignment factionAlignment = gameObject.AddOrGet <FactionAlignment>();

        factionAlignment.Alignment = FactionManager.FactionID.Duplicant;
        gameObject.AddOrGet <Weapon>();
        gameObject.AddOrGet <RangedAttackable>();
        gameObject.AddOrGet <CharacterOverlay>();
        OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>();

        occupyArea.objectLayers         = new ObjectLayer[1];
        occupyArea.ApplyToCells         = false;
        occupyArea.OccupiedCellsOffsets = new CellOffset[2]
        {
            new CellOffset(0, 0),
            new CellOffset(0, 1)
        };
        gameObject.AddOrGet <Pickupable>();
        CreatureSimTemperatureTransfer creatureSimTemperatureTransfer = gameObject.AddOrGet <CreatureSimTemperatureTransfer>();

        creatureSimTemperatureTransfer.SurfaceArea = 10f;
        creatureSimTemperatureTransfer.Thickness   = 0.01f;
        gameObject.AddOrGet <SicknessTrigger>();
        gameObject.AddOrGet <ClothingWearer>();
        gameObject.AddOrGet <SuitEquipper>();
        DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>();

        decorProvider.baseRadius = 3f;
        decorProvider.isMovable  = true;
        gameObject.AddOrGet <ConsumableConsumer>();
        gameObject.AddOrGet <NoiseListener>();
        gameObject.AddOrGet <MinionResume>();
        DuplicantNoiseLevels.SetupNoiseLevels();
        SetupLaserEffects(gameObject);
        SymbolOverrideController symbolOverrideController = SymbolOverrideControllerUtil.AddToPrefab(gameObject);

        symbolOverrideController.applySymbolOverridesEveryFrame = true;
        ConfigureSymbols(gameObject);
        return(gameObject);
    }
Пример #3
0
    public void Unequip(Equippable equippable)
    {
        AssignableSlotInstance slot = GetSlot(equippable.slot);

        slot.Unassign(true);
        equippable.Trigger(-170173755, this);
        GameObject targetGameObject = GetTargetGameObject();

        if ((bool)targetGameObject)
        {
            targetGameObject.Trigger(-1285462312, equippable.GetComponent <KPrefabID>());
            KBatchedAnimController component = targetGameObject.GetComponent <KBatchedAnimController>();
            if (!destroyed)
            {
                if ((Object)equippable.def.BuildOverride != (Object)null && (Object)component != (Object)null)
                {
                    component.GetComponent <SymbolOverrideController>().TryRemoveBuildOverride(equippable.def.BuildOverride.GetData(), equippable.def.BuildOverridePriority);
                }
                Attributes attributes = targetGameObject.GetAttributes();
                if (attributes != null)
                {
                    foreach (AttributeModifier attributeModifier in equippable.def.AttributeModifiers)
                    {
                        attributes.Remove(attributeModifier);
                    }
                }
                if (!equippable.def.IsBody)
                {
                    SnapOn component2 = targetGameObject.GetComponent <SnapOn>();
                    component2.DetachSnapOnByName(equippable.def.SnapOn);
                    if (equippable.def.SnapOn1 != null)
                    {
                        component2.DetachSnapOnByName(equippable.def.SnapOn1);
                    }
                }
                if ((bool)equippable.transform.parent)
                {
                    Storage component3 = equippable.transform.parent.GetComponent <Storage>();
                    if ((bool)component3)
                    {
                        component3.Drop(equippable.gameObject, true);
                    }
                }
                SetEquippableStoredModifiers(equippable, false);
                equippable.transform.parent = null;
                equippable.transform.SetPosition(targetGameObject.transform.GetPosition() + Vector3.up / 2f);
                KBatchedAnimController component4 = equippable.GetComponent <KBatchedAnimController>();
                if ((bool)component4)
                {
                    component4.SetSceneLayer(Grid.SceneLayer.Ore);
                }
                if (!((Object)component == (Object)null))
                {
                    if (refreshHandle.TimeRemaining > 0f)
                    {
                        refreshHandle.ClearScheduler();
                    }
                    refreshHandle = GameScheduler.Instance.Schedule("ChangeEquipment", 1f, delegate
                    {
                        GameObject gameObject = (!((Object)this != (Object)null)) ? null : GetTargetGameObject();
                        if ((bool)gameObject)
                        {
                            CreatureSimTemperatureTransfer component5 = gameObject.GetComponent <CreatureSimTemperatureTransfer>();
                            if ((Object)component5 != (Object)null)
                            {
                                component5.RefreshRegistration();
                            }
                        }
                    }, null, null);
                }
            }
            Game.Instance.Trigger(-2146166042, null);
        }
    }